Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for ZNCZ04LM #770

Merged
merged 2 commits into from
Nov 23, 2019
Merged

Added support for ZNCZ04LM #770

merged 2 commits into from
Nov 23, 2019

Conversation

tomaae
Copy link
Contributor

@tomaae tomaae commented Nov 23, 2019

zigbee2mqtt:info 2019-11-23T00:00:18: Device 'Computer' joined
zigbee2mqtt:info 2019-11-23T00:00:18: MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"device_connected","message":{"friendly_name":"Computer"}}'
zigbee2mqtt:info 2019-11-23T00:00:18: Starting interview of 'Computer'
zigbee2mqtt:info 2019-11-23T00:00:18: MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"pairing","message":"interview_started","meta":{"friendly_name":"Computer"}}'
zigbee2mqtt:info 2019-11-23T00:00:19: Successfully interviewed 'Computer', device has successfully been paired
zigbee2mqtt:info 2019-11-23T00:00:19: Device 'Computer' is supported, identified as: Xiaomi Mi power plug ZigBee EU (ZNCZ04LM)
zigbee2mqtt:info 2019-11-23T00:00:19: MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"pairing","message":"interview_successful","meta":{"friendly_name":"Computer","model":"ZNCZ04LM","vendor":"Xiaomi","description":"Mi power plug ZigBee EU","supported":true}}'
zigbee2mqtt:info 2019-11-23T00:00:22: MQTT publish: topic 'zigbee2mqtt/Computer', payload '{"state":"OFF","linkquality":36,"power":4.67}'
zigbee2mqtt:info 2019-11-23T00:00:38: MQTT publish: topic 'zigbee2mqtt/Computer', payload '{"state":"ON","linkquality":2,"power":4.67}'
zigbee2mqtt:info 2019-11-23T00:00:47: MQTT publish: topic 'zigbee2mqtt/Computer', payload '{"state":"ON","linkquality":34,"power":4.75}'
zigbee2mqtt:info 2019-11-23T00:01:18: MQTT publish: topic 'zigbee2mqtt/Computer', payload '{"state":"ON","linkquality":23,"power":0}'
zigbee2mqtt:info 2019-11-23T00:01:32: MQTT publish: topic 'zigbee2mqtt/Computer', payload '{"state":"ON","linkquality":28,"power":4.67}'

@Koenkk
Copy link
Owner

Koenkk commented Nov 23, 2019

Thanks! Could you provide an AliExpress link to the devive? Im interested in it.

@Koenkk Koenkk merged commit e96f56e into Koenkk:master Nov 23, 2019
@tomaae
Copy link
Contributor Author

tomaae commented Nov 23, 2019

Thanks! Could you provide an AliExpress link to the devive? Im interested in it.

I got it in a local xiaomi shop. I have already tried to look up this device, but it does not seem to be anywhere online yet.
Btw, it does not retain power state after power loss/unplug. In case that is something you need.

@Koenkk
Copy link
Owner

Koenkk commented Nov 23, 2019

Ok thanks, I guess its really new! Does it have the eu ground connectors?

EDIT: and whats the price?

EDIT 2: Could you make a photo of it?

@tomaae
Copy link
Contributor Author

tomaae commented Nov 23, 2019

Ok thanks, I guess its really new! Does it have the eu ground connectors?

EDIT: and whats the price?

EDIT 2: Could you make a photo of it?

It uses german shuko connectors (type F) and can be of course plugged into type E

Price was 29.99e, but thats a local shop, I bet it will be cheaper elsewhere

I have my PC plugged into it right now, but here is a photo of the packaging:
IMG_1335

@Koenkk
Copy link
Owner

Koenkk commented Nov 23, 2019

Looks great, thanks!

@rezmus
Copy link

rezmus commented Nov 23, 2019

@tomaae can you share which country you bought it in? i wait for this plug to show up on the market.

@tomaae
Copy link
Contributor Author

tomaae commented Nov 23, 2019

@tomaae can you share which country you bought it in? i wait for this plug to show up on the market.

Sure, Slovakia.
Its small and fairly quick to update watts. But wont retain power state after power loss, so my search continues.

