Template not updateing

I have this template for the old “washing machine status by power consumption” problem:

template:
  - binary_sensor:
    - name: "Washing machine active"
      unique_id: uk_washing_active
      device_class: power
      delay_off: "0:05:00"
      state: >
        "{{ states('sensor.tas_plug1_energy_power')|float > 10 }}"

However, it is not updating:
Screenshot_20230304_165516

What am I overlooking?

Anything in your log?

Can a binary sensor have a device class of ‘power’? :man_shrugging:

Logs:

A few things to do, but not in this regard, as far as I can see. Not that the power plug in question would be tas-plug1.

Good question, I added that from another example for the same problem during testing. Took it out again.

For completeness
Screenshot_20230304_174017

Yes it can: https://www.home-assistant.io/integrations/binary_sensor/

1 Like

Don’t quote multi-line templates. Only single line templates have to be quoted. Also you should supply a default value for your float filter and an availability template. So like this:

template:
  - binary_sensor:
      - name: "Washing machine active"
        unique_id: uk_washing_active
        device_class: power
        delay_off: "0:05:00"
        state: "{{ states('sensor.tas_plug1_energy_power')|float(0) > 10 }}"
        availability: "{{ states('sensor.tas_plug1_energy_power')|is_number }}"

Or this:

template:
  - binary_sensor:
      - name: "Washing machine active"
        unique_id: uk_washing_active
        device_class: power
        delay_off: "0:05:00"
        state: > 
          {{ states('sensor.tas_plug1_energy_power')|float(0) > 10 }}
        availability: >
          {{ states('sensor.tas_plug1_energy_power')|is_number }}

You might like to fix your entity id too. Power or energy, not both. They are seperate things.

Thanks, that indeed did it!

energy_power" is provided by tasmota, I don’t think I want to patch it to change that :slight_smile:
"energy
” is essentially the namespace for a bunch of energy related MQTT topics:
sensor.tas_plug1_energy_apparentpower, sensor.tas_plug1_energy_current, sensor.tas_plug1_energy_factor, sensor.tas_plug1_energy_power, sensor.tas_plug1_energy_reactivepower, sensor.tas_plug1_energy_today, sensor.tas_plug1_energy_total, sensor.tas_plug1_energy_totalstarttime, sensor.tas_plug1_energy_voltage, sensor.tas_plug1_energy_yesterday

Is it though?

Or is it because you have called your device tas_plug1_energy

Either way you don’t have to patch anything. Just edit the entity id from the UI (and everywhere you have already used it).

Won’t that cause issues with the MQTT autodiscover, i.e., the old device would be added again?

No. The entity_id is not the unique_id.

I see, thanks.