I’m trying to use the not
condition to filter out the events when the device goes to an unknown
or unavailable
state. My code looks like this:
- id: send_message_on_ups_changes
initial_state: true
alias: Send Message on UPS Changes
trigger:
platform: state
entity_id:
- sensor.wiring_closet_ups_status
- sensor.living_room_ups_status
- sensor.office_ups_status
condition:
condition: not
conditions:
- condition: state
entity_id:
- sensor.wiring_closet_ups_status
- sensor.living_room_ups_status
- sensor.office_ups_status
state:
- unknown
- unavailable
mode: queued
max: 4
action:
service: notify.vapid
data_template:
title: >
{{ trigger.to_state.name }}: from {{ trigger.from_state.state }} to {{ trigger.to_state.state }}
message: >
Wiring Closet: {{ states("sensor.wiring_closet_ups_status") }}
Charge: {{ states("sensor.wiring_closet_ups_battery_charge") }}% Load: {{ states("sensor.wiring_closet_ups_load") }}% Runtime: {{ states("sensor.wiring_closet_ups_battery_runtime") }}s
Living Room: {{ states("sensor.living_room_ups_status") }}
Charge: {{ states("sensor.living_room_ups_battery_charge") }}% Load: {{ states("sensor.living_room_ups_load") }}% Runtime: {{ states("sensor.living_room_ups_battery_runtime") }}s
Office: {{ states("sensor.office_ups_status") }}
Charge: {{ states("sensor.office_ups_battery_charge") }}% Load: {{ states("sensor.office_ups_load") }}% Runtime: {{ states("sensor.office_ups_battery_runtime") }}s
but when the entities go to an unavailable state I still get the notification! Why does that happen and how can I fix it?
Should I use a template
trigger and can I still look at the trigger.from_state.state
and trigger.to_state.state
within it?
Thanks,
-Greg