Automation of random binary sensor

Hello,
I am rather new with home automation.
I would like to trigger events based on door sensors, and since I installed them in another house I wanted to use random sensors to test automation actions.

Unfortunately, the following does not work :
configuration.yaml

binary_sensor:
  - platform: random
    name: random_sensor
...
automation: !include automations.yaml

I added the sensor in a group and I can see it toggle on web interface every 30s as expected

automations.yaml

- alias: 'Intrusion'
  trigger:
    - platform: state
      entity_id: binary_sensor.random_senor
      from: 'off'
      to: 'on'
  action:
    service: notify.sms_me
    data:
      message: Intrusion

The above configuration does not trigger SMS to me, however, when I manually trigger “automation.trigger”, I do receive it.
So my trigger does not work and I don’t understand why.
I did not find examples that show me what I am doing wrong.

Thanks a lot for any help

configuration.yaml
binary_sensor: !include binary_sensor.yaml

inside my binary_sensor.yaml

- platform: rpi_gpio
  ports:
    21: FoyerPIR1
    20: FoyerPIR2
    17: DrivewayPIR

automation

- alias: Message when foyer detects motion when alarm is set
  trigger:
    - platform: state
      entity_id: binary_sensor.foyerpir2
      to: 'on'
  condition:
    - condition: state
      entity_id: alarm_control_panel.ha_alarm
      state: 'armed_away'

  action:
    - service: notify.notify
      data:
        message: "Unexpected Motion in Foyer"
        target: "channel/xxxxxxxxxxxx"

    - service: alarm_control_panel.alarm_trigger
      entity_id: alarm_control_panel.ha_alarm

Hopefully that helps. If its not relevant, feel free to ignore. :slight_smile:

My understanding is that random binary sensor only decides its state when called by something. Your automaton only reacts if the state changes, which it never will because it’s never called. You would need to trigger the automation say once every ten minutes and use the binary sensor as a condition.

This way when the automation is triggered it will test the condition by calling the random sensor, which will return true or false at random, which will decide whether to fire the action.

or if you just want to easily test that the automation itself is working just create a input_boolean and trigger the automation with that.

then you can just manually turn the input_boolean on & off from the frontend and see if the automation works as expected.

Hello all,
thanks for the answers, it helps although the problem was as simple as it can be, I had a typo hidden in my configuration.
I let you find it … :slight_smile:

Indeed the trigger works with the binary sensor, and I get SMS every minute for this test.

Thanks again