Enable sensor if consumption is low

Hello, I would like to create sensor if power consumption is low for more than 3 hours. Example: If consumption is under 10 watts for more than 3 hours then activate sensor. Any ideas? Regards

I use a template binary_sensor for those kind of “alert” sensors:

Ex:

- binary_sensor:

    - name: "CLOUD error"
      device_class: problem
      state: >-
        {% if is_state("sensor.cloud_dmesg", "") %}off{% else %}on{% endif %}

To add: look at delay_on here.

Thanks guys, I will try to realise with your ideas.

@koying @parautenbach I need to ask again. I´m not very familiar with if/else etc. I would appreciate an example very much. My approach again: If consumption is under 10 watts for more than 2 hours then activate sensor.

Thank you in advance!

There’s literally an example in the docs I posted for you that you can tweak for your use case: Template - Home Assistant (home-assistant.io).

# Determine when the washing machine has a load running.
template:
  - binary_sensor:
      - name: "Washing Machine"
        delay_off:
          minutes: 5
        state: >
          {{ states('sensor.washing_machine_power')|float > 0 }}

My guess:

# Determine when the washing machine has a load running.
template:
  - binary_sensor:
      - name: "Some device not running"
        delay_on:
          hours: 3
        state: >
          {{ states('sensor.some_sensor') | float < 10 }}

You haven’t given us much to work from: You haven’t shown what you’ve tried, no entity names, whether you’re using YAML or the UI, etc. How to help us help you - or How to ask a good question - Configuration - Home Assistant Community (home-assistant.io)

template:
  - binary_sensor:
      - name: "Luftentfeuchter voll"
        delay_on:
          hours: 3
        state: >
          {{ states('sensor.luftentfeuchter_current_consumption') | W < 10 }}

My try above and I get following error: Invalid config for [template]: invalid template (TemplateAssertionError: No filter named ‘W’.) for dictionary value @ data[‘binary_sensor’][0][‘state’]. Got “{{ states(‘sensor.luftentfeuchter_current_consumption’) | W < 10 }}\n”.

Can you support? What could be the filter?

Are you trying at random? What is “W” supposed to achieve?

Please be so kind as to make some effort to read the existing and quit thorough documentation

Thanks again :slightly_smiling_face: I had a misunderstanding with “float”, my tought was the filter is related to the unit of m. I change back to “float” and the sensor is available. Crossing fingers that is works…

image

Works as designed :slight_smile: I have tested with minutes. Will order one more power plug for my washing machine :star_struck:

Thanks again for very helpful support!