falcke
(Marcel)
February 27, 2017, 3:41pm
1
Hi!
I’m trying out the binary sensor and started with this:
binary_sensor:
- platform: template
sensors:
hm_lan:
value_template: '{% if is_state("device_tracker.keq1024131fritzbox", "home") %}online{% else %}offline{% endif %}'
friendly_name: 'HM LAN'
sensor_class: connectivity
The template should work since it works with the Templates-Tool. In there it shows the state ‘online’.
In the States section the sensor appears but with the wrong state: ‘offline’.
Where’s the catch?
Any help is appreciated!!!
thrust15
(Thrust15)
February 27, 2017, 4:09pm
2
Hi!
I think binary_sensors only accept True or False as input.
Try this as your value template:
value_template: '{{ states.device_tracker.keq1024131fritzbox.state == "home" }}'
Let me know if this works
edit: home in double quotes
falcke
(Marcel)
February 27, 2017, 4:14pm
3
I just found this thread:
@PtP did the answer:
If you are trying to change the output of the entity it would just be a template sensor.
or try using the elif… I think there was a post about using them both…
mc_garage_state:
value_template: '{% if is_state("binary_sensor.garage_controller", "on") %}Open{% elif states.binary_sensor.garage_controller, "off" %}Closed{% else %}Check Connection{% endif %}'
This works for me now:
sensor:
- platform: template
sensors:
status_hm_lan:
value_template: '{% if is_state("device_tracker.keq1024131fritzbox", "home") %}online{% else %}offline{% endif %}'
friendly_name: 'HM LAN'
icon_template: '{% if is_state("device_tracker.keq1024131fritzbox", "home") %}mdi:server-network{% else %}mdi:server-network-off{% endif %}'
Thanks!!
1 Like