Smanar / Domoticz-deCONZ

deCONZ plugin for Domoticz (Zigbee application)
GNU General Public License v3.0
36 stars 27 forks source link

Aqara T1, SSM-U01 #75

Closed flopp999 closed 3 years ago

flopp999 commented 3 years ago

Added this On/Off to my Conbee 2. It created a device in Domoticz as Light switch, everything is OK

But it should also send energy consumption but it doesn't show up in Domoticz. Aqara plug with energy consumption was created after a few minutes.

I am running Domoticz 2020.2 Deconz Plugin 1.0.15 Conbee 2 USB Firmware 26660700 Phoscon 2.05.88 Debian Buster on NUC

flopp999 commented 3 years ago

from debug I got this {'attr': {'id': '13', 'lastannounced': None, 'lastseen': '2020-11-23T19:41Z', 'manufacturername': 'LUMI', 'modelid': 'lumi.switch.n0agl1', 'name': 'Sovrum_Tak', 'swversion': 'Aug 8 2020', 'type': 'On/Off light', 'uniqueid': '04:cf:8c:df:--:8e:--:61-01'}, 'e': 'changed', 'id': '13', 'r': 'lights', 't': 'event', 'uniqueid': '04:cf:8c:df:--:8e:--:61-01'}

I have removed some data from uniqueid for my safety

flopp999 commented 3 years ago

I think you can close this, I couldn't find any data about Power or Consumption in Phoscon API.

Smanar commented 3 years ago

Yep this device is not yet in deconz, some problem with an hidden cluster, need to rewrite the code https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3380

flopp999 commented 3 years ago

This is now working after an update in Rest-plugin, now it is on Beta but will soon be released

flopp999 commented 3 years ago

i noticed that Consumption is not working "51":{"config":{"battery":null,"on":true,"reachable":true,"temperature":0},"ep":1,"etag":"e723ddf8d2f2c94f24f1762e1c7a59b2","lastseen":"2020-12-17T16:19Z","manufacturername":"LUMI","modelid":"lumi.switch.n0agl1","name":"Consumption 51","state":{"consumption":9,"lastupdated":"2020-12-17T16:16:47.340","power":0},"swversion":"Aug 8 2020","type":"ZHAConsumption","uniqueid":"04:cf:8c:df:3c:8e:40:61-01-0702"},

image

Smanar commented 3 years ago

Ha ? Do you have a capture of the widget ? (Some of them have power + consumption, other only one)

aaa It's this one, so it display only consumption ?

On the code I m seing that

    elif _Type == 'ZHAConsumption':# in kWh
        #Device with only comsumption
        if True: # if IEEE.endswith('0702'):
            kwarg['Type'] = 113
            kwarg['Subtype'] = 0
            kwarg['Switchtype'] = 0
        #Device with power and energy, not exist (yet)
        else:
            kwarg['TypeName'] = 'kWh'

But I realy don't remember the problem, you are sure the power is working ? Not always 0 ?

flopp999 commented 3 years ago

Yes, I have a device for the consumption(kWh) I also have another device for the Power(watt) and of course the On/Off :)

data from API "51":{"config":{"battery":null,"on":true,"reachable":true,"temperature":0},"ep":1,"etag":"03256f911d0565ae42ea7153ea6579ba","lastseen":"2020-12-17T20:11Z","manufacturername":"LUMI","modelid":"lumi.switch.n0agl1","name":"Consumption 51","state":{"consumption":16,"lastupdated":"2020-12-17T20:11:24.375","power":0},"swversion":"Aug 8 2020","type":"ZHAConsumption","uniqueid":"04:cf:8c:df:3c:8e:40:61-01-0702"}

"61":{"config":{"battery":null,"on":true,"reachable":true,"temperature":0},"ep":1,"etag":"9d5d83c496eabc64cafd96cfcb23a5eb","lastseen":"2020-12-17T20:11Z","manufacturername":"LUMI","modelid":"lumi.switch.n0agl1","name":"Power 61","state":{"lastupdated":"2020-12-17T20:11:22.570","power":62},"swversion":"Aug 8 2020","type":"ZHAPower","uniqueid":"04:cf:8c:df:3c:8e:40:61-01-0b04"}

image

working Aqara Plug

58":{"config":{"on":true,"reachable":true,"temperature":0},"ep":1,"etag":"316f59ad26a3a36dbd1265e3784ed0ea","lastseen":"2020-12-17T20:17Z","manufacturername":"LUMI","modelid":"lumi.plug.maeu01","name":"Consumption 58","state":{"consumption":188104,"lastupdated":"2020-12-17T20:12:50.277"},"swversion":"09-10-2019","type":"ZHAConsumption","uniqueid":"04:cf:8c:df:3c:78:8b:4c-01-0702"},

flopp999 commented 3 years ago

other ZigBee also with Consumption is working image

flopp999 commented 3 years ago

from LOG in Domoticz

2020-12-17 22:24:40.728 (ConBee) ### WebSocket Data : {'e': 'changed', 'id': '51', 'r': 'sensors', 'state': {'consumption': 36, 'lastupdated': '2020-12-17T21:24:40.692', 'power': 0}, 't': 'event', 'uniqueid': '04:cf:8c:df:3c:8e:40:61-01-0702'}
2020-12-17 22:24:40.728 (ConBee) ### Update device (ConBee - Consumption 51) : {'nValue': 0, 'sValue': '0;36.0'}, IGNORED , no changes !
flopp999 commented 3 years ago

