alias: UPS 状态变化提醒
trigger:
- platform: state
entity_id: sensor.ups_status
condition:
- condition: template
value_template: >
{{
(trigger.from_state.state in ['online', 'charging'] and
trigger.to_state.state not in ['online', 'charging']) or
(trigger.from_state.state not in ['online', 'charging'] and
trigger.to_state.state in ['online', 'charging'])
}}
action:
- service: notify.your_notification_service
data:
message: >
{% if trigger.to_state.state in ['online', 'charging'] %}
UPS 状态已恢复正常。当前状态:{{ trigger.to_state.state }}
{% else %}
UPS 状态异常,请检查!当前状态:{{ trigger.to_state.state }}
{% endif %}
能看懂不? |