@Koenkk
Copy link
Owner

Koenkk commented Nov 23, 2019

@tomaae I think the power state is configurable from the Xiaomi gateway, once it is available on AliExpress I will buy it and figure it out.

@tomaae
Copy link
Contributor Author

tomaae commented Nov 23, 2019

too bad they dont sell xiaomi gateway standalone here, otherwise I would give that a try.
but if it is configurable from xiaomi gateway, should not it be possible to do the same using z2m by sending it some payload? I think some other devices can be configured that way, like motion sensors are configured that way.

@rezmus
Copy link

rezmus commented Nov 23, 2019

this plug in not in mi home yet. atm it is only supported by chinese aqara hub firmware, but we should get update for mi eu / aqara eu hubs as well.

@rezmus
Copy link

rezmus commented Nov 23, 2019

this is how mi home read/write plug props via hub (based on lumi.plug.v1)

{"method":"get_device_prop","params":["lumi.158d000xxxxxxx","poweroff_memory","charge_protect","en_night_tip_light"]}
< {"code":0,"result":[1,0,1]}

{"method":"set_device_prop","params":{"sid":"lumi.158d000xxxxxxx","poweroff_memory":1}}
< {"code":0,"result":["ok"]}

@tomaae
Copy link
Contributor Author

tomaae commented Nov 23, 2019

sending it poweroff_memory option does nothing.
I tried to look over the code, but cant figure out this one.

@rezmus
Copy link

rezmus commented Nov 24, 2019

send it like this, it should work {"poweroff_memory":"on"}

@tomaae
Copy link
Contributor Author

tomaae commented Nov 24, 2019

I have already tried that, but I dont think it is supposed to work like that.

@rezmus
Copy link

rezmus commented Nov 24, 2019

this is log from serial console of lumi dev working on eu plug which shows poweroff_memory is being switched on.

[12:08:06:694]send to sdk {"cmd":"read","model":"plug.mmeu01","sid":"4cf8cdf3c74639c","short_id":"53546","token":"10014523","data":"{"poweroff_memory":"status"}"}
[12:08:06:739]serial port recv:{"cmd":"report","model":"plug.mmeu01","sid":"4cf8cdf3c74639c","short_id":53546,"token":"179","data":"{"poweroff_memory":"off"}"}

[12:08:11:582]send to sdk {"cmd":"write","model":"plug.mmeu01","sid":"4cf8cdf3c74639c","short_id":"53546","token":"10014530","data":"{"poweroff_memory":"on"}"}
[12:08:11:628]serial port recv:{"cmd":"report","model":"plug.mmeu01","sid":"4cf8cdf3c74639c","short_id":53546,"token":"950","data":"{"poweroff_memory":"on"}"}
[12:08:11:655]Debug : ===========AAA============= 153 send to ot_fd:{"id":46655,"method":"props","model":"lumi.plug.mmeu01","params":{"from.poweroff_memory":"0,,,0.trg=0","poweroff_memory":1},"sid":"lumi.4cf8cdf3c74639c"}

@Koenkk
Copy link
Owner

Koenkk commented Nov 24, 2019

It doenst work like that, somebody needs to sniff the traffic while connected to the xiaomi gateway, then it can be added.

@tomaae
Copy link
Contributor Author

tomaae commented Nov 24, 2019

I have 2 spare cc2531 on the way, I can turn one into a sniffer. Question is, which gateway version do I need that supports most mi/aqara devices so I can get configuration parameters for other devices too.

@rezmus
Copy link

rezmus commented Nov 24, 2019

most devices should be supported by new mi combo hub. sale starts on 12th december and it's priced ~18 USD in china.

@tomaae
Copy link
Contributor Author

tomaae commented Nov 24, 2019

I see, there will be both new Mi and Aqara hub and bunch of new sensors available soon. I will wait then, thanks.

@rezmus
Copy link

rezmus commented Nov 28, 2019

@tomaae
Copy link
Contributor Author

tomaae commented Nov 28, 2019

https://www.mobilonline.sk/produkt/mi-smart-zastrcka

Nice find. I will grab few from there once we get poweroff memory working

