AlexxIT / SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
https://github.com/AlexxIT/Blog
MIT License
2.66k stars 414 forks source link

POWR320D turned off due to ewelink cloud error #1157

Open UmairEEE opened 1 year ago

UmairEEE commented 1 year ago

Hi, I have faced an issue with Sonoff LAN in HA. I got cloud warning from ewelink and my device that is a water pump turned off. [12:49 AM] Logger: custom_components.sonoff.core.ewelink.cloud Source: custom_components/sonoff/core/ewelink/cloud.py:346 Integration: Sonoff (documentation, issues) First occurred: 1 April 2023 at 23:53:08 (2 occurrences) Last logged: 1 April 2023 at 23:53:10

UmairEEE commented 1 year ago

It happened again and my water pump turned off again.

This error originated from a custom integration.

Logger: custom_components.sonoff.core.ewelink.cloud Source: custom_components/sonoff/core/ewelink/cloud.py:346 Integration: Sonoff (documentation, issues) First occurred: 9 April 2023 at 13:01:52 (21 occurrences) Last logged: 20:04:33

Cloud ERROR: {'error': 504, 'reason': 'Request Timeout', 'deviceid': '-------------', 'apikey': '----------', 'sequence': '------------'}

AlexxIT commented 1 year ago

I don't think that device turn off because integration. Log is useless until we can know what request has caused this error. You need to collect debug logs. Usually cloud response with error on energy request.

UmairEEE commented 1 year ago

I don't think that device turn off because integration. Log is useless until we can know what request has caused this error. You need to collect debug logs. Usually cloud response with error on energy request.

Thanks for the reply. Sorry i am new to Home Assistant. Can you please tell me how i can get debug logs?

Edit: I have been using Powr320d for more than 3 months. It never happened to me before but now it is happening very frequently. I usually notice it when i turn on my Water Pump and it unexpectedly turns off by itself. I am also using THR316d but its not happening to my THR316d.

UmairEEE commented 1 year ago

Getting this error frequently as well.

