Introduction
I quickly put together this article to provide guidance on how I flashed my cheap AliExpress ZigBee Smart plug. These are also known as Tuya TS011F.
Consider this as a work in progress article.
The purpose is to fix a firmware flaw causing the plugs to turn off when reaching 251 volts. Even if this sounds like a good idea, it’s actually a problem since spikes up to 263 volts are allowed as per European quality standard (I’ve added an update below on 2024-05-02 about IEC 60947-2).
Requirements
This post deals with a bunch of requirements, adapt for your own setup (spoiler : it might work, or not) :
- Home Assistant as my home automation software, mine runs as a VMware ESXi VM
- Home Assistant built-in integration Zigbee Home Automation (ZHA)
- Home Assistant custom HACS
- This can be tricky, sorry I don’t give guidance in this article
- HACS Integration ZHA Toolkit – Service for advanced Zigbee Usage
- Some reading on HA forum : “zha-toolkit” – Toolkit providing low and high level Zigbee commands through ZHA/zigpy
- A Zigbee coordinator, I’ve used both Sonoff Zigbee Bridge (ZBBridge) (WiFi) & Sonoff ZBDongle-P (USB).
What’s your firmware?
Before flashing your plugs, you might want to know where to find the firmware version.
Navigate to Settings > Integrations and click the “xx devices” on the card.
This opens the list of all your (paired) Zigbee devices.
Filter on some keyword (mine are all named “Prise Xz”).
Note this view provides overview of Manufacturer and Model. If your plug doesn’t update, this might be related to an unknown manufacturer ID.
Firmware version is shown under Device info. If the “Firmware” line is missing, your plug hasn’t been updated..
After what, the TS011F plugs started reporting below Firmware versions:
- _TZ3000_zloso4jk : 0x0000004a
- _TZ3000_cphmq0q7 : 0x00000043
- _TZ3000_typdpbpg : 0x0000004d
Update 2023-02-03, here are updated firmware versions:
- _TZ3000_zloso4jk : 0x000000c0 -> All 5 updated fine but one had to be disconnected and re-plugged
- _TZ3000_cphmq0q7 : 0x00000043 -> None have been updated (out of 8)
- _TZ3000_typdpbpg : 0x000000c0 -> All 6 updated fine
Flashing a Zigbee plug
Update 2023-04-30 : TODO, write more about zha.issue_zigbee_cluster_command
See full post here at Home Assistant community.
https://community.home-assistant.io/t/zha-ota-firmware-update-upgrade/488960
Send OTA notify
If you reach down to this, you are pretty well done with this.
Go to your HA instance under Developer Tools > Services (HA doc page).
From this page, you will be able to run an OTA notification using ZHA, causing the device to update.
If find it easier in YAML mode, so you can copy/paste below code. Don’t forget to change “ieee” to match the device name you want to flash.
service: zha_toolkit.ota_notify data: ieee: sensor.prise_7z_boiler_electrical_measurement download: true path: /config/zb_ota
More about OTA process
The OTA process automatically checks up-to-date firmware from a JSON file compiled by contributors with URLs from vendors’ OTA (see https://github.com/Koenkk/zigbee-OTA/blob/master/index.json ).
However after update, the OTA is not triggered automatically, you must go through the process again to keep your devices up-to-date (if any firmware is available and added to the list).
Here is example for one of my devices as per Home Assistant ZHA diagnostic output, note the “manufacturer_code”.
... "data": { "ieee": "**REDACTED**", "nwk": 2706, "manufacturer": "_TZ3000_typdpbpg", "model": "TS011F", "name": "_TZ3000_typdpbpg TS011F", "quirk_applied": true, "quirk_class": "zhaquirks.tuya.ts011f_plug.Plug", "manufacturer_code": 4417, ...
The correct firmware is detected from manufacturerCode (dec 4417 = 0x1141).
{ "fileVersion": 192, "fileSize": 307682, "manufacturerCode": 4417, "imageType": 54179, "sha512": "01939ca4fc790432d2c233e19b2440c1e0248d2ce85c9299e0b88928cb2341de675350ac7b78187a25f06a2768f93db0a17c4ba950b60c82c072e0c0833cfcfb", "url": "https://images.tuyaeu.com/smart/firmware/upgrade/20220907/1662545193-oem_zg_tl8258_plug_OTA_3.0.0.bin" }
As seen in the actual firmware binary file.
For full header specs, see https://github.com/Koenkk/zigbee-OTA/blob/da29b97e10d4ec674fb6a5a6c6df311497a1a2d9/lib/ota.js#L15
Re-pair device
After update, I highly recommend you to remove and re-pair the device.
This helps having inconsistent entities. A simple “Reconfigure” doesn’t seem to be good enough.
Tip : When playing around with many devices, I always go to Developer Tools > States and search for “_2”, to prevent suffixes being added to my entities.
Is it fixed?
First, be aware some plugs seem to have a hardware / firmware issue related to power monitoring. You can clearly see on below graphs that some plugs on the left graph are reporting around 10V higher than plugs on the right.
See this comment at Tuya TS011F (TZ3000_typdpbpg) powers off #13343.
Second, I want plugs not turning off themselves (even with flashed firmware!).
I haven’t dug into this yet, however since I mostly want to use these plugs in 2 cases:
- Control lights : So spikes during sunny day don’t matter;
- Monitor power consumptions of major appliances : I mainly care on having plugs always on and correctly reporting power.
My choice is pretty clear: Filter on “always on”-able plugs, use the reliable power monitoring ones.
I’m left with a subset of 7 plugs out of 13.
Update 2022-12-05
Since I’ve received a third batch of the ZigBee Smart plug. It is clear they are not made equal, making them somehow unreliable, I’d have to use another sensor to compare results.
Update 2024-05-02
I setup a couple months ago P1-Monitor to interface Home Assistant with my new house power meter.
I’ve used this to confirm voltage from grid. Here is stats in Belgium over partly cloudy/sunny days.
Grid voltage can reach up-to 261.3V over this period (last 2 days). This causes inverter to cut production and of course plugs to turn off.
At this Belgian forum, we can read:
This is about norm IEC 60947-2. I wasn’t able to find a PDF version, the document must de purchased.
While the usual grid voltage is within 230V-240V, it is allowed to work as low as 85% or at most 110%.
Base voltage | Lower bound | Upper bound |
230 | 195.5 (from article)
191.7 (from below table) |
253 |
240 | 204 | 264 |
There is a missing detail about why plugs shouldn’t turn off : duration of the spikes.
Here are specs for inverters as provided by Synergrid in document C10/11 ed 2.2, page 61 :
Let’s see the maths:
- Maximum average voltage over 10 min : 230V + 10% = 253,0 V
- Maximum instantaneous voltage : 230V + 15% = 264,5 V
Therefor, most firmware’s I’ve had a look at are missing that difference, which makes them highly unreliable.
Conclusion
Long story short : No, flashing your plugs might not fix your issue.
This is not an easy action, even if trivial, because it requires a lof of prerequisites that not everyone might be confortable with.
However once you unleash the power HACS, it is well worth the extra effort since that will be useful for a lot of other scenarios.
Other references, reading list
https://community.home-assistant.io/t/zha-ota-firmware-update-upgrade/488960
14 thoughts on “Home Assistant – Zigbee device updates and plugs shutting down”
Freek
(2022-12-15 - 19:01)Thanks, this was very helpful. I always wondered how OTA updates worked for Zigbee devices.
It’s interesting that your plugs show up as TS011F. According to the Blakadder ZHA wiki, TS011F does not support power measurement. My Lidl/SilverCrest Smart Plugs also identify as TS011F but they do not report any power usage.
Shut
(2022-12-15 - 20:57)Hi, thanks for heads up!
The TS011F seems to be a rather generic “no brand” item. I’ve noticed in forums that a lot have power measurements issues, an unreliable hardware might be the reason why it is not available for some “brands”.
This post on Jeedom forum (french, sorry) however states a plug behaves differently when used with Deconz or “Zigbee from Market”.
https://community.jeedom.com/t/souci-fonctionnement-etat-puissance-et-consommation-avec-prise-tuya-ts011f-marque-vikefon/72049/9
Theo
(2023-02-03 - 13:19)Hello Shut.
Thanks a lot for the above post.
I also despair of the tuya devices. I have the TS011F by _TZ3000_typdpbpg.
I bought them first a half year ago. And with the “zha.issue_zigbee_cluster_command” Update with the version 1654157434-oem_zg_tl8258_plug_OTA_1.0.13.bin it worked fine for me and all the 16 plugs i have bought went from nothing to 0x0000004a and then to 0x0000004d. And they are working more or less fine nowadays.
But a month ago, i bought further four TS011F by _TZ3000_typdpbpg plugs.
And they messed up. Not with the OTA_1.0.13.bin nor the OTA_3.0.0.bin they do not went from 0x0000004a to 0x0000004d.
And in the current state 0x0000004a they didnt work and plug odd randomly.
I tried your method above (zha_toolkit.ota_notify), but that didnt work.
So my question is: what have you done, to get them in state 0x0000004d?!?
Thx a lot, Theo
Shut
(2023-02-03 - 13:26)Hi Theo,
Thanks for your kind words!
The firmware version depends on the mapping provided at https://github.com/Koenkk/zigbee-OTA/blob/master/index.json
Since your plug has the same manufacturer as mine, they should behave in the same way.
Have you tried removing / pairing again the plugs?
Update 1 : I’m experiencing a similar issue for one of my TS011F by _TZ3000_zloso4jk.
My plugs (as in the post at time of writing) had firmware 0x0000004a, they all updated to 0x000000c0 but one. I’ll have to get a closer look.
Update 2 : The plug updated fine, I had to disconnect it from wall and put it back. It kind of rebooted it and started accepting the OTA again.
Regards,
Rudy
Theo
(2023-02-12 - 00:10)Hello Rudy.
Thanks for your reply. Yes, they are the same as yours with the same firmware (TZ3000_typdpbpg).
Several times, I reboot them, plug them from the wall, reconfigure them but nothing happend. It does not change from 0x0000004a to 0x0000004d or when I remove them from nothing to 0x0000004a but not to 0x0000004d. And so, they plug off randomly and are not usable for things like refridgerators etc.
Its kind of annoying because the plugs from last year (same product) are in state 0x0000004d.
So, with the new ones I have e-waste @home.
Regards, Theo
Shut
(2023-02-12 - 11:47)I’m afraid you’re right, the plugs do not seem to be made equal 🙁
Theo
(2023-03-19 - 23:32)Hey Rudy. Short update.
I bought a second conbee 2 and set up a zigbee 2 mqtt environment. And voila. The three “broken” plugs are working very fine. The gui looks fresher than ZHA and it shows me directly updates for the plugs.
Regards, Theo
Shut
(2023-03-20 - 08:42)Hi Theo,
Thanks for the update! That actually sounds scary as the coordinator shouldn’t affect that.
I might git it a try!
Regards
Christoph
(2023-04-28 - 14:03)Hi, thanks for your post about updating the TS011F firmware version 🙂
I’m running several of these TS011F plugs… they are from _TZ3000_rdfh8cfs … (FDTec) …
They have the same Device Vendor, etc…. so I finally managed to get the current installed firmware shown – which is: 0x0000004d (77).
A new firmware file was downloaded and is stored under /config/zigbee_ota/ the new version is (Update auf 192, 0x000000c0)
But: How do I trigger the update?
I’ve tried to run the ota_notify service several times, but nothing happened… Do I need to unplug the switches?
That’s unfortune, because many of them are only being used to measure the energy usage of specific devices… not to turn them on / off
Or can I somehow check, if the device is waiting for a firmware?
Thanks and regards,
Christoph
Shut
(2023-04-29 - 14:46)Hi Christoph, thanks for your comment, glad this post might help people around 🙂
I’m not sure why the firmware would download but not flash to your plug.
I however experienced a plug not flashing and had to unplug it.
That’s probably not a great news but I recommend having one on hand at your desk or something while you do your testing.
Regards,
Rudy
Christoph
(2023-04-29 - 17:01)Hi,
I figured out how to force the plugs to upgrade the Firmware.
First, it needs the following change in the configuration.yaml:
zha:
zigpy_config:
ota:
otau_directory: /config/zigpy_ota
optional, to force logging, add the following to the configuration.yaml
logger:
default: info
logs:
homeassistant.components.zha: debug
zigpy: debug
If the plug does not update automatically after restarting HA, you need to run the following service:
service: zha.issue_zigbee_cluster_command
data:
ieee:
endpoint_id: 1
cluster_type: out
command_type: client
cluster_id: 25
command: 0
args:
– 0
– 100
where is the ieee of the plug (can be copied from the “zigbee info” within the device info page.
After that, you can check the logs of HomeAssistant and see the progress of the firmware upgrade…
After a sucessfull update, the plug should switch off – and on again.
In my case, I had to run the ZHA-Toolkit: ota_notify command again to update the version information on the Device Page… but now, all _TZ3000_rdfh8cfs devices are running with the latest firmware.
Shut
(2023-04-30 - 14:36)Hi,
Thanks for the update! I indeed saw in the past comments about the zha.issue_zigbee_cluster_command but seems it wasn’t required for my situation. I’ll give it a new try to make sure all plugs are up-to-date.
Thanks!
Qapla
(2023-09-22 - 15:09)I have few plugs that are starting to go offline more and more…
TS011F by _TZ3000_okaz9tjs
Can’t upgrade firmware. Tried really everything I can think of..
Home assistant with ZHA
FYI, OTA cluster is not visible/available on this device
– trie setting up zha zipgy config in home assistant config in order to upgrade firmware
– downloading firmware from https://images.tuyaeu.com/smart/firmware/upgrade/20220907/1662545193-oem_zg_tl8258_plug_OTA_3.0.0.bin
– sending ota_notify command
– sending zha.issue_zigbee_cluster_command
– loading different quirk
And last i tried was using some other zigbee coordinator that is connected to Tuya Smart Home app
– removing the zigbee plug from home assistant
– adding the zigbee device to this other coordinator
– Tuya says that firmware version is v1.2.4 and that there are no updates available
– tried restarting of course, same thing
So as someone said, it seems that this is old version which have hardware issue.. so, bad luck I guess.
Shut
(2023-09-22 - 15:25)Hi,
I still have plugs turning off. I updated my post https://stuffblog.dullier.eu/2023/03/06/home-assistant-keep-a-plug-always-on-restore-failed-plugs/ today.
At the end of the day, I think I’ll physically hack the plugs and remove the relays altogether.