I am just starting with Home Assistant and got my 2 Aqara sensors on my Conbee2 running to get a status about my garage doors.
At the moment I do not plan to configure an external access to my network, so I configured an imap sensor and a notification. So if I send an email to the monitored mailbox I got an email back with the status about these 2 sensors.
What I want to achieve is:
Depending on who requested the status mail (looking for the senders address) the notification’s recipient should be filled dynamically.
This would mean:
I send an email to the home assistant mailbox → I got the status back.
My wife send an email to the home assistant mailbox → ONLY my wife get the status back.
- id: statreq
alias: Check Status by Mail
trigger:
platform: state
entity_id: sensor.imap_state_req
action:
service: notify.smtp_state_ans
data_template:
title: Status from Home Assistant
message: Status
data:
html: >
STATUS GARAGE <br>
Door left: {{ states.binary_sensor.sensor_garage_left.state }} <br>
Door right: {{ states.binary_sensor.sensor_garage_right.state }}
Do you have any idea how I get this working with dynamic recipients depending on the sender’s address?
I got it working!
Just one sensor, one notify and one automation for each email sender.
But do you have any idea how I got the sensor value changed from “off” to “closed” and “on” to “open”?
In the HO website I get the correct values, but not in the email message.
This seems to be normal for a binary_sensor - but how to change?
The valid state values for a binary_sensor are on and off. Depending on the binary_sensor’s optional device_class, its state value may be displayed differently in the Lovelace UI (and only in the UI).
If you want to represent the two values differently, in an email message, you will need to convert them using a template.
{{ 'Open' if is_state('binary_sensor.sensor_garage_left', 'on') else 'Closed' }}
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.
last_changed represents the time when the binary_sensor’s state value changed. It is often the same as last_updated but not necessarily (the entity’s state can be updated without changing).