@rezmus
Copy link

rezmus commented Nov 28, 2019

do you have official xiaomi distributor on slovakia? i saw it already in 2 online .sk shops. strange i can't get it in any other eu country. in poland we have official distributor / mi stores, but still unknown when eu zigbee socket will be sold.

@tomaae
Copy link
Contributor Author

tomaae commented Nov 29, 2019

I got it at mi-store.sk. Not sure if they are official, but it seems so. They don’t have it on their web yet tho.
If you need help ordering it from sk site, I can help with translation and instructions.

@rezmus
Copy link

rezmus commented Nov 29, 2019

tx i'm not in such hurry and i don't think these shops ship abroad. it's kinda strange they sell it already, because this plug is still missing in mi home and current mi eu hub firmware won't pair with it afaik. it may only work with aqara hub via aqara app atm.

@rezmus
Copy link

rezmus commented Dec 1, 2019

there is also aqara brand new eu plug

https://aqara.ru/product/aqara-smart-plug/

@rezmus
Copy link

rezmus commented Dec 2, 2019

@tomaae i confirmed with polish reseller that they don't know anything about this product so it won't be fast till it's available here. i don't think that any .sk shop ships abroad. any chance you can order one for me? i should be able to make it work with my rooted eu hub.

@rezmus
Copy link

rezmus commented Dec 2, 2019

found another .sk shop, but they only ship to slovakia, czech, hungary.

https://www.rychlypresun.sk/produkty/540-mi-smart-zastrcka-wi-fi.html

there is also some info

XIAOMi products on our website are imported by the official XIAOMI distributor for the Slovak market and all are properly certified for the EU market.

so i guess there is official xiaomi distributor for slovakia and already have this plug in stock.

@tomaae
Copy link
Contributor Author

tomaae commented Dec 2, 2019

Careful, thats a wifi version. zigbee one is square, see photo above.
Of course I can get it for you, but if they dont send to Poland, I will have to ship it.
I'm on vacation right now, so I wont be able to get to mi store until next week. But if you want me to ship it to you, please contact me on twitter or discord. We dont want to put any personal information here :)

@rezmus
Copy link

rezmus commented Dec 2, 2019

ohh i think they mixed up zigbee model ZNCZ04LM and description with wifi plug photo (i have it, made by chuangmi, model ZNCZ05CM). anyway i will contact you next week, have a nice vacation!

@rezmus
Copy link

rezmus commented Dec 6, 2019

managed to buy it from mobilonline.sk, i should have it next week :)

@rezmus
Copy link

rezmus commented Dec 12, 2019

got mi eu plug. works fine with mi eu hub. does not pair with mi cn hub. power memory option works fine.

@tomaae
Copy link
Contributor Author

tomaae commented Dec 12, 2019

I have ordered that new mi hub yesterday, we see. I hope it work, since I cannot but eu hub standalone for sniffing.
also their new light sensor, I just hope that one is faster to react then philips.

@rezmus
Copy link

rezmus commented Dec 15, 2019

i've also ordered cc2531 with sniffer fw and will try to log zigbee payload for poweroff_memory ;)

@tomaae
Copy link
Contributor Author

tomaae commented Dec 15, 2019

perfect, once we get poweroff_memory working in z2m parameter working, it will be a perfect plug :)

@ryanbeaton
Copy link

Would be great to see powering_memory working. Closest I’ve ever seen was:
Koenkk/zigbee2mqtt#297 (comment)

@tomaae
Copy link
Contributor Author

tomaae commented Dec 16, 2019

I found a pcap here:
Koenkk/zigbee2mqtt#201 (comment)
It does not say much to me tho. data possibly needs decoding, but I never did that so not sure. I will try to find out how to do that when I have more free time.

@rezmus
Copy link

rezmus commented Dec 18, 2019

@tomaae @Koenkk

poweroff_memory

Attribute Field, Boolean: 0x01
Attribute: 0x0201
Data Type: Boolean (0x10)
0000 0001 = Boolean: True

en_night_tip_light

Attribute Field, Boolean: 0x01
Attribute: 0x0203
Data Type: Boolean (0x10)
0000 0001 = Boolean: True

