Sensor vs binary sensor

I have a binary sensor for my ring doorbell.
In automation.yaml I have a trigger that should send a message to my google home mini when the doorbell is pressed.

For some reason however the automation is not triggered. When I set the state of the sensor manually, the message is played, so I assume the automation part is correct.

Now I have two questions :

  1. Can I put the binary sensor in sensors.yaml ?
  2. Do I have to set the state of a sensor back to 0 after the bell is pressed ?

This code I have in configuration.yaml

binary_sensor:
  - platform: ring
    name: ring_frontdoor_bell

And this in automations.yaml

- alias: ring_voordeur
  trigger:
    - platform: state
      entity_id: binary_sensor.ring_front_door_ding
      from: '0'
      to: '1'
  action:
    - service: tts.google_say
      data:
        entity_id: media_player.family_room_speaker
        message: "There is someone at your frontdoor" 
        entity_id: media_player.googlehome7626 
        message: "There is someone at your frontdoor"

The states of a binary_sensor are 'off' and 'on', not '0' and '1'.

Tried that before, and now again to be sure, but does not work.
As said when set the state manually to 1 it works

I may be totally off base here but doesn’t putting quotes around your 0 or 1 turn it into a string? Do binary sensors deal with strings?

Tried what? To be clear, you should change your automation trigger to:

  trigger:
    - platform: state
      entity_id: binary_sensor.ring_front_door_ding
      from: 'off'
      to: 'on'

EDIT: Also, check binary_sensor.ring_front_door_ding on the States page. What does it show for its state (when it has updated itself, not after you’ve manually changed the state)?

The state of any entity is a string. Also the values for from: and to:, consequently, must be strings.

`That is what I mean by “tried that too” .:slight_smile:
The state is set from off to on when I press the doorbell.
Still don’t know what is wrong.

Why are there two different entity names? Shouldn’t the automation use the binary_sensor’s name?

@123. One is a friendly name and the other is the entity-id I understood that it is allways possible to use the entity-id.

However, I rebooted my RPI and now I get a notification from my google home mini.

Hurray, don’t know how, but problem solved

But the entity_id should be created from the name you give the binary sensor in the config.

So I think you should end up with an entity_id of binary_sensor.ring_frontdoor_bell.

You should check your states page to verify for sure which one it is.

1 Like