I don't know if this helps you. From fonctions.py

    if command == 'consumption':
        #Wh to Kwh
        kwh = round( float(val) * 1 ,3)
        #Device with power and comsuption
        if buffercommand.get('power'):
            p = buffercommand['power']
            buffercommand.clear()
            kwarg['nValue'] = 0
            kwarg['sValue'] = str(p) + ';' + str(kwh)
        #device with only consumption
        else:
            kwarg['nValue'] = 0
            kwarg['sValue'] = str(kwh)

    if command == 'power':
        buffercommand['power'] = val
        kwarg['nValue'] = 0
        kwarg['sValue'] = str(val)
flopp999 commented 3 years ago

it seems that the plugin combine power and kwh in svalue for Aqara T1 but not for Aqara Plug

2020-12-17 22:44:35.471 (ConBee) ### WebSocket Data : {'e': 'changed', 'id': '51', 'r': 'sensors', 'state': {'consumption': 36, 'lastupdated': '2020-12-17T21:44:35.443', 'power': 0}, 't': 'event', 'uniqueid': '04:cf:8c:df:3c:8e:40:61-01-0702'}
2020-12-17 22:44:35.472 (ConBee) ### Update device (ConBee - Consumption 51) : {'nValue': 0, 'sValue': '0;36.0'}, IGNORED , no changes !

2020-12-17 22:44:59.342 (ConBee) ### WebSocket Data : {'e': 'changed', 'id': '58', 'r': 'sensors', 'state': {'consumption': 188321, 'lastupdated': '2020-12-17T21:44:59.299'}, 't': 'event', 'uniqueid': '04:cf:8c:df:3c:78:8b:4c-01-0702'}
2020-12-17 22:44:59.342 (ConBee) ### Update device (Förrådet_Plugg_kWh) : {'nValue': 0, 'sValue': '188321.0'}
flopp999 commented 3 years ago

Yes, I have a device for the consumption(kWh) I also have another device for the Power(watt) and of course the On/Off :)

data from API "51":{"config":{"battery":null,"on":true,"reachable":true,"temperature":0},"ep":1,"etag":"03256f911d0565ae42ea7153ea6579ba","lastseen":"2020-12-17T20:11Z","manufacturername":"LUMI","modelid":"lumi.switch.n0agl1","name":"Consumption 51","state":{"consumption":16,"lastupdated":"2020-12-17T20:11:24.375","power":0},"swversion":"Aug 8 2020","type":"ZHAConsumption","uniqueid":"04:cf:8c:df:3c:8e:40:61-01-0702"}

"61":{"config":{"battery":null,"on":true,"reachable":true,"temperature":0},"ep":1,"etag":"9d5d83c496eabc64cafd96cfcb23a5eb","lastseen":"2020-12-17T20:11Z","manufacturername":"LUMI","modelid":"lumi.switch.n0agl1","name":"Power 61","state":{"lastupdated":"2020-12-17T20:11:22.570","power":62},"swversion":"Aug 8 2020","type":"ZHAPower","uniqueid":"04:cf:8c:df:3c:8e:40:61-01-0b04"}

image

working Aqara Plug

58":{"config":{"on":true,"reachable":true,"temperature":0},"ep":1,"etag":"316f59ad26a3a36dbd1265e3784ed0ea","lastseen":"2020-12-17T20:17Z","manufacturername":"LUMI","modelid":"lumi.plug.maeu01","name":"Consumption 58","state":{"consumption":188104,"lastupdated":"2020-12-17T20:12:50.277"},"swversion":"09-10-2019","type":"ZHAConsumption","uniqueid":"04:cf:8c:df:3c:78:8b:4c-01-0702"},

I see now that T1 have "power":0 so the DZ-plugin want to create a combined Device with Watt and kWh

flopp999 commented 3 years ago

I found a workaround

    if command == 'consumption':
        #Wh to Kwh
        kwh = round( float(val) * 1 ,3)
        #Device with power and comsuption
#        if buffercommand.get('power'):
#            p = buffercommand['power']
#            buffercommand.clear()
#            kwarg['nValue'] = 0
#            kwarg['sValue'] = str(p) + ';' + str(kwh)
        #device with only consumption
#        else:
        kwarg['nValue'] = 0
        kwarg['sValue'] = str(kwh)

so now it is not creating svalue with multiple data

Smanar commented 3 years ago

Yep, I think there is a bug from deconz, you have in the json

{"consumption":16,"power":0}

But power is not working, you have always 0, the power value is on the second second sensor, the ZHApower.

I think i already have this bug it s for that the sensor with power + consumption is disabled on code

        #Device with power and energy, not exist (yet)
        else:
            kwarg['TypeName'] = 'kWh'

So yes you are right, waiting for a device with both field in the same entry, I will disable this part like you https://github.com/Smanar/Domoticz-deCONZ/commit/55fce4fb8eb4b921afda37b6f8b3e5fa739b7270#diff-ad37c58f8e9f72bcc4c5e369a651593fc121f8f3e6ee49fb3facea2d5d13ba2c

Thx ^^

BTW Move your PR about the clicable link on the beta branch too, I will validate it immediatly. And you have finaly found a difference on your side with and without the "&" ?