Force update on a sensor - the hack does not work anymore!

Hello,

I got the same problem as many people here which was forcing the update of a sensor.

For those that do not know why we would do this, it is a very valid scenario where you want to calculate your current power draw from the grid with only a sensor that is giving you an index in kWh (every 1 minute for example) and from this index you calculate the derivative to get the instant power draw.

So far so good, this works well.

But then you have solar panels and when the sun shines, you do not consume power from the grid anymore and then the annoying situation happens.

In this situation, because there is no update anymore on the consumption index, the derivative isn’t recalculated and sticks to its last value (for example 500W). That’s why I need an update of this index to have a derivative equal to 0.

Now that the situation is set, what I had working in 2024 was this :

- trigger:
    # work around 'source' sensor for the derive integrations
    - trigger: time_pattern
      minutes: "/1"
    - trigger: state
      entity_id:
        - sensor.zlinky_east
      not_to:
        - "unknown"
        - "unavailable"
  sensor:
    - unique_id: conso_totale_maj_forcee
      name: "Conso totale maj forcee"
      availability: "{{ has_value('sensor.zlinky_east') }}"
      state: "{{ states('sensor.zlinky_east') | float(3) }}"
      attributes:
        dummy: "{{ now().minute }}"
      unit_of_measurement: kWh
      device_class: energy

I saw this trick somewhere on the forum where you create a new sensor based on the original one where you force the update thanks to an update on its state every minute (and then you calculate the derivative on this new sensor).

Sadly this doesn’t seem to work anymore since some month. So what is now the new way of doing this, if there is any ?

Thanks in advance for any help you may provide !

Hello stylobille,

The above is indeed something you can try. It might update the last_updated property on the sensor. I’m curious to know if it works.

There was a partial change done to fix the derivative problem you are trying to solve, but another change is still needed to fix it entirely. It seems like that change also had the unfortunate side affect on your workaround. Hopefully the second change will come soon, so you do not need the workaround at all.

thanks for both answers, I’ve just implemented the common task, we’ll see tomorrow how it goes once the sun is back !

Any news here?

Got the exact same problem currently. PV Inverted goes to sleep at night and the integral helper freezes at 7000. Force entity does not work for some reason.
Which entity do I need to force the update for? The entity from the integral helper? If so, then this does not work sadly : (