I have several windows sensors that have a state to determin if they are opened or closed.
Right now I have separate automations for performing an action when the sensor is open and when it is closed, and when it has been left open when the property is vacant (For example, reminding you to close the windows before you leave at night)
Is there any way to combine these together so that the same automation deals with both the opened and the closed events?
For example, if this is my code for the automation. The automation for closing it is identical except I’ve flipped the open and close around.
Can I have one automation that sends one message when the door is opened and another when it is closed, rather than two separate automations?
alias: Sensor_Loadingdock_Door_Opened
description: sends an email when the loading dock pedestrian door has been opened.
trigger:
- platform: state
entity_id:
- binary_sensor.sensor_Loadingdock_door_opening
from: "off"
to: "on"
condition: []
action:
- service: notify.email_notification
data:
message: The Loading Dock Pedestrian door was opened {{ now().strftime( '%d-%m-%y %H:%M') }}
title: Loading Dock Door Opened ({{ now().strftime( '%d-%m-%y %H:%M') }})
target: email.address.com
mode: single