Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
1b6ac5d762
|
|||
95831d5e47
|
|||
c3dce9faab
|
|||
c332373691
|
|||
418b44289d
|
|||
23962cdebc
|
|||
b9e639e0a2
|
|||
1870089942
|
@ -52,6 +52,13 @@ create or replace view temperature_v as
|
||||
where application = 'Zigbee2MQTT Hottis Eupenstr.' and
|
||||
attributes->>'DeviceModel' in ('WSDCGQ11LM', 'WSDCGQ01LM');
|
||||
|
||||
create or replace view voltage_v as
|
||||
select time,
|
||||
cast(values->'Voltage'->>'value' as float) / 1000 as voltage,
|
||||
device
|
||||
from measurements
|
||||
where application = 'Zigbee2MQTT Hottis Eupenstr.' and
|
||||
attributes->>'DeviceModel' in ('WSDCGQ11LM', 'WSDCGQ01LM');
|
||||
|
||||
create or replace view temperature2_v as
|
||||
select time,
|
||||
|
@ -2,7 +2,7 @@ package snmp
|
||||
|
||||
import (
|
||||
"time"
|
||||
"log"
|
||||
// "log"
|
||||
"encoding/json"
|
||||
"udi/config"
|
||||
"udi/handlers/handler"
|
||||
@ -37,7 +37,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
}
|
||||
|
||||
func (self *SnmpHandler) Handle(message handler.MessageT) {
|
||||
log.Printf("Handler SNMP %d processing %s -> %s", self.Id, message.Topic, message.Payload)
|
||||
// log.Printf("Handler SNMP %d processing %s -> %s", self.Id, message.Topic, message.Payload)
|
||||
|
||||
var observation observation_t
|
||||
err := json.Unmarshal([]byte(message.Payload), &observation)
|
||||
@ -66,7 +66,7 @@ func (self *SnmpHandler) Handle(message handler.MessageT) {
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("Prepared measurement item: %s", measurement)
|
||||
// log.Printf("Prepared measurement item: %s", measurement)
|
||||
|
||||
self.dbh.StoreMeasurement(&measurement)
|
||||
self.S()
|
||||
|
55
src/udi/handlers/ttn/models/hottisGy21/hottisGY21.go
Normal file
55
src/udi/handlers/ttn/models/hottisGy21/hottisGY21.go
Normal file
@ -0,0 +1,55 @@
|
||||
package hottisGy21
|
||||
|
||||
import (
|
||||
//"log"
|
||||
"fmt"
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"udi/database"
|
||||
)
|
||||
|
||||
type hottisGy21Values struct {
|
||||
Connected uint8
|
||||
Status uint8
|
||||
RawHumidity uint16
|
||||
RawTemperature uint16
|
||||
}
|
||||
|
||||
|
||||
func Parse(fPort int, _ []byte, frmPayload string, variables *map[string]database.VariableType, attributes *map[string]interface{}, _ *database.Device) error {
|
||||
if fPort != 2 {
|
||||
return fmt.Errorf("Unexpected fPort %d", fPort)
|
||||
}
|
||||
|
||||
b, err := base64.StdEncoding.DecodeString(frmPayload)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to base64-decode payload: %v", err)
|
||||
}
|
||||
|
||||
var values hottisGy21Values
|
||||
err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &values)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to cast into struct: %v", err)
|
||||
}
|
||||
var temperature float32 = -46.85 + 175.72 * (float32(values.RawTemperature) / 65536.0)
|
||||
var humidity float32 = -6 + 125 * (float32(values.RawHumidity) / 65536.0);
|
||||
|
||||
// log.Printf("CO2: %f, Temp: %f, Hum: %f, Status: %d", co2concentration, temperature, humidity, values.Status)
|
||||
|
||||
(*variables)["Humidity"] = database.VariableType {
|
||||
Label: "Humidity",
|
||||
Variable: "Humidity",
|
||||
Unit: "%",
|
||||
Value: humidity,
|
||||
}
|
||||
(*variables)["Temperature"] = database.VariableType {
|
||||
Label: "Temperature",
|
||||
Variable: "Temperature",
|
||||
Unit: "°C",
|
||||
Value: temperature,
|
||||
}
|
||||
|
||||
(*attributes)["Status"] = values.Status
|
||||
return nil
|
||||
}
|
@ -14,6 +14,7 @@ import (
|
||||
"udi/handlers/ttn/models/draginoLsn50"
|
||||
"udi/handlers/ttn/models/rawPayloadPrinter"
|
||||
"udi/handlers/ttn/models/hottisScd30"
|
||||
"udi/handlers/ttn/models/hottisGy21"
|
||||
"udi/handlers/ttn/models/hottisThreeWayThermometer"
|
||||
"udi/database"
|
||||
)
|
||||
@ -153,6 +154,8 @@ func (self *TTNHandler) Handle(message handler.MessageT) {
|
||||
parser = rawPayloadPrinter.Parse
|
||||
case "hottis-scd30":
|
||||
parser = hottisScd30.Parse
|
||||
case "hottis-gy21":
|
||||
parser = hottisGy21.Parse
|
||||
case "hottis-threeway-thermometer":
|
||||
parser = hottisThreeWayThermometer.Parse
|
||||
default:
|
||||
|
15
src/udi/handlers/z2m/models/gs361ah04/gs361ah04.go
Normal file
15
src/udi/handlers/z2m/models/gs361ah04/gs361ah04.go
Normal file
@ -0,0 +1,15 @@
|
||||
package gs361ah04
|
||||
|
||||
type Observation struct {
|
||||
LinkQuality uint8 `unit:"" json:"linkquality"`
|
||||
Battery uint8 `unit:"%" json:"battery"`
|
||||
AwayMode string `unit:"" json:"away_mode"`
|
||||
ChildLock string `unit:"" json:"child_lock"`
|
||||
CurrentHeatingSetpoint float32 `unit:"°C" json:"current_heating_setpoint"`
|
||||
LocalTemperature float32 `unit:"°C" json:"local_temperature"`
|
||||
Preset string `unit:"" json:"preset"`
|
||||
SystemMode string `unit:"" json:"system_mode"`
|
||||
ValveDetection string `unit:"" json:"valve_detection"`
|
||||
WindowDetection string `unit:"" json:"window_detection"`
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"udi/database"
|
||||
"udi/handlers/z2m/models/wsdcgq11lm"
|
||||
"udi/handlers/z2m/models/wsdcgq01lm"
|
||||
"udi/handlers/z2m/models/gs361ah04"
|
||||
)
|
||||
|
||||
|
||||
@ -83,6 +84,8 @@ func (self *Z2MHandler) Handle(message handler.MessageT) {
|
||||
T = wsdcgq11lm.Observation{}
|
||||
case "WSDCGQ01LM":
|
||||
T = wsdcgq01lm.Observation{}
|
||||
case "GS361A-H04":
|
||||
T = gs361ah04.Observation{}
|
||||
default:
|
||||
self.Lost(fmt.Sprintf("No parser found for %s", device.DeviceType.ModelIdentifier), nil, message)
|
||||
return
|
||||
|
Reference in New Issue
Block a user