Force sensor refresh

Hi,
I connected my Sonoff POWs R2 running official firmware with HA with help of https://github.com/peterbuga/HASS-sonoff-ewelink but I see that my sensor readings are updated only once per HA reboot (11:12 and 22:30).

Can I set some script to force refresh them for example every 30 seconds?

ha

Those sensors look like they refresh. Do you see anything in the logs? Might have to go to info level…

    if self.get_user_apikey() is None:
        _LOGGER.error("Initial login failed, devices cannot be updated!")
        return self._devices

    # we are in the grace period, no updates to the devices
    if self._skipped_login and self.is_grace_period():
        _LOGGER.info("Grace period active")
        return self._devices

There is a service call you can make to force an update. But it still requires the integration to honor the update time. This sonoff one looks like it has its own internal grace period timer thing so it probably won’t work.

  - service: homeassistant.update_entity
    entity_id: sensor.sonoff_pow
1 Like

I saw on the github that the sonos POW R2 is only partial supported it had no sensor data.

I use this one for native sonoff https://github.com/AlexxIT/SonoffLAN

I’m experimenting with this but i’m a home assistant noob so I only can switch it on and of. But I’m sure that much more is possible.

Hi,
Thank You both guys.

I tried with SonoffLAN and it behaves exactly the same. Also manually triggering sensor update doesn’t help.

Don’t know where exactly is the issue (I suspect ewelink/sonoff servers) but I noticed that when I update devices by swiping down in ewelink it refreshes also sensors in HA.

Maybe an obsoleet question but did you update your firmawre?

See remark from github below

Support only devices with firmware v3+ . LAN should support Multicast traffic.

Yes to both of them.
But I remember clearly when I bought first sonoff pows then powerd readings in app were instant, they were changing basically every second or two. Then after some firmware/app updates it became more and more slow.

Do You get instant readings in Your app? My power consumption changes now like once per 30-60 seconds and even for that I need swipe down few times to force refresh. This is the issue I believe.

In the app I have constantly changing values.

In home assistant I see the values also changing but it seems slower as in the app. Stil there are irregular changes.Below a picture of my sonoff measuring the power consumption of the pump of my floor heating (only temporary for testing will use it late for automated wasmachine notification). When it is active I see some changes.Sometimes multiple changes per minute some times no changes for minutes.

My setup is very basic

Just added these lines to my config and the device gets detected:

sonoff:
  username: !secret Sonoff_user
  password: !secret Sonoff_pass

For creating the sensor I used

  - platform: template
    sensors:
      sonoff_wasmachine_power:
        friendly_name: Washmachine Power
        unit_of_measurement: W
        value_template: "{{ state_attr('switch.sonoff_wasmachine', 'power') }}"
      sonoff_wasmachine_voltage:
        friendly_name: Washmachine Voltage
        unit_of_measurement: V
        value_template: "{{ state_attr('switch.sonoff_wasmachine', 'voltage') }}"
      sonoff_wasmachine_current:
        friendly_name: Washmachine Current
        unit_of_measurement: A
        value_template: "{{ state_attr('switch.sonoff_wasmachine', 'current') }}"

Maybe you can try to delete the .sonoff.json file te rediscover the device.

The issue is that I don’t. So this is something between POW ↔ eWelink and not related to HA - this is why both plugins have same issues in my case.

May I know Your county? And do You have sonoff added via deviced id over cloud or via device key over LAN?

I just created fresh new account, unlinked one POW from original account and linked it there, currently testing but I don’t think it will help. I noticed tho that after unlinking and linking POW again I got new option in settings - Enable LAN. I checked other 6 POWs which were not touched yet and they did not have that option.

I live in the Netherlands.

I just did the standard procedure for installing the ewelink app. I did not use the lan feature

Howerver it worked for me I decided yesterday to flash my sonoffs with tasmota to use MQTT. The updates are now with a 5min interval. Thats fine for me at the moment.

Yep, I will end with Tasmota as well.

Yesterday I pulled device id’s from all my sonoff devices and added them to HA so now I have direct connection between sonoff and HA via LAN. Still lag. My final though is that sonoffs are falling in some kind of sleep mode from which they can be awaken only by refreshing via official app. Topic closed, I don’t think anything more can be done from user side at this point.

Just quick question - that 5 minutes refresh interval is a bit long for me. Did You set it or this is something user can’t adjust?

I think it’s by default. I didn’t do any research how to adjust it at this time.

if you check documentation you have to create an automation to get data populated to the sensor…

I’m using SONOFF LAN 2.3.1, and still learning how to do…

from doc:

Sonoff Pow Power Consumption

For update power consumption of all your Pow devices you can call sonoff.update_consumption service.

The device attributes will display data for the last 100 days. The first element is today’s data. It’s up to you how often to call updates and what to do with this data later.

Remember, without calling the service, there will be no values. Use automation.