max_power

Attribute Field, Float: 2300
Attribute: 0x020b
Data Type: Single Precision Floating Point (0x39)
Float: 2300

@tomaae
Copy link
Contributor Author

tomaae commented Dec 18, 2019

Perfect, I will check if I’m able to get it working when I get home

@tomaae
Copy link
Contributor Author

tomaae commented Dec 18, 2019

I have tried, but it does not do anything. No mention in debugs too, so not sure.

ZNCZ04LM_poweroff_memory: {
key: ['poweroff_memory'],
convertSet: async (entity, key, value, meta) => {
await entity.write('genBasic', {0x0201: {value: value ? 0x01 : 0x00, type: 0x10}}, options.xiaomi);
},
},
ZNCZ04LM_led: {
key: ['led'],
convertSet: async (entity, key, value, meta) => {
await entity.write('genBasic', {0x0203: {value: value ? 0x01 : 0x00, type: 0x10}}, options.xiaomi);
},
},

@rezmus
Copy link

rezmus commented Dec 18, 2019

can you log raw hex payload being sent? in hex it looks like 01 02 10 01 for poweroff_memory true (reversed byte order of attribute 0x0201). i can provide full pcap if needed. i guess we need @Koenkk here ;)

@tomaae
Copy link
Contributor Author

tomaae commented Dec 18, 2019

I dont have a sniffer yet, so I cant. but if you can give me pcap, I will have a look :)

@rezmus
Copy link

rezmus commented Dec 19, 2019

@tomaae
Copy link
Contributor Author

tomaae commented Dec 19, 2019

image
I see there is a custom cluster. I tried to add it, but nothing. Guess we need someone more experienced with this.

@tomaae
Copy link
Contributor Author

tomaae commented Dec 19, 2019

I have created #827 , hopefully someone can help

@tomaae
Copy link
Contributor Author

tomaae commented Dec 19, 2019

I see my custom cluster implementation was recognized tho

2019-12-19 06:40:31: No converter available for 'ZNCZ04LM' with cluster 'manuSpecificXiaomi' and type 'attributeReport' and data '{"247":{"type":"Buffer","data":[100,16,1,3,40,30,152,57,0,0,0,0,149,57,41,163,106,62,150,57,0,32,20,69,151,57,0,0,0,0,5,33,38,0,154,32,16,8,33,22,1,7,39,0,0,0,0,0,0,0,0,9,33,2,8,11,32,0,155,16,0]}}'

I wonder what are those. Some settings I guess.

3rd is on/off state
Last number seems to be "plugged" status
@rezmus maybe you can find out which one is led and poweroff_memory? just change one of them and wait a bit until device reports with cluster 64704

@tomaae
Copy link
Contributor Author

tomaae commented Dec 19, 2019

and this seems to be detection that something was plugged physically into the socket. Nice

zigbee2mqtt:warn 2019-12-19 06:45:24: No converter available for 'ZNCZ04LM' with cluster 'manuSpecificXiaomi' and type 'attributeReport' and data '{"519":0}'
zigbee2mqtt:warn 2019-12-19 06:45:26: No converter available for 'ZNCZ04LM' with cluster 'manuSpecificXiaomi' and type 'attributeReport' and data '{"519":1}'

Added:
image
Needs better name tho

@rezmus
Copy link

rezmus commented Dec 19, 2019

poweroff_memory / en_night_tip_light state change does not lead to any changes in 0x00f7. btw 0x0202 is charge_protect.

@tomaae
Copy link
Contributor Author

tomaae commented Dec 20, 2019

hmm, too bad, that means we cannot show them in UI. but thats not really important to see in UI.
seems like my implementation for poweroff_memory and led is correct according to example Koenkk gave me.
I'm so confused about whats wrong there. Your pcap cannot be wrong, we have correct values.

any idea what charge_protect is? protection against pulling over amp rating for that plug?

Also, while looking for some things, I found this on google, saying it is in this thread for some reason. Seems to be a complete device config:

