-
Notifications
You must be signed in to change notification settings - Fork 4k
Feature: Wi-Fi Configuration via Zigbee for Shelly Gen4 Devices #10276
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
Conversation
|
Thanks! |
|
Just played around with the this patch. Looking forward to it, as it promisises the only way of performing firmware updates on the Gen4 shellys without physical access to the device (because there is no MQTT based OTA available). The initial connect to my WiFi via the Zigbee2Mqtt UI worked. Shelly got IP and Web-UI was reachable. @dan-danache ever seen something like this while developing & testing the code? |
|
I just retested this on a Mini 1 Gen4 running firmware 1.7.1, and I was able to enable and disable Wi-Fi multiple times without issues.
After clicking "Apply", try using the refresh icon next to the "Wi-Fi status" field in the UI. What status does it show?
Let me know what status you see, that’ll help narrow it down. |
|
I tested it with a Shelly 2PM Gen4. Updated the SW to 1.7.1 the one time it connected to wifi. I can see the API calls in the debug log of the browser after hitting "apply". Something like this (removed ssid/pw): It does not seem to be an issue with the UI. I also hit the "refresh" after wifi status, IP, ... after each apply (recognized at the one successful execution that it's needed for getting the current state). Wifi state says disconnected most times. I also gave static IP a try. In that case, it added the entries to the status, but the gateway address was missing the last number of the ip after fetching the current state by "referesh" button. Something like "192.168.6." was in the state. Maybe an issue with the 2PM firmware ??? PS: That's the state in MQTT where it's stuck: PS2: removing power from the shelly (reboot) does not help |
|
I retested using my other Gen4 device (1PM Mini) and everything worked as expected (enable/disable, DHCP/static) no issues at all. It's a bit frustrating that I can't reproduce your issue 😅 To help dig deeper, I’ve created an external converter with very verbose logging. If you’d like to try it out:
Thanks again for testing and putting in the effort; really appreciate you helping track this down! |
|
Not an expert for the external converters unfortunately, this is the error i get: I am running Zigbee2MQTT version [2.6.3] commit: 6f6bc4bb |
|
That seemed to be an issue with 2.6.3. version. Version 2.6.2 running in docker was able to load the Shelly.js I think i found the issue! It's related to the length of the password! Take aways
Question:
Here is my analysis (passwords and SSIDs obfuscated, but length remained as used): Test with only enabled: true, no ssid, no password-> Works Test with only enabled:true and ssid, no password-> Works too Test with enabled, SSID and password:-> failed Started shortening the password one letter by one letter-> failed again and again, it gets interesting at: -> Fails reliably with direkt error, no timeout any more One letter less (11 letters), and the password is taken fineIn-between disabling wifi works by the wayVerified that an 11 letter password works by changing the passwordVerified that Password with 12 letters reliably brings a communication error again:-> more than 11 letters reliably breaks the write! Out of curiosity, started also testing how the length of the network name behave-> ssid "PiiiZaaaPPPP" got shorted to "PiiiZaaaP" (9 letters) |
Thank you for the finding! I'll investigate! |
|
Try this updated version of the External Converter, which distributes attribute read/write operations across multiple Zigbee commands to help avoid frame size limitations.
Also, please test the static configuration to ensure everything works as expected. Thanks again for your effort and thorough testing! |
|
Did not see your second post, but modified the code myself by this write command: and this modified read command: This is the result: Works fine. Shelly connected to my network and gets an IP. Splitting the write commands resolves it. @dan-danache Thanks for the analysis. Will you provide an update for your code? I can offer a review if you like. |
|
The RPC cluster isn't working (for me) in the dev console, all commands time out. I could be doing something wrong of course, but looking at some other code it seems that they're sending the I've been trying to get this to work myself, but as often, I'm not too familiar with the ever-changing codebase and the internals of the Zigbee protocol, so there might be an easy fix but I haven't found it yet. |
|
Okay I've managed to get the RPC cluster to work based on your code, but it wasn't generating full/any responses to my commands. It would correctly fill @dan-danache have you had any luck using that cluster? I'm writing |
|
It is on my to do list to play with the RPC cluster, but currently things are a bit crazy at work. I'll get back to it when things cool a little bit down. Sorry I cannot help rn. |
|
No problem. Shelly just responded and told me I am doing the correct thing, so you don't need to check/try anymore.
So I'll go ahead on a write-only version of some controls for now. |


This PR introduces support for configuring Wi-Fi settings directly over Zigbee for all Shelly Gen4 devices. It leverages the
shellyWiFiSetupCluster, enabling remote network setup through Zigbee2MQTT.Supported Wi-Fi Parameters:
Full Zigbee cluster specification: https://shelly-api-docs.shelly.cloud/gen2/Integrations/Zigbee/WiFiSetupCluster/
This is a mix between #9468 and #9927.
I believe diagnostic data should be exposed as standalone state entries (exposes) to enable seamless integration with Home Assistant automations (for example, triggering actions when Wi-Fi is enabled or disabled on a Shelly device). In contrast, Wi-Fi setup parameters are currently exposed as a single composite entry.
View from Home Assistant:
How it works
Refresh Action (/get or UI "refresh" icon)
When the user triggers a refresh for any Wi-Fi attribute, the converter performs the following steps:
0to theAction (0x02)attribute, syncing all values with the current device configuration.Apply Action (/set wifi_config or UI "Apply" button)
When the user applies a new configuration, the converter executes:
1to theAction (0x02)attribute, committing the current Zigbee attribute values to the device.Note: The Wi-Fi password must be provided each time the "Apply" action is used, as it is not stored in the device state.
I tested this code on a Mini 1 Gen4 device with firmware 1.7.1, using both DHCP and static configurations, as an external converter in my production environment. For this pull request, I made minimal adjustments to ensure compatibility, primarily updating import paths and TypeScript types where necessary.
Have fun!