PIR based alarm automation debuging

Hi everyone,

I’m still in the “overwhelmed” phase of my HA discovery. But it’s promising. IE, my wife loves the “cat needs to pee” automation that open one of the cover just enough to let the beast out at 7am.

I’m facing a problem though. I’m trying to use some Neo Coolcam Z-wave PIR sensors as perimetric security devices. The goal is to get an alert if someone triggers the PIR around my house during night, or while we’re not home. But so far, I do not get any notifications…?

I created 3 test automations:

- id: '1637164944247'
  alias: PIR test
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.pir_motion_sensor_2_home_security_motion_detection
    to: Detected
    from: Clear
  condition:
  - condition: time
    after: '13:00'
    before: '21:00'
  action:
  - service: notify.mobile_app_kamobile_xi
    data:
      message: PIR TEST
  mode: single
- id: '1637164942422'
  alias: PIR night alert
  trigger:
    platform: state
    entity_id:
    - binary_sensor.pir_motion_sensor_1_home_security_motion_detection
    - binary_sensor.pir_motion_sensor_3_home_security_motion_detection_2
    - binary_sensor.pir_motion_sensor_3_home_security_motion_detection_3
    to: Detected
  action:
  - condition: time
    state:
    - after: '13:00'
    - before: '19:35'
  - service: notify.Home-Alert
  - service: notify.mobile_app_kamobile_xi
    data:
      message: Perimeter alert!
- id: '1837164947747'
  alias: PIR OOH alert
  trigger:
    platform: state
    entity_id:
    - binary_sensor.pir_motion_sensor_1_home_security_motion_detection
    - binary_sensor.pir_motion_sensor_3_home_security_motion_detection_2
    - binary_sensor.pir_motion_sensor_3_home_security_motion_detection_3
    to: Detected
  action:
  - delay: 00:01:00
  - condition: state
    entity_id:
    - device_tracker.kamobile_xi_2
    state: not_home
  - service: notify.Home-Alert
  - service: notify.mobile_app_kamobile_xi
    data:
      message: Perimeter alert!

None of them triggers anything…?

I checked the notifications system, it’s working when I trigger it by hand from the dev.tool section.
The device trackers are okay, the bin sensors as well and they do report state as either Detected or Clear.

Any clue?

Binary sensors are either ‘on’ or ‘off’, but you used ‘Detected’ and ‘Clear’. These are the states in the frontend and they are based on your language setting and the device class of the binary sensor.

The “true” states can be found under Developer Tools → States, these are the ones you need to use in the automation.

Ok makes total sense, thx a lot. I fixed my automation, but still no luck.
I tried with just one notifier (in case) and with all of them but I don’t get anything so far, neither in pushover (notify.info/alert), app nor in MQTT. Like if it was not triggered. I removed the time also in 1st automation to avoid unnecessary variables.

I checked in the dev.tools and the PIRs are indeed changing states from off to on.

- id: '1637164942422'
  alias: PIR night alert
  trigger:
    platform: state
    entity_id:
    - binary_sensor.pir_motion_sensor_1_home_security_motion_detection
    - binary_sensor.pir_motion_sensor_2_home_security_motion_detection
    from: off
    to: on
  action:
  - service: notify.home_alert
    data:
      message: "Perimeter alert!"
- id: '1837164947747'
  alias: PIR OOH alert
  trigger:
    platform: state
    entity_id:
    - binary_sensor.pir_motion_sensor_1_home_security_motion_detection
    - binary_sensor.pir_motion_sensor_2_home_security_motion_detection
    from: off
    to: on
  action:
  - delay: 00:01:00
  - condition: state
    entity_id:
    - device_tracker.kamobile_xi_2
    state: not_home
  - service: notify.home_alert
  - service: notify.home_info
  - service: notify.mobile_app_kamobile_xi
  - service: notify.notify
    data:
      message: "Perimeter alert!"

Ok I had to quote ‘on’ and ‘off’, my bad, thanks a lot.
I also had a mistake in the state and the data payload needs to be precised per notification service.

Final (working) config:

- id: '1637164942422'
  alias: PIR night alert
  description: ''
  trigger:
    platform: state
    entity_id: 
    - binary_sensor.pir_motion_sensor_1_home_security_motion_detection
    - binary_sensor.pir_motion_sensor_2_home_security_motion_detection
    from: 'off'
    to: 'on'
  action:
  - condition: time
    after: '00:00'
    before: '07:35'
  - service: notify.home_alert
    data:
      message: Perimeter alert!
  - service: notify.notify
    data:
      message: Perimeter alert!
  - service: notify.home_info
    data:
      message: Perimeter alert!
  - service: notify.mobile_app_kamobile_xi
    data:
      message: Perimeter alert!

thx @Burningstone