Hi all!
Newbie to Home Assistant but slowly getting there.
I’m trying to set up a template sensor with 3 states but i’m not getting the result i’m expecting.
Wee bit of background:
I have a sensor under my bed for detecting when I’m in bed. It feeds a voltage reading to HAS and depending on what that rating is i want to set one of 3 states on the template sensor.
1- If the voltage is lower than 1.00v then state “In Bed”
2- If the voltage is higher than 1.60v then state “Empty”
3- If the voltage is between 1.00v and 1.60v then state “Sitting”
I’ve attempted to do this with the code below which, although it doesn’t cause any errors, always returns “In Bed” regardless of what the voltage is at. Hopefully this is something daft I’m missing but any help would be greatly appreciated!
sensor:
Cav Bed Occupied Sensor
- platform: template
sensors:
cav_bed_status:
friendly_name: "Cav Bed Status"
value_template: >-
{% if states('senor.cav_bed_sensor') | float < 1.00 %}
In Bed
{% elif states('senor.cav_bed_sensor') | float > 1.60 %}
Empty
{% elif states('senor.cav_bed_sensor') | float > 1.00 and states('senor.cav_bed_sensor') | float < 1.60 %}
Sitting
{% else %}
Error
{% endif %}