{ "type": "plug", "mode": "alway_wake", "props": { "channel_0" :{"type":"status", "sync":true, "default":"off"}, "load_voltage" :{"type":"status", "sync":true, "default":0}, "load_power" :{"type":"status", "sync":true, "default":0}, "power" :{"type":"status", "sync":true, "default":"off"}, "protect" :{"type":"status", "sync":false, "default":"temp"}, "fw_ver" :{"type":"status", "sync":false, "default":0}, "hw_ver" :{"type":"status", "sync":false, "default":0}, "poweroff_memory" :{"type":"status", "sync":true, "default":0}, "charge_protect" :{"type":"status", "sync":true, "default":0}, "en_night_tip_light":{"type":"config", "sync":false, "default":0}, "power_on_join" :{"type":"config", "sync":false, "default":0}, "plug_detection" :{"type":"config", "sync":false, "default":"plug_out"}, "max_power" :{"type":"config", "sync":true, "default":1800} }, "prop_trans": { "lumi2xiaomi_prop": { "0.11.85" :[["", "p;load_voltage;"]], "0.12.85" :[["", "p;load_power;"]], "0.13.85" :[["", "n;;"]], "13.1.85" :[["", "n;;"]], "14.1.111" :[["*", "n;;"]], "14.30.85" :[["", "n;;"]], "14.31.85" :[["", "n;;"]], "14.9.111" :[["", "n;;"]], "14.9.85" :[["", "n;;"]], "4.1.104" :[["", "n;;"]], "4.1.85" :[["0", "p;channel_0;"off""], ["1", "p;channel_0;"on""], ["2", "n;;"]], "4.1.87" :[["", "n;;"]], "4.10.85" :[["", "n;;"]], "4.4.85" :[["", "n;;"]], "410.0.85" :[["", "n;;"]], "8.0.2002" :[["", "n;;"]], "8.0.2003" :[["*", "n;;"]], "8.0.2004" :[["", "n;;"]], "8.0.2005" :[["", "n;;"]], "8.0.2006" :[["", "n;;"]], "8.0.2007" :[["", "n;;_"]], "8.0.2008" :[["", "n;;"]], "8.0.2009" :[["", "n;;"]], "8.0.2010" :[["", "n;;"]], "8.0.2011" :[["", "n;;"]], "8.0.2012" :[["*", "n;;"]], "8.0.2013" :[["", "n;;"]], "8.0.2014" :[["1", "p;protect;"temp""], ["2", "p;protect;"voload""]], "8.0.2015" :[["1", "p;power;"on""], ["0", "p;power;"off""], ["2", "p;power;"unknown""]], "8.0.2021" :[["", "n;;"]], "8.0.2022" :[["", "p;fw_ver;"]], "8.0.2023" :[["", "p;hw_ver;" ]], "8.0.2024" :[["", "n;;"]], "8.0.2025" :[["", "n;;_"]], "8.0.2026" :[["", "n;;"]], "8.0.2027" :[["", "n;;"]], "8.0.2028" :[["", "n;;"]], "8.0.2029" :[["", "n;;"]], "8.0.2030" :[["", "p;poweroff_memory;"]], "8.0.2031" :[["", "p;charge_protect;"]], "8.0.2032" :[["", "p;en_night_tip_light;"]], "8.0.2033" :[["*", "n;;"]], "8.0.2041" :[["", "n;;"]], "8.0.2042" :[["", "p;max_power;"]], "8.0.2044" :[["0", "p;plug_detection;"plug_out""], ["1", "p;plug_detection;"plug_in""]], "8.0.2045" :[["", "n;;"]], "8.0.2086" :[["", "n;;"]], "8.0.9001" :[["", "n;;_"]] }, "lumi2xiaomi_upload": { "0.11.85" :[["", "p;load_voltage;"]], "0.12.85" :[["", "p;load_power;"]], "0.13.85" :[["", "n;;"]], "13.1.85" :[["", "n;;"]], "14.1.111" :[["", "n;;"]], "14.30.85" :[["", "n;;"]], "14.31.85" :[["*", "n;;"]], "14.9.111" :[["", "n;;"]], "14.9.85" :[["", "n;;"]], "4.1.104" :[["", "n;;"]], "4.1.85" :[["0", "p;channel_0;"off""], ["1", "p;channel_0;"on""], ["2", "n;;"]], "4.1.87" :[["", "n;;"]], "4.10.85" :[["", "n;;"]], "4.4.85" :[["", "n;;"]], "410.0.85" :[["*", "n;;"]], "8.0.2002" :[["", "n;;"]], "8.0.2003" :[["", "n;;"]], "8.0.2004" :[["", "n;;"]], "8.0.2005" :[["", "n;;_"]], "8.0.2006" :[["", "n;;"]], "8.0.2007" :[["", "n;;"]], "8.0.2008" :[["", "n;;"]], "8.0.2009" :[["", "n;;"]], "8.0.2010" :[["*", "n;;"]], "8.0.2011" :[["", "n;;"]], "8.0.2012" :[["", "n;;"]], "8.0.2013" :[["", "n;;"]], "8.0.2014" :[["1", "p;protect;"temp""], ["2", "p;protect;"voload""]], "8.0.2015" :[["1", "p;power;"on""], ["0", "p;power;"off""], ["2", "p;power;"unknown""]], "8.0.2021" :[["", "n;;_"]], "8.0.2022" :[["", "p;fw_ver;"]], "8.0.2023" :[["", "p;hw_ver;" ]], "8.0.2024" :[["", "n;;"]], "8.0.2025" :[["", "n;;"]], "8.0.2026" :[["", "n;;"]], "8.0.2027" :[["", "n;;"]], "8.0.2028" :[["*", "n;;"]], "8.0.2029" :[["", "n;;"]], "8.0.2030" :[["", "n;;"]], "8.0.2031" :[["", "n;;"]], "8.0.2032" :[["", "n;;_"]], "8.0.2033" :[["", "n;;"]], "8.0.2041" :[["", "n;;"]], "8.0.2042" :[["", "p;max_power;"]], "8.0.2044" :[["1", "e;plug_detection;"plug_in""], ["0", "e;plug_detection;"plug_out""]], "8.0.2045" :[["", "n;;_"]], "8.0.2086" :[["", "n;;"]], "8.0.9001" :[["*", "n;;"]] }, "xiaomi2lumi": { "channel_0" :["4.1.85", [[""on"", "1"], [""off"", "0"], [""toggle"", "2"]]], "load_voltage" :["0.11.85", [["" , "" ]]], "load_power" :["0.12.85", [["" , "" ]]], "power" :["8.0.2015", [[""on"", "1"], [""off"", "0" ], [""unknow"", "2"]]], "protect" :["8.0.2014", [[""temp"", "8"], [""voload"","4"]]], "fw_ver" :["8.0.2022", [["" , "" ]]], "hw_ver" :["8.0.2023", [["" , "" ]]], "poweroff_memory" :["8.0.2030", [["" , "" ]]], "charge_protect" :["8.0.2031", [["" , "" ]]], "en_night_tip_light":["8.0.2032", [["" , "" ]]], "plug_detection" :["8.0.2044", [[""plug_in"", "0"], [""plug_out"", "1"]]], "max_power" :["8.0.2042", [["" , "" ]]] } } }

@rezmus
Copy link

rezmus commented Dec 20, 2019

"lumi_plug_setting_maxPower": "Maximum power limit",
"lumi_plug_setting_cutOff": "Power outage memory",
"lumi_plug_setting_cutOff_tps": "When the plug is on again, it restores the settings before the power outage.",
"lumi_plug_charging_protect": "Charging protection",
"lumi_plug_close_overload": "If the power is less than 2 W for half an hour, the plug will be turned off automatically",
"lumi_plug_setting_indecateLight": "Turn off indicator",
"lumi_plug_setting_indecateLight_tips": "Turn off the indicator from 21:00 to 09:00",

it's config for lumi.plug.* from hub firmware, but looks like mmeu01 only supports these

"method":"get_device_prop","params":["lumi.XXXX","channel_0","load_voltage","load_power","poweroff_memory","charge_protect","en_night_tip_light","max_power"]

load_voltage / load_power are not sent to zigbee socket however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants