I did set up two binary sensors, but something seems to be not ok and I can’t figure out what it might be. Even the sensors are shown, they are not working and the state is always defined as unavailable.
This is the binary_sensor.yaml file.
#### Binary sensors EV Charging ########
- platform: template
sensors:
# True if power is over 2000W
ev_charging_onoff_2kw:
friendly_name: 'EV is Charging with 2 kW'
value_template: "{{states.sensor.sensor.shelly_em_channel_1_power|float < 2 and states.sensor.sensor.shelly_em_channel_1_power|float > 2000}}"
device_class: battery_charging
# True if power is over 3000W
ev_charging_onoff_3_5kw:
friendly_name: 'EV is Charging with 3.5 kW'
entity_id:
- sensor.shelly_em_channel_1_power
value_template: "{{states.sensor.sensor.shelly_em_channel_1_power|float > 3000}}"
#### Binary sensors EV Charging ########
- platform: template
sensors:
# True if power is over 2000W
ev_charging_onoff_2kw:
friendly_name: 'EV is Charging with 2 kW'
value_template: "{{((states.sensor.sensor.shelly_em_channel_1_power|float(0)) < 2) and ((states.sensor.sensor.shelly_em_channel_1_power|float(0)) > 2000)}}"
device_class: battery_charging
# True if power is over 3000W
ev_charging_onoff_3_5kw:
friendly_name: 'EV is Charging with 3.5 kW'
entity_id:
- sensor.shelly_em_channel_1_power
value_template: "{{(states.sensor.sensor.shelly_em_channel_1_power|float(0)) > 3000}}"
#### Binary sensors EV Charging ########
- platform: template
sensors:
# True if power is over 2000W
ev_charging_onoff_2kw:
friendly_name: 'EV is Charging with 2 kW'
value_template: "{{((states.sensor.shelly_em_channel_1_power.state|float(0)) < 2) and ((states.sensor.shelly_em_channel_1_power.state|float(0)) > 2000)}}"
device_class: battery_charging
# True if power is over 3000W
ev_charging_onoff_3_5kw:
friendly_name: 'EV is Charging with 3.5 kW'
value_template: "{{states.sensor.shelly_em_channel_1_power.state|float(0) > 3000}}"
device_class: battery_charging