Notification with a Sensors State

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.

Interestingly, in the logbook the sensor shows as open/close but template it is showing on/off in the notification.

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.