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.75k stars 417 forks source link

Sonoff S60 generally works but it loses overall energy consumption #1383

Open guciopl opened 7 months ago

guciopl commented 7 months ago

On/Off control works ok, Daily and Month energy meters are correct. Volts, Amps, Watts I did not exactly check but looks that this is correct as well.

Only thing malfunctioning is overall energy used. It keeps resetting, no idea why. I have 3 of them and on all 3 overall consumption regularly disappears (1st picture in batch of 3). Therefore when I use sensor.sonoff_1002XXXXX_energy in Energy dashboard it shows total bullshit (2nd picture in batch of 3). For example S60TPF is desk LED lamp using 9W, and in Energy dashboard daily energy consumption shows 0,88kWh, while the true one is 0,04. All other readings are ok (3rd picture in batch of 3) and they match ewelink readings (last picture). Let me know if I can assist somehow by sending some more logs or sharing device to Your account.

led led2 led3 lod lod2 lod3 pc pc2 pc3 Screenshot_20240415_142538_eWeLink

AlexxIT commented 7 months ago

Energy should have history for last 30 days. Check attributes of your sensor https://github.com/AlexxIT/SonoffLAN?tab=readme-ov-file#sonoff-pow

guciopl commented 7 months ago

I don't think this is matter of history settings. I don't set them at all and I have 20+ sonoff devices (mostly POW) and they all work well. Definitely something is wrong on HA side with calculating actual power to energy usage. I bought another S60 and added it to HA to double check it.

Daily/monthly usage from app is correct (I verified that with independent power meter): Screenshot_20240417_104627_eWeLink

Those 2 attrubites are passed to HA correctly and visible there: 12

However actual power usage readings are somehow incorrect, and when I link it with power meter entity by this:

- platform: integration
  name: energy_spent_S60chlod
  source: sensor.sonoff_100223XXXX_power
  unit_prefix: k
  round: 2

This is what I see in Energy dashboard after adding sensor.energy_spent_S60chlod there: 11

All needed entities like

AlexxIT commented 7 months ago

The component just requests data from the cloud. I've never seen this data. I don't have any of these devices.

tpehant commented 7 months ago

Hi! I am also having problems in Energy dashboard when adding S60 devices. Data in Individual devices usage is not shown correctly as seen on next two screenshots. I shows negative Energy when it should be positive. I think there is problem with data timestamp. Any ideas? Screenshot_2024-04-22_08-17-42 Screenshot_2024-04-22_08-19-34

jabbas commented 4 months ago

I'm having the same issue, maybe it's because Energy dashboard treats them as incremental not daily?

jabbas commented 4 months ago

In my case, in the db data looks ok:

image

But when put in the energy tab:

image
Gherry777 commented 1 month ago

I can confirm the issue, I have 2xS60TPF and they both do the same.

Another problem I found is that I cannot add the power consumption to the "Energy Tab", despite both devices working correctly.

I guess there's some configuration error on the addon side, both plugs are working perfectly.

guciopl commented 1 month ago

Problem with wrong metering I solved with adding method: left to the configuration:

- platform: integration
  name: energy_spent_jacuzzi
  source: sensor.sonoff_XYZ_power
  unit_prefix: k
  round: 2
  method: left

as per: https://www.home-assistant.io/integrations/integration/#integration-method

Devices I use S60TPF with are not having constant usage, so this metering method is better suited. Now readings in HA match readings in Ewelink. They are being also correctly transformed into daily usage in Energy tab once I registered energy_spent_jacuzzi there.

If someone doesn't need current usage and simply want to have daily readings from device transfered to Energy tab, then the easiest thing to achieve that is to modify S60TPF's _energy_month entity in customize.yaml. You need to set it as total_increasing:

sensor.sonoff_ABC_energy_month:
  device_class: energy
  unit_of_measurement: kWh
  friendly_name: "Device"
  state_class: total_increasing
mikeschat commented 1 month ago

Where exactly did you find customize.yaml? I'm having the same problems and I really only need the energy consumption te be correct for my use case, so i'd like to implement the fix you found.

Thanks in advance!

guciopl commented 1 month ago

Where exactly did you find customize.yaml? I'm having the same problems and I really only need the energy consumption te be correct for my use case, so i'd like to implement the fix you found.

Thanks in advance!

I have it in root directory, next to config.yaml. It is included in that config like this:

homeassistant:
  customize: !include customize.yaml

I think You can also put that code directly to config.yaml but not sure.