-
Notifications
You must be signed in to change notification settings - Fork 403
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
Sonoff SPM - 2nd module not reporting power #1366
Comments
So, I have a theory that the SPM main unit only responds to one request in a span of time. I can sometimes get the f8 module to respond if I restart the integration with new config, or use the ewelink app, or something else that offsets the requests. I see the integration sends cloud "UI active" messages to f7 and f8 at the same time. Is there a way I can make it wait a half second between requests? I'm going to try disable f7, and see if f8 then reliably sends data. |
Okay so even if I disable all the entities related to f7, and the device, and restart HA, the sonoff integration still asks the cloud to ping f7. So I'm not sure what else I can try. |
I don't know why this is happening. I don't have these devices. |
Thanks @AlexxIT for the response. I know it's not easy to debug something you can't actually use! Is there a way I can disable the integration from polling the one sub-device? Then I can try and see if the behavior changes if there's only f7/f8. I think that I would be willing to give you remote access too, if you are willing to go to that effort. |
Do it in the code SonoffLAN/custom_components/sonoff/core/ewelink/__init__.py Lines 320 to 354 in a54bcb8
|
Ah! Thank you for pointing me there. I will have a go and see if I can get any useful results. I see there is a section for SPM for local queries, but I read in the docs that some devices don't support local update. Am I correct in saying that the SPM devices don't support local only mode? |
Old devices support only cloud updates. Some new devices support local updates. You can see all of them in the code above |
Okay @AlexxIT I think I have something. Looking at the debug logs I attached above, the main SPM unit says local connection is possible. E.g.
But for the sub devices these values are null. Debug also attached in the original post. So even though the SPM unit supports LAN communication, it's never used because the sub devices are considered cloud only. I tested this by adding some logging in above line 361 to print out whether cloud was true or not. SonoffLAN/custom_components/sonoff/core/ewelink/__init__.py Lines 360 to 364 in a54bcb8
It always prints out True. So I'm now going to force local communication and see what happens... |
Okay, so forcing the code to use LAN doesn't work because So I forced the host to be the same as the parent device, and it now gives me:
So clearly I'm not doing this right. Any ideas? Does the SPM need to be in DIY mode first? |
Looks like you right. There is code for detecting local mode in another function: SonoffLAN/custom_components/sonoff/core/ewelink/__init__.py Lines 106 to 113 in a54bcb8
Unfortunately I don't have this devices for local test. |
Reopen issue if this fix not helps |
Hello @AlexxIT Thanks! I appreciate you working blindly with this. We have progress, it's trying to communicate locally, but we're not there yet: 2024-04-17 20:40:43 [D] ab300006f7 => Cloud4 | {'uiActive': {'outlet': 0, 'time': 60}} | DDoS | 1713379243280
2024-04-17 20:40:45 [D] ab300006f7 <= Local3 | 192.168.8.14:8081 | {'current_00': 10, 'voltage_00': 23368, 'actPow_00': 0, 'reactPow_00': 2265, 'apparentPow_00': 2273} | 101490
2024-04-17 20:40:45 [D] ab300006f7 <= Cloud3 | {'current_00': 10, 'voltage_00': 23368, 'actPow_00': 0, 'reactPow_00': 2265, 'apparentPow_00': 2273} | None
2024-04-17 20:40:48 [E] ab300006f8 => Local4 | | {'uiActive': {'outlet': 1, 'time': 60}}| File "/config/custom_components/sonoff/core/ewelink/local.py", line 192, in send| host = device["host"]| ~~~~~~^^^^^^^^|KeyError: 'host'|
2024-04-17 20:40:48 [D] ab300006f8 => Cloud4 | {'uiActive': {'outlet': 1, 'time': 60}} | 1713379248182
2024-04-17 20:40:48 [E] ab300006f7 => Local4 | | {'uiActive': {'outlet': 1, 'time': 60}}| File "/config/custom_components/sonoff/core/ewelink/local.py", line 192, in send| host = device["host"]| ~~~~~~^^^^^^^^|KeyError: 'host'|
2024-04-17 20:40:48 [D] ab300006f7 => Cloud4 | {'uiActive': {'outlet': 1, 'time': 60}} | DDoS | 1713379248283
2024-04-17 20:40:49 [D] ab300006f7 <= Local3 | 192.168.8.14:8081 | {'current_01': 0, 'voltage_01': 0, 'actPow_01': 0, 'reactPow_01': 0, 'apparentPow_01': 0} | 101491
2024-04-17 20:40:49 [D] ab300006f7 <= Cloud3 | {'current_01': 0, 'voltage_01': 0, 'actPow_01': 0, 'reactPow_01': 0, 'apparentPow_01': 0} | None
2024-04-17 20:40:53 [E] ab300006f8 => Local4 | | {'uiActive': {'outlet': 2, 'time': 60}}| File "/config/custom_components/sonoff/core/ewelink/local.py", line 192, in send| host = device["host"]| ~~~~~~^^^^^^^^|KeyError: 'host'|
2024-04-17 20:40:53 [D] ab300006f8 => Cloud4 | {'uiActive': {'outlet': 2, 'time': 60}} | 1713379253184
2024-04-17 20:40:53 [E] ab300006f7 => Local4 | | {'uiActive': {'outlet': 2, 'time': 60}}| File "/config/custom_components/sonoff/core/ewelink/local.py", line 192, in send| host = device["host"]| ~~~~~~^^^^^^^^|KeyError: 'host'|
2024-04-17 20:40:53 [D] ab300006f7 => Cloud4 | {'uiActive': {'outlet': 2, 'time': 60}} | DDoS | 1713379253285
2024-04-17 20:40:55 [D] ab300006f7 <= Local3 | 192.168.8.14:8081 | {'current_02': 0, 'voltage_02': 23386, 'actPow_02': 0, 'reactPow_02': 0, 'apparentPow_02': 0} | 101492
2024-04-17 20:40:55 [D] ab300006f7 <= Cloud3 | {'current_02': 0, 'voltage_02': 23386, 'actPow_02': 0, 'reactPow_02': 0, 'apparentPow_02': 0} | None
2024-04-17 20:40:58 [E] ab300006f8 => Local4 | | {'uiActive': {'outlet': 3, 'time': 60}}| File "/config/custom_components/sonoff/core/ewelink/local.py", line 192, in send| host = device["host"]| ~~~~~~^^^^^^^^|KeyError: 'host'|
2024-04-17 20:40:58 [D] ab300006f8 => Cloud4 | {'uiActive': {'outlet': 3, 'time': 60}} | 1713379258187
2024-04-17 20:40:58 [E] ab300006f7 => Local4 | | {'uiActive': {'outlet': 3, 'time': 60}}| File "/config/custom_components/sonoff/core/ewelink/local.py", line 192, in send| host = device["host"]| ~~~~~~^^^^^^^^|KeyError: 'host'| So it looks like the parents host key isn't being copied to the child device. The diagnostics, same as before, show null in those fields. If you point me where to update that, I can have a go! Thanks again for the efforts! |
Hello @AlexxIT Thanks! I have pulled and tested. Unfortunately we aren't there yet. Though I might be able to help out a little more now. This is the new output:
From reading the DIY docs here: https://sonoff.tech/sonoff-diy-developer-documentation-spm-main-http-api/ I'll try dig into the code a little. I'm also not sure if the DIY mode docs have anything to do with the ewelink mode API. To be clear, I have NOT enabled DIY mode yet, but if I should try that, let me know. |
I can just turn off local updates for this device. That would be the easiest way |
That would take us back to my original issue though, where we only query Cloud and I don't get good stats. The cloud queries aren't reliable, and I don't get replies often from the one 4channel module. Let me look some more. |
Okay, I've got a plan. I'm going to try block the SPM from connecting to the internet. Then use ewelink to try query the SPM, and see what works and what doesn't. That should atleast tell us if local mode is possible. |
Okay, well that answers one questions. If I stop the SPM from contacting the internet, then I can still control switches and so on from ewelink on local lan, but I cannot retrieve stats for power monitoring. So, it would seem that unless it's in DIY mode, there is not local mode for power monitoring. To support DIY mode, it seems one would need to run a server to receive the stats. Which I'm guessing is not simple/possible with this add-on right? |
Hello @AlexxIT Thanks for the update. Though it took me back to the same issue, that is, the one module updates, but the other one does not. However! I have made some changes to the code, and managed to get some positive initial results. I'll report back tomorrow if they stay consistent:
So it seems that if the different modules data is requested at the same time, then only the first one returns data! The code I changed, obviously not useful beyond testing in my context: async def update_spm_pow(self, device: XDevice):
if device["deviceid"] == "ab300006f7":
await asyncio.sleep(3)
for i in range(4):
if i > 0:
await asyncio.sleep(5)
params = {"uiActive": {"outlet": i, "time": 60}}
await self.cloud.send(device, params, timeout=0) What does the |
Duration while reports are active |
Hello @AlexxIT
First off, thanks for the work on this integration!
I see quite a few past issues about power reports and so on, and I hope I've covered my bases here!
I'm using auto mode, and can view everything OK in ewelink.
I have disabled energy, voltage and current entities to cleanup the output, power reporting is the main thing I'm after, and the problem I face.
I have 2 GD32-SM4 modules. The system is on firmware 1.3.0 but the same issues were present on the previous firmware too.
Okay, so the issue is that I only get data from ab300006f7 (f7 from here on). I get very scant replies from ab300006f8 (f8 from here on).
Here, see the below output from "known logs", the integration requests to the cloud, but only f7 responds.
Please let me know if I can provide any further info. Please also find debug logs from the main unit, and both modules.
sonoff-8d397396bb2885eafc38053d11c44564-Device0006f8-c9586ddd90c6107a6263222ba2394104.json
sonoff-8d397396bb2885eafc38053d11c44564-Device0006f7-6d764384adb02074260df635efe21dde.json
sonoff-8d397396bb2885eafc38053d11c44564-SPM-Main House-aba1dcf6164b309786758ad5550f1698-1.json
The text was updated successfully, but these errors were encountered: