Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
15458b9955
|
|||
f55990cc57
|
|||
766355f85d
|
@ -1,7 +1,7 @@
|
|||||||
package hottisScd30
|
package hottisScd30
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
//"log"
|
||||||
"fmt"
|
"fmt"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
@ -17,7 +17,7 @@ type hottisScd30Values struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func Parse(fPort int, _ []byte, frmPayload string, variables *map[string]database.VariableType, _ *map[string]interface{}, _ *database.Device) error {
|
func Parse(fPort int, _ []byte, frmPayload string, variables *map[string]database.VariableType, attributes *map[string]interface{}, _ *database.Device) error {
|
||||||
if fPort != 2 {
|
if fPort != 2 {
|
||||||
return fmt.Errorf("Unexpected fPort %d", fPort)
|
return fmt.Errorf("Unexpected fPort %d", fPort)
|
||||||
}
|
}
|
||||||
@ -32,7 +32,30 @@ func Parse(fPort int, _ []byte, frmPayload string, variables *map[string]databas
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable to cast into struct: %v", err)
|
return fmt.Errorf("Unable to cast into struct: %v", err)
|
||||||
}
|
}
|
||||||
log.Printf("CO2: %d, Temp: %d, Hum: %d, Status: %d", values.CO2Conc, values.Temp, values.Hum, values.Status)
|
var co2concentration float32 = float32(values.CO2Conc) / 100;
|
||||||
|
var temperature float32 = float32(values.Temp) / 100;
|
||||||
|
var humidity float32 = float32(values.Hum) / 100;
|
||||||
|
// log.Printf("CO2: %f, Temp: %f, Hum: %f, Status: %d", co2concentration, temperature, humidity, values.Status)
|
||||||
|
|
||||||
|
(*variables)["CO2concentration"] = database.VariableType {
|
||||||
|
Label: "CO2concentration",
|
||||||
|
Variable: "Concentration",
|
||||||
|
Unit: "ppm",
|
||||||
|
Value: co2concentration,
|
||||||
|
}
|
||||||
|
(*variables)["Temperature"] = database.VariableType {
|
||||||
|
Label: "Temperature",
|
||||||
|
Variable: "Temperature",
|
||||||
|
Unit: "°C",
|
||||||
|
Value: temperature,
|
||||||
|
}
|
||||||
|
(*variables)["Humidity"] = database.VariableType {
|
||||||
|
Label: "Humidity",
|
||||||
|
Variable: "Humidity",
|
||||||
|
Unit: "%",
|
||||||
|
Value: humidity,
|
||||||
|
}
|
||||||
|
|
||||||
|
(*attributes)["Status"] = values.Status
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user