From aa3f784a41e71b03f60d84e2c48fba0b1b42f85f Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Mon, 11 Nov 2024 17:59:23 +0100 Subject: [PATCH] mi sensor --- queries/hottis.sql | 19 +++++++++++++++++-- .../z2m/models/wsdcgq01lm/wsdcgq01lm.go | 11 +++++++++++ src/udi/handlers/z2m/z2m.go | 3 +++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/udi/handlers/z2m/models/wsdcgq01lm/wsdcgq01lm.go diff --git a/queries/hottis.sql b/queries/hottis.sql index ef43632..17f9aca 100644 --- a/queries/hottis.sql +++ b/queries/hottis.sql @@ -43,7 +43,15 @@ create or replace view temperature_v as cast(values->'Value'->>'value' as float) as temperature, device from measurements - where application in ('Temperature Multisensor', 'Temperature Shelly Plus HT'); + where application in ('Temperature Multisensor', 'Temperature Shelly Plus HT') + union + select time, + cast(values->'Temperature'->>'value' as float) as temperature, + device + from measurements + where application = 'Zigbee2MQTT Hottis Eupenstr.' and + attributes->>'DeviceModel' in ('WSDCGQ11LM', 'WSDCGQ01LM'); + create or replace view temperature2_v as select time, @@ -57,7 +65,14 @@ create or replace view humidity_v as cast(values->'Value'->>'value' as float) as humidity, device from measurements - where application in ('Humidity Multisensor'); + where application in ('Humidity Multisensor') + union + select time, + cast(values->'Humidity'->>'value' as float) as temperature, + device + from measurements + where application = 'Zigbee2MQTT Hottis Eupenstr.' and + attributes->>'DeviceModel' in ('WSDCGQ11LM', 'WSDCGQ01LM'); create or replace view soil_v as select time, diff --git a/src/udi/handlers/z2m/models/wsdcgq01lm/wsdcgq01lm.go b/src/udi/handlers/z2m/models/wsdcgq01lm/wsdcgq01lm.go new file mode 100644 index 0000000..29b3e02 --- /dev/null +++ b/src/udi/handlers/z2m/models/wsdcgq01lm/wsdcgq01lm.go @@ -0,0 +1,11 @@ +package wsdcgq01lm + +type Observation struct { + LinkQuality uint8 `unit:"" json:"linkquality"` + Battery uint8 `unit:"%" json:"battery"` + Humidity float32 `unit:"%H" json:"humidity"` + Pressure float32 `unit:"mbar" json:"pressure"` + Temperature float32 `unit:"°C" json:"temperature"` + Voltage uint16 `unit:"mV" json:"voltage"` +} + diff --git a/src/udi/handlers/z2m/z2m.go b/src/udi/handlers/z2m/z2m.go index 1f45891..6779d09 100644 --- a/src/udi/handlers/z2m/z2m.go +++ b/src/udi/handlers/z2m/z2m.go @@ -11,6 +11,7 @@ import ( "udi/handlers/handler" "udi/database" "udi/handlers/z2m/models/wsdcgq11lm" + "udi/handlers/z2m/models/wsdcgq01lm" ) @@ -80,6 +81,8 @@ func (self *Z2MHandler) Handle(message handler.MessageT) { switch device.DeviceType.ModelIdentifier { case "WSDCGQ11LM": T = wsdcgq11lm.Observation{} + case "WSDCGQ01LM": + T = wsdcgq01lm.Observation{} default: self.Lost(fmt.Sprintf("No parser found for %s", device.DeviceType.ModelIdentifier), nil, message) return