Logger: homeassistant.helpers.template
Source: helpers/template.py:735
First occurred: 下午11:29:19 (1089 occurrences)
Last logged: 下午11:32:29
Template variable warning: 'dict object' has no attribute 'threshold_2_protection' when rendering '{{ value_json.threshold_2_protection }}'
Template variable warning: 'dict object' has no attribute 'threshold_1' when rendering '{{ value_json.threshold_1 }}'
Template variable warning: 'dict object' has no attribute 'threshold_2' when rendering '{{ value_json.threshold_2 }}'
input_boolean:
log_enable:
name: "Log Enable"
input_datetime:
log_disable_time:
name: "Log Disable Time"
has_date: true
has_time: true
automation:
# - Starts Log Enable and set timeout
- alias: Enable/Disable Logging By The State of The Log Enable and Set Timeout for 24 Hours
id: "1607918439986"
trigger:
- platform: state
entity_id: input_boolean.log_enable
to:
- "on"
- "off"
action:
- service: >
{% if states('input_boolean.log_enable') == 'on' %}
recorder.enable
{% else %}
recorder.disable
{% endif %}
# Reset the Timer
- service: input_datetime.set_datetime
entity_id: input_datetime.log_disable_time
data_template:
datetime: "{{ (now().timestamp())| timestamp_custom('%Y-%m-%d %H:%M:%S', true) }}"
# IF log_enable is ON
- condition: state
entity_id: input_boolean.log_enable
state: "on"
# Make the timeout to 1 day later
- service: input_datetime.set_datetime
entity_id: input_datetime.log_disable_time
data_template:
datetime: "{{ (now().timestamp() + 60*60*24)| timestamp_custom('%Y-%m-%d %H:%M:%S', true) }}"
- alias: Turn Off Logging By The Timeout
id: "1607918439987"
trigger:
- platform: time_pattern
minutes: "/5"
action:
# Time condition does not work with input_datetime so have to use template to work aorund
- condition: template
value_template: "{{now().timestamp() > state_attr('input_datetime.log_disable_time', 'timestamp')}}"
- service: input_boolean.turn_off
entity_id: input_boolean.log_enable
- service: recorder.disable