stas-demydiuk / domoticz-zigbee2mqtt-plugin

zigbee2mqtt plugin for domoticz
MIT License
136 stars 98 forks source link

Temp+hum (*_th) devices removed(?)/stopped updating for Aqara WSDCGQ11LM #728

Closed odelma closed 2 years ago

odelma commented 2 years ago

Issue description I went ahead and updated to the latest version. It seems that now the temp+hum (*_th) devices are not updating anymore for at least WSDCGQ11LM, possibly this device type removed altogether. This was the primary device I was using. Also some of the other "legacy" devices are not updating but they are not critical from my viewpoint: image

Can we get the temp+hum device back?

Additional information Zigbee2MQTT version: updated 21.10.2021 Python version: 3.7.3 Domoticz version: updated 21.10.2021 (Version: 2021.1 (build 13738)) Plugin version: updated 21.10.2021

Art531 commented 2 years ago

Just add WSDCGQ11LM.py file with following code in your /domoticz/plugins/zigbee2mqtt/adapters/lumi folder:

from adapters.adapter_with_battery import AdapterWithBattery
from devices.sensor.temperature import TemperatureSensor
from devices.sensor.humidity import HumiditySensor
from devices.sensor.pressure import PressureSensor
from devices.sensor.barometer import BarometerSensor
from devices.temperature_humidity_sensor import TemperatureHumiditySensor
from devices.temperature_humidity_barometer_sensor import TemperatureHumidityBarometerSensor

# Xiaomi Aqara temperature, humidity and pressure sensor
class WSDCGQ11LM(AdapterWithBattery):
    def __init__(self, devices):
        super().__init__(devices)
        self.devices.append(TemperatureSensor(devices, 'temp', 'temperature', ' (Temperature)'))
        self.devices.append(HumiditySensor(devices, 'hum', 'humidity', ' (Humidity)'))
        self.devices.append(PressureSensor(devices, 'pres', 'pressure', ' (Pressure)'))
        self.devices.append(BarometerSensor(devices, 'bar', 'pressure', ' (Barometer)'))
        self.devices.append(TemperatureHumiditySensor(devices, 'th', 'combined', ' (Temperature + Humidity)'))
        self.devices.append(TemperatureHumidityBarometerSensor(devices, 'all', 'combined', ' (Temperature + Humidity + Barometer)'))

    def convert_message(self, message):
        message = super().convert_message(message)

        if 'temperature' in message.raw and 'humidity' in message.raw and 'pressure' in message.raw:
            message.raw['combined'] = {
                'temperature': message.raw['temperature'],
                'humidity': message.raw['humidity'],
                'pressure': message.raw['pressure']
            }

        return message

and then modify file _init_.py in the same folder, adding WSDCGQ11LM description (add two stirngs in this file, you will see where to add them):

from adapters.lumi.WSDCGQ11LM import WSDCGQ11LM

 'WSDCGQ11LM': WSDCGQ11LM,           # Xiaomi Aqara temperature, humidity and pressure sensor

and finally let domoticz accept new devices and restart zigbee2mqtt plugin, you will get your WSDCGQ11LM devices back.

odelma commented 2 years ago

Thanks a lot for the tip(/probable solution). It seems that now after several hours new set of temp+hum devices were created that are also updating 👍

I wonder why it went like this. Also the new voltage sensor show 3000V instead of 3.000V earlier 😄 - but that is minor…

sammyke007 commented 2 years ago

Maybe re-open this issue? I've updated too to the latest commit and indeed, the _th devices from the WSDCGQ11LM devices stopped from being updated. The above code might work, but gets lost on next updates.

commit 1fd64f27dc322238de5a7407aa15f252bdd930c1 is wat broke it

sammyke007 commented 2 years ago

The WSDCGQ11LM device has temp + hum + press. In the past, the plugin created both "temp + hum" and "temp + hum + press" devices (and each one individual too). After the commit mentioned above, it only creates a "temp + hum + press" device. Is it possible @stas-demydiuk to also create a "temp + hum" device next to it?

The voltage also indeed seems to be off by x1000 (3000V instead of 3.0V). Divide by 1000 or name it mV instead of V.