Action - motion detection with multisensor_4in1 does not do what I think

Fokksm
I have create a scene, not quite sure if this is working with a scene. But I wanna switch on the Sonos in the bathroom when I enter the room. I have created and tested a scene and it’s working

  • name: Enter Bad
    entities:
    media_player.bad:
    state: on

What I haven’t figured out is how I can track when I enter the room. I do have a z-wave vision_zp3111_multisensor_4in1. That guy has multiple sensors:

  • sensor.vision_zp3111_multisensor_4in1_alarm_level_3_1
  • sensor.vision_zp3111_multisensor_4in1_alarm_type_3_0
  • sensor.vision_zp3111_multisensor_4in1_burglar_3_10
  • sensor.vision_zp3111_multisensor_4in1_clock_3_14
  • sensor.vision_zp3111_multisensor_4in1_emergency_3_13
  • sensor.vision_zp3111_multisensor_4in1_luminance_3_3
  • sensor.vision_zp3111_multisensor_4in1_relative_humidity_3_5
  • sensor.vision_zp3111_multisensor_4in1_sourcenodeid_3_2
  • sensor.vision_zp3111_multisensor_4in1_system_3_12
  • sensor.vision_zp3111_multisensor_4in1_temperature_3_1

…so I expact that vision_zp3111_multisensor_4in1_burglar_3_10 will recognize when someone moves.

So I expect that this value changes from 8 to 0. So I created:

automation:
trigger:
platform: template
value_template: “{% if is_state(“sensor.vision_zp3111_multisensor_4in1_burglar_3_10”, “0”) %}true{% endif %}”
action:
- service: scene.turn_on
entity_id: scene.enter_bad

You could start by verifying how / which sensor reports back to HA when you enter the room. It took quite a bit of experimenting to figure mine out.

Mine is running on pi3, so if I execute
sudo journalctl -fu home-assistant | grep -i binary_sensor (which is the base of my sensor name) and then walk in front of that sensor, I will get a short dump of data to verify what HA sees.

Sorry, I can’t help you with your problem. Just a suggestion: I’d write that template as

value_template: '{{ states.sensor.vision_zp3111_multisensor_4in1_burglar_3_10.state | int == 0 }}'

I think that’s easier to read.

EDIT: When you’re using it as a trigger, it would be:

trigger:
  - platform: state
    entity_id: sensor.vision_zp3111_multisensor_4in1_burglar_3_10
    state: '0'

Sebastian

Well folks I solved the problem and not quite sure if this was a very sophistacted solution with:

  • platform: template
    sensors:
    motion_bad:
    friendly_name: ‘Bad Motion Detector’
    value_template: >-
    {%- if is_state(“sensor.vision_zp3111_multisensor_4in1_burglar_5_10”, “0”) -%}
    No
    {%- else -%}
    Yes
    {%- endif -%}
    So I do see if there is motion detected or not.
    My ask was to turn on my sonos when motion is detected and switch if off when I left the room.
    My solution was:
  • alias: “Switch on BAD Media Player if Motion is detected during day”
    trigger:
    platform: state
    entity_id: sensor.vision_zp3111_multisensor_4in1_burglar_5_10
    from: ‘0’
    to: ‘8’
    condition:
    condition: time

    At least one of the following is required.

    after: ‘8:00:00’
    before: ‘23:00:00’
    action:
    service: media_player.turn_on
    entity_id: media_player.bad

service: script.turn_on

entity_id: script.sonos_bad_timer

  • alias: “No Motion Notification”
    trigger:
    platform: state
    entity_id: sensor.vision_zp3111_multisensor_4in1_burglar_5_10
    from: ‘8’
    to: ‘0’
    action:
    service: media_player.turn_off
    entity_id: media_player.bad

What that automation.yaml entry does is: only switch on radio during the day not at night and switch it off when I leave the room. Looks like I get some progress in my experience. Let’s say from 0% to 8%