Sonoff S31 watts not updating unless eWeLink app is open

Just started using HA a few weeks ago and tried monitoring power usage from 4 different Sonoff S31. After reading some guides I was able to add a chart to my dashboard with the power usage history.

However, it is not updating power usage unless I open the eWeLink mobile app on my phone which is very annoying.

For example, I have a timer to close my lights at 4PM. The lights were closed 4 hours ago, but Home Assistant is still showing the plug is open and consuming power.
image

Now I will open the eWeLink app on my phone, and the chart will update in HA
image
However, even after updating it doesn’t fix the history. The lights were closed 4 hours ago and HA think the lights just closed 6 minutes ago when I opened the app

How can I fix this?

do you have the eWeLink Smart Home add on installed like in here

I use the addon eWeLink Smart Home 1.2.3

I have 4 sonoff but not the same as you have , sometimes I face issues and have to logout and login from the app . But it not that frequent.

Do you also use local sonoff ( Sonoff LAN) ?

I have already tried logout and logging back but unfortunately it didn’t work (fixed the issue temporarily because I opened the app but stopped updating as soon as the app was closed)

“LAN control” is turned ON by default for each device in the eWeLink app but tbh I’m not sure what is the purpose of this function

LAN control is also on in my case .

Did you install Sonoff LAN ? I installed it because sometimes I get cloud disconnection ,even if you do not want to use Sonoff LAN , it a good way to verify and troubleshoot your setup .

Also check your devices connectivity to make sure they are always online ( ping them until you see issue )
Lastly you can change the logger setting to debug mode and you can see more info in the log

I just checked and I already had Sonoff LAN installed. Can you use both at same time? I tried uninstalling Sonoff LAN to use only the official app in case there were conflicts, but it didn’t help. So now I am reinstalling Sonoff LAN. Should I try using only the LAN mode and uninstall the official eWeLink integration, or should I use both at same time?

I was thinking that it could be a conflict too but I have Sonoff LAN installed and my cloud is okay but some of Sonoff LAN devices today are having issue , i am not sure why but it could be because I was testing for your setup .

I will have to check the docs now and redo the same , if no one else help then i’ll try to start from scratch and let you know

( the document below is listing condition for Sonoff LAN but it might not apply in your case )

do you have any devices like the below under the development tools ? if so take a pic

1 Like

Thanks for the replies,

I don’t see any ‘cloud: online’ in the dev tools


Also, I just noticed when I go to the eWeLink integration it’s not updating neither. Cactus lights closed over 1 hour ago, the eWeLink integration is showing the lights are off but it shows both are still using around 100W.

I use Alexa app to schedule when to turn on/off the smart plug.

If I manually click on any of the refresh button, it updates the power usage correctly, but it doesn’t do it automatically

This user seems to be having the exact same problem as mine, using the Sonoff LAN with S31. User suspects the latest HA broke the integration (it was working before the update)

my config.yaml:

  - platform: template
    sensors:
      sensor_power_grow1:
        friendly_name: "Grow Tent 1"
        unit_of_measurement: 'W'
        value_template: "{{ state_attr('switch.10014f7842', 'power')|replace(' W', '') }}" 
      sensor_power_grow2:
        friendly_name: "Grow Tent 2"
        unit_of_measurement: 'W'
        value_template: "{{ state_attr('switch.10014f7776', 'power')|replace(' W', '') }}"
      sensor_power_cactus1:
        friendly_name: "Cactus 1"
        unit_of_measurement: 'W'
        value_template: "{{ state_attr('switch.10014f7996', 'power')|replace(' W', '') }}"
      sensor_power_cactus2:
        friendly_name: "Cactus 2"
        unit_of_measurement: 'W'
        value_template: "{{ state_attr('switch.10014f8010', 'power')|replace(' W', '') }}" 
      grow_room_total_power_usage_kwh:
        friendly_name: 'Total electricity usage'
        unit_of_measurement: 'KWh'
        value_template: "
        {{ (
                state_attr('switch.10014f7842', 'power')|replace(' W', '') + 
                state_attr('switch.10014f7776', 'power')|replace(' W', '') 
            ) / 1000
        }}
        "
      energy_month_kwh:
        friendly_name: Monthly electricity usage
        unit_of_measurement: kWh
        value_template: "{% set p=state_attr('switch.10014f7842', 'consumption') %}{{ p[:30]|sum if p }}"

Logoff everything including the ewlink add-on in HA , Apps … etc and login again ,

