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:
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.
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
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%