MadMonkey87 / HomeyCONZ

deCONZ app for Athom Homey smart home controller
3 stars 14 forks source link

Support for Xiaomi plug, Xiaomi plug EU and Aqara plug EU with measure_power and meter_power #10

Closed JeffL1 closed 4 years ago

JeffL1 commented 4 years ago

MadMonkey87,

Thank you for the Homey app and the support.

I have been gathering the information you requested. Since I am not a progammer and it's my first time working on Linux it took me a bit longer. If you need additional info I will do my best.

JSON and Sensor Xiaomi Aqara plugs v1.pdf

MadMonkey87 commented 4 years ago

Hey @JeffL1

I think I can support these two models. I just need some more details:

JeffL1 commented 4 years ago

Hey @MadMonkey87 ,

Let me know if your need more information.

Xiaomi and Aqara plugs v2.pdf

MadMonkey87 commented 4 years ago

Thx for the infos. What is strange to me is that it does not properly recognize the power, I've tested it on my homey with your data and I actually got a power capability on both plugs. Could you check if the unique id's are actually the same on the light and the sensor ressource (i.e upper- vs lowercase)?

JeffL1 commented 4 years ago

Hey @MadMonkey87 ,

Xiaomi smart plug (ZNCZ02LM) "modelid": "lumi.plug" Lights uniqueid": "00:15:XX:XX:XX:XX:XX:XX-01 Sensors "uniqueid": "00:15:XX:XX:XX:XX:XX:XX-02-000c" "uniqueid": "00:15:XX:XX:XX:XX:XX:XX-03-000c" Everything the same until the end, pattern at the end: -01 -02-000c -03-000c

Xiaomi smart plug (EU) (ZNCZ04LM) "modelid": "lumi.plug.mmeu01" Lights "uniqueid": "04:cf:XX:XX:XX:XX:XX:XX-01" Sensors "uniqueid": "04:cf:XX:XX:XX:XX:XX:XX-15-000c" "uniqueid": "04:cf:XX:XX:XX:XX:XX:XX-16-000c" Everything the same until the end, pattern at the end: -01 -15-000c -16-000c

Aqara smart plug EU (SP-EUC01) "modelid": "lumi.plug.maeu01" Lights "uniqueid": "04:cf:XX:XX:XX:XX:XX:XX-01" Sensors "uniqueid": "04:cf:XX:XX:XX:XX:XX:XX-01-0702" "uniqueid": "04:cf:XX:XX:XX:XX:XX:XX-01-0b04" Everything the same until the end, pattern at the end: -01 -01-0702 -01-0b04

MadMonkey87 commented 4 years ago

Very strange, when I mock exactly the json responses you submitted I can add the plugs using the generic and metering seems to work. Anyways, I've submitted a beta version of the next release supporting your devices. Can you please install it from over here and confirm if it works or not?

-> https://homey.app/de-ch/app/de.dresden-elektronik.deconz/deCONZ/test/

JeffL1 commented 4 years ago

Hey @MadMonkey87 ,

Installed the app it looks great. I almost got 2 out of 3 the plugs working. Now I am a bit stuck. I think some issues with rest-api hope you can provide some insight. Also I added some screenshots.

Xiaomi smart plug (ZNCZ02LM) Works perfect.

Xiaomi smart plug (EU) (ZNCZ04LM) 1 Worked perfect for some time and another did not have the device tab with power and consumption in the Homey app. Before I installed your Homey app I checked if the unique ID pattern of each type stayed the same for multiple plugs of the same type. The patterns were the same except for the second Xiaomi smart plug (EU) the new ligh JSON was added but their were no sensor JSON's added. ( Background: I installed 2 Xiaomi EU plugs on Deconz. After that I deleted one from Deconz and installed it directly on Homey for some testing. I installed a third Xiaomi EU plug the 2 sensor JSON’s of the second removed plug where still there.) Steps I took to get the plug working: 1 Removed the third plug from Phoscon and Homey > reinstall of plug did not work (no sensor JSON) 2 Removed the entries from the second "removed plug" with postman on restapi. > And add third plug again > no sensor JSON 3 Tried 2 mock JSON files based on the sensor info of a similir plug and an adapted unique ID based on pattern of the light. > Didn't get this working. 4 Removed all devices from Phoscon and Homey one by one. Did a complete reset of Phoscon gateway. Got a new API key, checked if the lights and sensor JSON's were empty. Added 6 devices to Phoscon 2 of each type. Changed the configuration in Homey with new Api Key. > No power and consumption tab available for Xiaomi smart plug EU. Also no sensor JSON for this plug 5 Opened a brand new never used plug and installed> No sensor JSON, no energy information in Homey. Result: 3 Xiaomi EU plugs none of them make entries in sensor and they don't show energy info in Homey.

Aqara smart plug EU (SP-EUC01) Gives the wrong Power values. I have tested 5 plugs 3 types with power information. 2 plugs where this Aqara. I have pluged in a 1watt continues device. All the other plugs show the correct information, the Aqara plugs show 15 watt.

Xiaomi and Aqara plugs v3.pdf

MadMonkey87 commented 4 years ago

Hey @JeffL1 Here is how my app works: it first takes the light ressource that represents the plug and then it tries to find all sensors belonging to it. If it cannot find them you will still be able to add the plug to turn it on/off, but it won't be displaying the consumption etc. You mentioned that one of your ZNCZ04LM devices has this sensor resources and the other one not? I would recommend to remove and pair the plug again or try to get help in the deconz repo. If these resources are not there the homey app has no way to read these values.

Did I get that right, the power values are correct for some devices but for others not?

JeffL1 commented 4 years ago

Hey @MadMonkey87,

Thanks for the feedback. Here's a quick update.

Xiaomi smart plug (ZNCZ02LM) Multiple plugs tested. Shows sensor JSONS and all correct power values in Homey. I think this plug is ready to be included in the next update.

Xiaomi smart plug (EU) (ZNCZ04LM) 0 Devices have JSONS sensors. Already tried: Repair plugs, Reset Phoscon. Completely removed Deconz and extra files. Tried 5 plugs of this type result 0 sensors. Contacted Deconz for help. Will update you once I have sensor JSONS again. To confirm if the values are right.

Aqara smart plug EU (SP-EUC01) This is type with the wrong power values. I checked for multiple devices the values directly in rest-api with Postman. For example A 1 watt devices show 15 watt in Rest-api. My current assumption is that device is at this point in time not properly supported in rest-api.

MadMonkey87 commented 4 years ago

Hey Sorry I forgot to answer:) I've pushed the updated as all remaining issues seem to be with deconz itself. Please feel free to reopen the case if there should be anything wrong in the app itself!