zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Aqara wall switch H1 (WS-EUK04) - not syncing state, not showing power measurement anymore

Open adynis opened this issue 2 years ago β€’ 40 comments

What happened?

My kids played with one wall switches - it was showing "red" leds ... 😑 it was removed from Z2M. (probably they pressed more than 6 seconds) Device: WS-EUK04 (lumi.switch.n2aeu1) I added it back to Z2M (1000 times) and I can not make it work properly:

  1. When I press the physical switch button, I don't get the updated state value in Z2M, it appears only if I manually press "refresh" icon to get the value, but not automatically.
  2. for some info fields, e.g.: power, energy, device_temperature I have N/A . If I press the "refresh icon" I get the error:
Zigbee2MQTT:debug 2024-03-05 02:08:30: Publishing get 'get' 'power' to 'copii_aqara'
Zigbee2MQTT:error 2024-03-05 02:08:30: Publish 'get' 'power' to 'copii_aqara' failed: 'TypeError: Cannot read properties of undefined (reading 'read')'
Zigbee2MQTT:debug 2024-03-05 02:08:30: TypeError: Cannot read properties of undefined (reading 'read')

Workaround for issue 1. : I found somewhere on internet this screenshot with the suggestion to add "Reporting" : WhatsApp Image 2024-01-28 at 05 53 20_57bb6ed0 I don't know if this is something ok to do, it looks like it has some slower reaction times then before, I'm not sure if this way I make any process to consume "energy" just to check from second to second the status of the switch ... somehow I feel that it's not ok to have this workaround ...

Some remarks:

  • I have ~10 such switches in my house, the other ones work fine
  • I was having this issue also in the past (previous Z2M versions) , but usualy after "dancing with tambourines" in a coupple of trials of removing from network and re-joining (eventually joining to an aqara hub then back to Z2M) , I was able to make it work. This time I couldn't after ~1h of trials of remove/re-join, restart HA ... etc
  • I recently changed to 1.36 and ember

Final thought: I'm not sure if it is from aqara device itself (since I was having this kind of issues also in the past), or from Z2M , or from new ember, or from something else ... but it would be helpful to have a solution when it happens. Also ... like I already wrote, the workaround I used doesn't "smell nice" to me now (unless someone confirms to me that it's ok :) )

Zigbee2MQTT version

1.36.0, ember

Adapter firmware version

7.4.1 [GA]

Adapter

Home Assistant Yellow - EZSP v13

Setup

HomeAssistant on HomeAssistantYellow

adynis avatar Mar 05 '24 00:03 adynis

Hello @adynis, I have a similar issue.

Is it possible to remember what versions your setup had when you paired them?

At which month/date maybe? - That could tell us which versions you might had..

mojiro avatar Mar 05 '24 00:03 mojiro

oh ... @mojiro , sorry .. I missed your message. I observed it now by accident. I will answer to you immediately after my intended message. So .... today .. very strange experiences:

1.) Something ... less important but I can't avoid mentioning it ... Something very strange which I CAN NOT REPLICATE anymore :( My kid pressed 6 times quickly on the switch and ... "magic" ... for ~3 minutes the relay started to go ON/OFF/ON/OFF/ON/OFF at around 2 changes per second ... Unfortunately I didn't have the idea to start loging it :( My wife made a short video with the switch ... When I got home I also tried, it did the same (after 6 clicks it started to on/off/on/off....) and I just checked that when I restarted the Z2M addon from my HA instance, the on/off/on/off stopped. After that I just forced a re-join of the switch and .... from that moment I couldn't replicate the issue anymore ....

2.) This I consider it IMPORTANT: After the problem from point 1 , the state of the switch was not synced anymore 😠 😒 ... also power was NULL.... I tried agan to rejoin , restart HA, remove, force remove, add to aqara hub, remove, re-add, re-join, etc etc .... nothing. Then ... I changed back to ezsp !!! Then I tried to rejoin the device for ~10 minutes (it took me so long because of z2m crashing #21118 , but finally I succeded it) and ... surprize: state is syncing, power measurement is working !!! And I moved back from ezsp to ember, and the switch is still working fine . So ... my conclusion : there's a problem with ember & aqara switch for state syncing & power measurements !

adynis avatar Mar 07 '24 23:03 adynis

@Nerivec Could that be the same reason like on the ikea motion sensor which we found today? Maybe aqara do such a same dumb thing on this device?

wastez avatar Mar 07 '24 23:03 wastez

Hello @adynis, I have a similar issue.

Is it possible to remember what versions your setup had when you paired them?

At which month/date maybe? - That could tell us which versions you might had..

Sorry for not answering, I missed the mail when you initially wrote. I do not remember Z2M version, but ... : majority of switches ware installed in ~October.2023 Just that some of them (especially the one from my office-room) I tested a lot and it was removed/re-added multiple times.

In the same time, like in the poiint 2.) written above, with some effort I was usually succeeding to join it with power & state-sync working. I couldn't yet understand which was the trick to make it work ... I was trying various things until it was working ... . Things I was trying , independently or combined :

  • keep 6 seconds pressed on the switch with PermitJoin = OFF
  • keep 6 seconds pressedo n the switch with PermitJoin = ON
  • Remove it from the z2m button then re-join
  • Remove it with force switch , then re-join
  • remove it, restart z2m (or HA) then re-join
  • add it to an aqara hub, then back to z2m
  • this is the most "strange" assumption I was hoping for and testing (I had the feeling it worked once but probably it was jsut a conincidence) : Adding The "Reporting" options like in the picture from the ticket description, then remove it somehow (check previous points) then re-join the device (hoping to somhow maintain the reporting :-D )

