Different modes for integration sensor

Not sure it works… was honestly asking for a test :slight_smile:

It’s not about changing the timestamp, it’s about changing the value…

Here is a workaround that uses a Python script to cause a state change in the source sensor one second before the hour boundary. I have provided it for those who still want to use the Integration Sensor to Utility Meter flow which needs:

  1. Integration Sensor to convert kW to kWh
  2. Utility Meter to collect hourly energy consumption
  3. Template sensor to capture the Utility Meter “Last Period” attribute
  4. Automation to force power sensor change just before a new hour.
  5. Python script called by the automation to implement the power sensor change.

Personally, If a Python script workaround is required it might as well replace the Integration Sensor and the Utility Meter. My Python script needs:

  1. Automation to call the Python script when the power sensor changes and on each new hour.
  2. Python script called by the automation to implement the integration.
  3. Template sensor used by the Python script to store the integration. (Not recorded)
  4. Template sensor used by the Python script to store the last power sensor value (Not recorded)
  5. Template sensor used by the Python script to store the hourly energy values.

The ultimate simplification would be to only use the Utility Meter component with these one and two feature requests.

I got same problem with my warmfloors template sensors, try to use your script, thanks.

So after testing I stayed with updates template sensors with small (not zero) consumption when warmfloors is off:

      bathroom_warmfloor_power:
        friendly_name: Мощность теплого пола в ванной
        unit_of_measurement: "W"
        value_template: >
          {% if state_attr("switch.bathroom_warmfloor","actualTemperature")<state_attr("switch.bathroom_warmfloor","desiredTemperature") and states("switch.bathroom_warmfloor") == "on" %}
          {{((states("sensor.l3_voltage")|float)**2/112)|int }}
          {% else %}
          {{((states("sensor.l3_voltage")|float)**2/100000)|round(4) }}
          {% endif %}
1 Like