Also check the password you used in your yaml for sonoff lan

PS. As you mentioned it could be buggy integration so its going to be trial and error , if this is not okay then let me know before I change my setup to test plzzz

Ok, just signed off everything and logged in again. It updated everything because I opened the app, but it stopped refreshing right after closing the app.

Another strange thing when I logoff eWeLink addon in HA:

After logging:


Yes, the device is in my account. After refreshing the page, the error goes away.

I hope your issue is fixed now . Also my issue was the password is wrong with local sonoff

One thing I noteced is you have a lot of enteires in your yaml for sonoff , why do you have that many
I only have below lines


#===========================SONOFF=======================================================#
  username: !secret sonoff_svf_user
  password: !secret sonoff_svf_password

  force_update: [temperature, humidity, power, current, voltage]
  scan_interval: '00:01:00'  # (optional) default 5 minutes
  sensors: [temperature, humidity, sw_version, cloud, rssi ,local ,unit_of_measurement ]
#=======================================================================================#
        ```

edit , sorry i dnt mention  this is for local sonoff
1 Like

Nice!! Using the parameters scan_interval and force_update it seems to be working now. I set it to 1 minute and now the sensor seems to be updating. It’s working correctly for the first time! However I still don’t see the ‘cloud’ entry in the dev tools (despite using ‘mode: cloud’ in my config) but as long as it’s working it’s fine!

I’m noob I just installed HA a few days ago, I thought I had to manually create a sensor entry in config.yaml for each plug because I was using the official addon and it didn’t automatically create the sensors

Thanks a lot for your help, appreciate it

I think now I remembered ( actually you helped me understand and fix my password )

The config i sent you is for AlexxIT/SonoffLAN ( its also work for cloud ! ) and the eWeLink add-on for the official one .

Just one tip if the devices are important to you to also make sure AlexxIT/SonoffLAN is working so you can have another option if eWeLink is not working .I think i did this because i faced issues few months ago

it was fun working with you , you are a chill dude
cheers

1 Like

Hi guys,

I am a beginner with HA. I have the same problem with eWelink not updating unless I open the mobile app. Installed the “Sonoff” integration via HACS.

I want to try to add the “scan_interval” in the YAML, if this would fix it.
But the problem is that my configuration.yaml file is almost empty, there are no “Sonoff” configuration lines?
Can you help me to locate the config.yaml file for my “Sonoff” integration?

I have the same issue of Power Usage not updating until open the phone app. This only happen to my new Sonoff SPM power monitoring unit. The switch turn ON/OFF works but it reverb back to original setting after toggle it ON/OFF. I update the configuration file as above but no success. Any other ideas?

Looks like the configuration.yaml file force update every minute works but not consistent. I still have one more problem on refresh the switch. IT turn on the switch but within 2 seconds it flip back on the HA but the switch still off. Status not show correctly on the screen.

At first, the power entity updated correctly. Then, I enabled the hidden entity for energy and the power stopped updating unless I open the eWeLink app or call the update_entity service. Then, I disabled the energy entity and rebooted Home Assistant and the power entity is updating correctly again. I use the Powercalc integration as a workaround to convert the power to energy.

I have a basic setup running on a Raspberry Pi 4, with Lutron Caseda switches, an EcoBee using Homekit, a Rachio, an Ambient Weather Station, and 12 S31s. I only have 1 script and automation for my Rachio at the moment. I use the default integrations for all.
I have firmware 3.5.0 on all 12 of my S31s.

Since I last updated the Core and Supervisor on my Raspberry Pi 4 on August 26, all 12 of my S31s are flat lined at the last values for Watts, Amps, Volts in the graphs until I open the ewelink app. The on/off switches function fine within HA including recognizing the on/off state in close to real time. I could view graphs in the History before the HA update.

What changed with the update that would break HA from polling the S31s, and how can I fix it? I do not use the “energy” navigation item, I just want to be able to view the graphs in history. I am only using the S31s to find energy Hogs.

What is this “Sonoff LAN” integration? I do not see it in Integrations. I am not sure I want to clutter the config with redundant items, but I am trying to find ways to lessen the dependency of cloud based APIs.

I am trying to keep things simple, so editing YAML, and adding a bunch of HACS add ons are not really what I am looking to do. Thanks.

[edit] I apparently did install Sonoff LAN in HACS already, and I see it in custom configurations, but I do not see any YAML other than services.yaml in that folder. I do not have any entries for Sonoff in my global configuration.yaml file. :thinking: [/edit]