cdikland
(Cor Dikland)
December 15, 2018, 10:20pm
1
I have the following sensor that captures the time the Foyer motion Sensor activate AND deactivate events occur :
foyer_eventtime:
friendly_name: "Last Foyer Motion"
icon_template: "mdi:clock-alert"
value_template: "{{ as_timestamp(states.binary_sensor.aeotec_dsb05_multisensor_sensor.last_updated) | timestamp_custom('%a %b %d %H:%M:%S') }}"
I want to change this so only the activated (βonβ) event is captured. I am at a loss on what I need to change. Anyone can help would be much appreciated.
nickrout
(Nick Rout)
December 15, 2018, 10:30pm
2
What about updating via an automation?
VDRainer
(π»)
December 15, 2018, 10:42pm
3
Not tested, give it a try.
{% if is_state('binary_sensor.aeotec_dsb05_multisensor_sensor', 'on') %}
"{{ as_timestamp(states.binary_sensor.aeotec_dsb05_multisensor_sensor.last_updated) | timestamp_custom('%a %b %d %H:%M:%S') }}"
{% else %}
{{ states.binary_sensor.aeotec_dsb05_multisensor_sensor.state }}
{% endif %}
cdikland
(Cor Dikland)
December 16, 2018, 12:57pm
4
Not sure I formatted it correctly but the way it is I get errors. Specifically:
Error loading /home/homeassistant/.homeassistant/configuration.yaml: while scanning for the next token
found character '%' that cannot start any token
in "/home/homeassistant/.homeassistant/configuration.yaml", line 253, column 26
where line 253, column 26 is the first % in the first line of
value_template: {% if is_state('binary_sensor.aeotec_dsb05_multisensor_sensor', 'on') %}
"{{ as_timestamp(states.binary_sensor.aeotec_dsb05_multisensor_sensor.last_updated) | timestamp_custom('%a %b %d %H:%M:%S') }}"
{% else %}
{{ states.binary_sensor.aeotec_dsb05_multisensor_sensor.state }}
{% endif %}
cdikland
(Cor Dikland)
December 16, 2018, 1:24pm
5
Not sure how I would do that either.
VDRainer
(π»)
December 16, 2018, 2:01pm
6
Try it this way:
value_template: >
{% if is_state('binary_sensor.aeotec_dsb05_multisensor_sensor', 'on') %}
"{{ as_timestamp(states.binary_sensor.aeotec_dsb05_multisensor_sensor.last_updated) | timestamp_custom('%a %b %d %H:%M:%S') }}"
{% else %}
{{ states.binary_sensor.aeotec_dsb05_multisensor_sensor.state }}
{% endif %}
1 Like
cdikland
(Cor Dikland)
December 16, 2018, 3:28pm
7
Works perfectly with one exception. When the sensor becomes inactive the Last Foyer Motion is set to βoffβ. I modified what you posted above to:
value_template: >
{% if is_state('binary_sensor.aeotec_dsb05_multisensor_sensor', 'on') %}
"{{ as_timestamp(states.binary_sensor.aeotec_dsb05_multisensor_sensor.last_updated) | timestamp_custom('%a %b %d %H:%M:%S') }}"
{% endif %}
but all that did what blank the field once the sensor became inactive.