The problem was that all these tests were DIFFICULT because of the Z2M restart issue ( https://github.com/Koenkk/zigbee2mqtt/issues/21118 ) . But somehow in ... ~5-30 minutes of testing I was usually able to make it work ... despite the z2m restarts in the middle of "device configuration" or despite all the "non-understandings" which I have with regards to all previous points while testing

adynis avatar Mar 07 '24 23:03 adynis

@adynis Can you post logs with herdsman debug logging on? https://www.zigbee2mqtt.io/guide/usage/debug.html

wastez avatar Mar 07 '24 23:03 wastez

Yes, but what do you think it would worth "adding" in the log:

  • ember vs ezsp
  • normal functionality vs not working functionality
  • the joining moment ?

adynis avatar Mar 07 '24 23:03 adynis

@adynis wastez may be right. Hopefully, the pending ember PR should also take care of this issue. All newly reported issues (since ember release) are being fixed in dev branch at the moment, to allow some testing before release (every 1st of the month). If you can, try with dev/edge version after that PR is merged and available, and let me know if you still encounter the issue.

As for the magic on/off, it will be hard to say without debug logs. It almost sounds like the device got into a "special state" by triggering it in a very specific way (kind of like some devices that need to be plugged/unplugged 5 times at regular interval to reset them...).

Nerivec avatar Mar 07 '24 23:03 Nerivec

@Nerivec : I would be glad to test ! Jsut that .. being in home assistant (on a "productive environment" ) I ask first: can I just change to Z2M-edge addon in HA and all devices will still be there ?

adynis avatar Mar 07 '24 23:03 adynis

@adynis I wanted to have a look if the problem is the same thing like on ikea motion sensor because it’s very probably. But I didn’t know that @Nerivec is sooooooo fast. So the best thing is you try the edge release as soon the PR is pushed to it. Iβ€˜m pretty sure it will solve it.

wastez avatar Mar 07 '24 23:03 wastez

@adynis Yes everything is there, the same db is used. You can swap between them without problems.

wastez avatar Mar 07 '24 23:03 wastez

In the meantime here's one log:

log ember 5:
 - 01:51 EET - hobby_aqara (was working fine) -> pressed 6 seconds on the physical switch to force it re-join
	-> PermitJoin was previously enabled; Device was succesfuylly added back with the same name
	-> state not syncing anymore
	-> power measurements not working anymore (but still shows 0 in browser, not NULL, maybe because of a browser caching ? )
 - 01:54 EET - Press "remove device button in Z2M (Permit Join still on)
	-> Device removed and added back succesfully (added with the default name 0x54ef441000720a04 )
	-> onOff not synced, Power , Energy, DeviceTemperature show NULL now. 
	-> If I press the "refresh" icon in Z2M for onoff state then it works. If I press for Power/Energy/DeviceTemperature then it gives error.

log_ember_5.txt

PS.

  • Firmware is, I think, this: https://github.com/darkxst/silabs-firmware-builder/blob/ember-nohw/firmware_builds/yellow/ncp-uart-hw-v7.4.1.0-yellow-115200.gbl (the uncertainty is because I'm not sure if the flashing was successfully or not, the log didn't mentioned an error but also no "success" keyword )
  • in config I still have: rtscts: true

adynis avatar Mar 08 '24 00:03 adynis

Flash https://github.com/darkxst/silabs-firmware-builder/blob/ember-nohw/firmware_builds/yellow/ncp-uart-hw-v7.4.1.0-yellow-115200.gbl again, just to be sure, then definitely set rtscts: false in config. I'm seeing strange behavior in your logs, that's likely the cause. Then try getting logs again please.

Nerivec avatar Mar 08 '24 00:03 Nerivec

EZSP logs, 2 files combined, since it was a Z2M restart in the middle:

log_ezsp_1_and_2:
 - 2:14 EET - removed device from Z2M interface
  - various things: Z2M crashed once, I pressed again on the physical switch for 6 seconds , then it didn't finish the interview, then I pressed again 6 seconds, then it worked ... 
 - ~2:19 EET - succcesfully added, and things are sincing correctly

log_ezsp_1_and_2.txt

adynis avatar Mar 08 '24 00:03 adynis

Oh, I've seen you message now, @Nerivec . Oky , I reflash, set rtscts to false and re do the log πŸ‘

adynis avatar Mar 08 '24 00:03 adynis

Firmware log:

universal-silabs-flasher --device /dev/ttyAMA1 flash --allow-cross-flashing --firmware ncp-uart-hw-v7.4.1.0-yellow-115200.gbl --force 2>&1 | tee log_fw_no_hw3.log
2024-03-08 02:29:28.324 a0d7b954-ssh universal_silabs_flasher.flash INFO Extracted GBL metadata: NabuCasaMetadata(metadata_version=1, sdk_version='4.4.1', ezsp_version='7.4.1.0', ot_rcp_version=None, cpc_version=None, fw_type=<FirmwareImageType.NCP_UART_HW: 'ncp-uart-hw'>, baudrate=115200)
2024-03-08 02:29:28.325 a0d7b954-ssh universal_silabs_flasher.flasher INFO Probing ApplicationType.GECKO_BOOTLOADER at 115200 baud
2024-03-08 02:29:30.329 a0d7b954-ssh universal_silabs_flasher.flasher INFO Probing ApplicationType.EZSP at 115200 baud
2024-03-08 02:29:31.570 a0d7b954-ssh universal_silabs_flasher.flasher INFO Detected ApplicationType.EZSP, version '7.4.1.0 build 0' (7.4.1.0.0) at 115200 baudrate (bootloader baudrate None)
2024-03-08 02:29:37.789 a0d7b954-ssh universal_silabs_flasher.flasher INFO Probing ApplicationType.GECKO_BOOTLOADER at 115200 baud
2024-03-08 02:29:38.806 a0d7b954-ssh universal_silabs_flasher.flasher INFO Detected bootloader version '2.0.1'
2024-03-08 02:29:38.807 a0d7b954-ssh universal_silabs_flasher.flasher INFO Detected ApplicationType.GECKO_BOOTLOADER, version '2.0.1' at 115200 baudrate (bootloader baudrate 115200)
ncp-uart-hw-v7.4.1.0-yellow-115200.gbl

Does this mean that ... it worked ... or not ... ❓

adynis avatar Mar 08 '24 00:03 adynis

a new log:

  • firmware: https://github.com/darkxst/silabs-firmware-builder/blob/ember-nohw/firmware_builds/yellow/ncp-uart-hw-v7.4.1.0-yellow-115200.gbl , with flashing log in the previous comment
  • Z2M version 1.36.0 (I will move also to edge, if it helps I can re-do the log on edge)
  • ember
  • rtscts: false

log_ember_6:

 - 2:38 EET 
	- Permit Join
	- 0x54ef441000720a04 device (which was working ok, state synced, power measurements working), press 6 seconds on phisical button
	- device removed and successfully re-added
	- onOff not synced , power measurements not working
 - 2:40 EET
	- press also "remove device" from Z2M interface
	- device successfully removed and re-added
	- onOff not synced , power measurements not working

log_ember_6.txt

Let me know what other logs are helpful to make (ezsp? something else?)

adynis avatar Mar 08 '24 00:03 adynis

This device is terrible, awful. I'd take a hammer to it if it was mine... 😞 It's spamming the network with duplicate messages for no reason whatsoever; it's like it's trying really hard to crash the network or something...

With ezsp, I'd bet the setManufacturerCode workaround is the reason behind the crashes; it's triggering this dozens of times. I'm sure the coordinator doesn't like that... @kirovilya Seems there is a need to throttle the triggering of setManufacturerCode somehow when a xiaomi/lumi device joins the network? I'm guessing that's the cause of the crashes...

ember manages to survive, but I'm not surprised things aren't working well after that. I'll have to dig deeper...

Nerivec avatar Mar 08 '24 03:03 Nerivec

Thanks @Nerivec for looking into it ! If you need any kind of test/log and you estimate I can do it, please let me know, I'm willing to help :)

adynis avatar Mar 08 '24 03:03 adynis

@Nerivec Sorry, I don't understand what's wrong? in the ezsp adapter setManufacturerCode is set separately to 0x115F for Lumi/Xiaomi/Aqara devices when they connect to the network

kirovilya avatar Mar 08 '24 05:03 kirovilya

@kirovilya Check the logs here. You will see the setManufacturerCode is triggered in rapid succession from the join handler. For 3 joins, I count 25 setManufacturerCode triggered...

Nerivec avatar Mar 08 '24 15:03 Nerivec