potts-mike
(Potts Mike)
January 5, 2023, 11:36pm
1
I am struggling with sending the state of a binary sensor in a notification. I’ve got the notification sending no problem but the templating is proving a challenge.
I’ve got
service: notify.pottshomebot
data:
message: >
Exterior Contacts are {{ states.sensor.binary_sensor.exterior_contacts.state
}}
Where binary_sensor.exterior_contacts is a contact group of all the exterior doors and windows.
Thanks for any help.
You have an error in your template. It is either “sensor” or “binary_sensor”, not both.
The better/correct template would be:
{{ states('binary_sensor.exterior_contacts') }}
Or you could keep using:
{{ states.binary_sensor.exterior_contacts.state }}
That worked thank you.
Curiously the contact group is showing as on or off . Is there a way to make open or closed ?
In general you can define a device class for a binary sensor, that determines how the device is displayed (icon, states).
Not sure how this would work with a group.
I guess, as long as all the entities in a group have the same device class, the group would inherit it.
potts-mike
(Potts Mike)
January 20, 2023, 4:11am
5
Interestingly, in the logbook the sensor shows as open/close but template it is showing on/off in the notification.
330chauf
(330chauf)
June 1, 2023, 12:25pm
6
Hi Mike,
did you ever get this solved. running in to the same issue?
tnx in adv
Pretty sure you can do it with some sort of template but I gave up.