I have a GE Z-wave plus motion sensor that I’ve been trying to configure so it works nicely with Homeassistant. Currently I get values of 0 (clear), 8 (motion detected), or 254 (right after a reboot of Homeassistant). Below is my template, and it seems to be working when I try it in the template editor, but doesn’t actually work when tested.
binary_sensor:
- platform: template
sensors:
ge_motion:
friendly_name: GE Motion Sensor
entity_id: sensor.ge_zw6302_portable_smart_motion_sensor_burglar_2
device_class: motion
value_template: >-
{% if is_state('sensor.ge_zw6302_portable_smart_motion_sensor_burglar_2', '8') %}
on
{% else %}
off
{% endif %}
I just now discovered there is a nice write up in the docs about this exact template. When I copied and pasted the example everything works. Not sure if it was formatting or what but here is the working config.
Yeah, I’m aware of the importance of formatting, but this was my first go at templating so I was a bit out of my comfort zone. I think that was the solution, although it’s a little misleading that my template was giving accurate results in the front end template editor.
The way I use the template editor is to make sure the template gives the proper text, but in the .yaml files, I have to make sure I put the template in the proper “place” to make that text appear correctly.