Hi. I have two accelerometers setup with ESPHome, one to my washer and one to my dryer. I’m getting data from them, but unfortunately I am unable to get a binary sensor template working to show that the dryer/washer is running.
This is what I have in my binary_sensor.yaml:
- platform: template
sensors:
washing_machine:
friendly_name: Washing Machine
value_template: >-
{% if states('sensor.washer_accel_z') | float > 0.1 %}
Running
{% elif states('sensor.washer_accel_z') | float < -0.1 %}
Running
{% else %}
Off
{% endif %}
availability_template: >
{{ states('sensor.washer_accel_z') != 'unavailable'}}
dryer:
friendly_name: Dryer
value_template: >-
{% if states('sensor.dryer_accel_x') | float > 0.1 %}
Running
{% elif states('sensor.dryer_accel_x') | float < -0.1 %}
Running
{% else %}
Off
{% endif %}
availability_template: >
{{ states('sensor.dryer_accel_x') != 'unavailable'}}
No matter what the readings of the accelerometers are at they both always show Off. Can anyone help me figure out what is wrong here? This is my first time writing templates.