2023-04-20 22:00:47.470 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.sonoff_*****_energy_month (<class 'custom_components.sonoff.sensor.XSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total', 'total_increasing'; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

ov3rload1ng commented 1 year ago

Hi, I'm facing the same issue using the POWR316D and POWR320D devices. It seems that when there is a "Cloud error" (error 504) in the logs, the device reboots and returns to the configured initial state. On other hand, if the device is configured to start in the off state, the devices turn off in case of error and this strange reboot.

These are the logs about the cloud error:

2023-04-21 14:07:54 [D] 10013c5a66 <= Cloud3 | {'power': '164.24', 'voltage': '233.61', 'current': '1.10'} | None
2023-04-21 14:07:54 [D] 10013c5a66 <= Local3 | 192.168.70.90:8081 | {'alarmVValue': [-1, -1], 'alarmCValue': [-1, -1], 'alarmPValue': [-1, -1], 'switch': 'on', 'startup': 'stay', 'pulse': 'off', 'pulseWidth': 500, 'sledOnline': 'on', 'power': 164.24, 'voltage': 233.61, 'current': 1.1} | 594
2023-04-21 14:07:56 [D] 1001736dfa <= Cloud3 | {'current': 22, 'voltage': 23358, 'power': 3098, 'dayKwh': 43, 'monthKwh': 1488} | None
2023-04-21 14:07:56 [D] 1001736dfa <= Local3 | 192.168.70.22:8081 | {'switches': [{'switch': 'on', 'outlet': 0}], 'configure': [{'startup': 'on', 'outlet': 0}], 'pulses': [{'pulse': 'off', 'switch': 'off', 'outlet': 0, 'width': 500}], 'fwVersion': '1.0.7', 'rssi': -38, 'current': 22, 'voltage': 23358, 'power': 3098, 'dayKwh': 43, 'monthKwh': 1488} | 23594
2023-04-21 14:07:57 [D] 10017385e0 => Local4 | 192.168.70.92:8081 | {'getHoursKwh': {'start': 0, 'end': 719}} !! Can't read JSON 
2023-04-21 14:07:57 [D] 10017385e0 => Cloud4 | {'getHoursKwh': {'start': 0, 'end': 719}} | 1682078872001
2023-04-21 14:07:57 [D] 10017385e0 <= Cloud3 | {'online': False} | None
2023-04-21 14:07:57 [D] 10017385e0 => Local4 | 192.168.70.92:8081 | None <= {'sequence': '1682078877000', 'seq': 2, 'error': 400, 'encrypt': True}
2023-04-21 14:08:00 [D] 10017385e0 <= Local3 | 192.168.70.92:8081 | {'switches': [{'switch': 'off', 'outlet': 0}], 'configure': [{'startup': 'off', 'outlet': 0}], 'pulses': [{'pulse': 'off', 'switch': 'off', 'outlet': 0, 'width': 500}], 'fwVersion': '1.0.7', 'rssi': -60, 'current': 0, 'voltage': 0, 'power': 0} | 2
2023-04-21 14:08:00 [D] 10013c5a66 <= Local3 | 192.168.70.90:8081 | {'alarmVValue': [-1, -1], 'alarmCValue': [-1, -1], 'alarmPValue': [-1, -1], 'switch': 'on', 'startup': 'stay', 'pulse': 'off', 'pulseWidth': 500, 'sledOnline': 'on', 'power': 162.43, 'voltage': 231.46, 'current': 1.08} | 595
2023-04-21 14:08:00 [D] 10013c5a66 <= Cloud3 | {'power': '162.43', 'voltage': '231.47', 'current': '1.08'} | None
2023-04-21 14:08:02 [W] Cloud ERROR: {'error': 504, 'reason': 'Request Timeout', 'deviceid': '10017385e0', 'apikey': 'XXXXXXXXXXXXXXXXXX, 'sequence': '1682078872001'}
2023-04-21 14:08:02 [D] 10017385e0 => Local4 | 192.168.70.92:8081 | None <= {'sequence': '1682078882000', 'seq': 3, 'error': 400, 'encrypt': True}
2023-04-21 14:08:02 [D] 10017385e0 <= Local3 | 192.168.70.92:8081 | {'switches': [{'switch': 'off', 'outlet': 0}], 'configure': [{'startup': 'off', 'outlet': 0}], 'pulses': [{'pulse': 'off', 'switch': 'off', 'outlet': 0, 'width': 500}], 'fwVersion': '1.0.7', 'rssi': -61, 'current': 0, 'voltage': 0, 'power': 0} | 3
2023-04-21 14:08:03 [D] 10017385e0 <= Cloud3 | {'online': True} | None
2023-04-21 14:08:03 [D] 10017385e0 => Local4 | 192.168.70.92:8081 | None <= {'sequence': '1682078883000', 'seq': 4, 'error': 400, 'encrypt': True}
2023-04-21 14:08:03 [D] 10017385e0 <= Local3 | 192.168.70.92:8081 | {'switches': [{'switch': 'off', 'outlet': 0}], 'configure': [{'startup': 'off', 'outlet': 0}], 'pulses': [{'pulse': 'off', 'switch': 'off', 'outlet': 0, 'width': 500}], 'fwVersion': '1.0.7', 'rssi': -61, 'current': 0, 'voltage': 0, 'power': 0} | 4
2023-04-21 14:08:03 [D] 10017385e0 <= Cloud3 | {'fwVersion': '1.0.7'} | None
2023-04-21 14:08:04 [D] 10017385e0 <= Cloud3 | {'switches': [{'switch': 'off', 'outlet': 0}], 'configure': [{'startup': 'off', 'outlet': 0}], 'pulses': [{'pulse': 'off', 'switch': 'off', 'outlet': 0, 'width': 500}], 'fwVersion': '1.0.7', 'rssi': -61, 'threshold': {'actPow': {'min': 10, 'max': 500000}, 'voltage': {'min': 18500, 'max': 26400}, 'current': {'min': 10, 'max': 2000}}} | None
2023-04-21 14:08:04 [D] 10017385e0 <= Cloud3 | {'current': 0, 'voltage': 0, 'power': 0, 'dayKwh': 0, 'monthKwh': 1310} | None

Do you have any ideas why the device reboot on this error?

UmairEEE commented 1 year ago

@ov3rload1ng I don't know if the device reboots but if i have Water Pump running. It stops unexpectedly by this error. Then I have to turn my Water Pump on again.

I have changed an option under Settings>Devices&Services>Sonoff>Configure>Mode. that seems to have fixed this issue for now but it implies "not recommended for most users". I have changed Mode from auto to local. I am not sure if it will help you. Only tested it recently and i did not get this error after changing this setting.

defaultsecurity commented 1 year ago

Unfortunately @ov3rload1ng's solution isn't working for me. POWR320D keeps turning off by itself.

UmairEEE commented 1 year ago

@defaultsecurity Are you still getting cloud error or some other error as well?

After changing Mode to local, try reloading integration and restarting HA. Maybe it will work for you. That's what i did after changing Mode.

Also make sure LAN control option for POWR320D is set to enable inside ewelink app.

ov3rload1ng commented 1 year ago

@defaultsecurity @UmairEEE A solution that I found is to change the power-on state configuration to ON using the ewelink app. For this reason, I suppose that the device reboots on the cloud error. I don't know if the problem is on the device, in the SonoffLAN integration, or another part of the chain.

Switching the integration from auto to local works also on my ha but there are other problems. In fact, this mode is not suggested by @AlexxIT

@AlexxIT If my assumption is correct, Do you have any idea why the device reboots when there is a cloud error (see the log)?

UmairEEE commented 1 year ago

I can't change power-on state to ON considering I have a Water Pump connected to it.

@AlexxIT shed some light on this issue and its fix.

UmairEEE commented 1 year ago

Switching the integration from auto to local works also on my ha but there are other problems. In fact, this mode is not suggested by @AlexxIT

Yeah changing mode to local works but not fully. Yesterday my Powr320d turned OFF again without giving me cloud error. Maybe changing mode to local hide the error but the issue still occurs. One thing i can cofirm though after changing mode to local my Powr320d is turning OFF very less.

UmairEEE commented 1 year ago

Tonight Powr320d cycled between ON and then Unavailable few times. Don't know what caused it but then i switched back to auto mode to be on the safe side (re;loaded integration and restarted HA) and it stopped cycling.

kformosa commented 1 year ago

I am too experiencing my POWR316 switching OFF after approx. 1 hour. This device should always be ON since I mainly use it to log power usage. On the eWeLink App I selected Power-on state ON but it doesn't make any effect.

It used to work fine until 2 days ago - random switching OFF just happened. I also noticed that the history on the eWeLink App is all 0; i.e. it seems like not being recorded or deleted. Only have history since around 1-2 April when I think @AlexxIT pushed an update. Again, I don't know if it is related or not.

I can see a number of ERRORS in the log.

I had to remove the device from HA since I cannot afford this random switching OFF. I will test my device being connected to power but without a config on HA and see if the random switching OFF still happens or not.

mihai-trasca commented 1 year ago

I have this issue too, random power-offs. Started recently.

UmairEEE commented 1 year ago

I had to remove the device from HA since I cannot afford this random switching OFF. I will test my device being connected to power but without a config on HA and see if the random switching OFF still happens or not.

@kformosa Does it still happen after removing integration?

mihai-trasca commented 1 year ago

For me it does not happen after disabling the integration

kformosa commented 1 year ago

@UmairEEE it didn't happen, so I can say that it was/is something with the integration.

HOWEVER, after deleting the device from HA, the day after I "found" the device added again in HA automatically (????) but not using any entities/values. It still didn't switch OFF randomly so I really don't know what is happening tbh.

UPDATE: You won't believe me BUT I found a "device triggered" in the eWeLink log this morning at 1:20am! Checked HA logs and there are no errors in the "home-assistant.log" at that time.

UmairEEE commented 1 year ago

UPDATE: You won't believe me BUT I found a "device triggered" in the eWeLink log this morning at 1:20am! Checked HA logs and there are no errors in the "home-assistant.log" at that time.

Was this after removing integration from HA?

UmairEEE commented 1 year ago

I have just noticed that blue led on POWR320D is blinking twice quickly. It's still working in HA. Considering I have to setup it again in ewelink to fix this issue of blinking twice. I remember when i first setup this device in ewelink I was having issue with ewelink not recognizing it from the QR code at the back of this device. I had to use other methods to link it up with ewelink. Maybe QR code was misprinted for my device.

UmairEEE commented 1 year ago

Reconfiguring device after removing in ewelink did nothing to solve cloud error.

AlexxIT commented 1 year ago

Perhaps regular energy requests are overloading the device in some way. You need to disable all energy-related entities.

UmairEEE commented 1 year ago

Perhaps regular energy requests are overloading the device in some way. You need to disable all energy-related entities.

Thanks for the reply. If this is an issue with the device then should it not be there from day one? When i bought it at first. It worked OK for 2 months then this issue started.

AlexxIT commented 1 year ago

Do you use latest integration version from day one? Also energy history grows over time.

UmairEEE commented 1 year ago

Do you use latest integration version from day one? Also energy history grows over time.

When I installed SonoffLAN at first never really looked into versions. I guess the version was latest at that time. This issue started after 2 months when some new updates came out for integration as well as HA and maybe ewelink. Don't remember which one caused it. I tried removing energy history from ewelink but has no effect. Then i reconfigured device from ewelink. That also did nothing. Don't know how to delete energy related entities from integration.

kformosa commented 1 year ago

So I disabled all the energy entities for this Sonoff device - left only Voltage, Current, Power. I tested by leaving the device ON and after 30+ hours it didn't switch OFF on its own. I am keeping energy history using a template and the HA Energy dashboard.

@UmairEEE go to the Entity screen, find the Sonoff device, SELECT the energy entities (Day, month, etc) and press DISABLE

UmairEEE commented 1 year ago

@UmairEEE go to the Entity screen, find the Sonoff device, SELECT the energy entities (Day, month, etc) and press DISABLE

Thanks I will test it.

UmairEEE commented 1 year ago

Finally cloud error is not appearing after disabling energy entities. I have tested for more than 48 hours. Thanks @AlexxIT and @kformosa.

kformosa commented 1 year ago

Unfortunately my POW switched off again on its own at 5:03am - 4.5 days working. I have energy entities disabled. Can't find any logs why this happened again.

UmairEEE commented 1 year ago

Unfortunately my POW switched off again on its own at 5:03am - 4.5 days working. I have energy entities disabled. Can't find any logs why this happened again.

I also got same issue after 3 days. Device turned off just like it used to do with cloud error. This time there was no log.

AlexxIT commented 1 year ago

If you are using a second ewelink account for Hass, try to remove sharing of this device from that account.

kformosa commented 1 year ago

@AlexxIT would it be useful to share my device POWR316 with you (from ewelink)? Right now it is not useful device for me since I cannot trust it - and I need it enabled/ON most of the time.

What I noticed is that I set the "Power ON state" -> ON and SAVE. When it switches OFF (randomly even after 3 days) I see this setting going back to OFF. Don't understand what's going on and cannot see and logs which might help.

All energy entities are disabled.

dheimaz commented 1 year ago

i have same issue with my POWR316D, did you still have problem with this devices?

kformosa commented 1 year ago

I had to remove this device and unplugged it - cannot rely on it to be working 100%

And there seems to be no more support for that.

I suggest not to use this device at all in conjunction with HA

dmostert commented 12 months ago

I have the same problem with my POWR320D - it also started misbehaving 2 days ago.

Power on state would default back to OFF and switch would randomly toggle on and off.

Seems to behave better after disabling all the energy sensors.

exSnake commented 1 month ago

The same thing happens to me, I am currently talking to Sonoff support via Amazon to see if they can access figure out what is going on, the conversation has been going through more than one week right now. The POWR320D shuts down, resets his stats and settings (like power-on on power-off, wi-fi seem to not being impacted) sometimes I have a way to turn it back on via HA before the UPS shuts down, other times I have to physically act on the button because even in the eWelink app become unreachable (even if the UPS is still going).

A real trouble, currently I am always at home so I can debug for Sonoff, there is to say that I also believe it is something related to this integration, as for a while that I was away from home I kept Energy Tab disabled in Home Assistant and it never happened. The curiosity on my side is that for three times in a row it always happened at the same time 12.22pm - 12.24pm UTC+2, does that ring a bell?