HOME ASSISTANT

HomeAssistant Automation 설정

choi88 2020. 11. 2. 16:50

자동화 세팅

 

- id: '12312xxx'
  alias: 화장실 노래 on
  description: 입장시 노래 on
  trigger:
  - type: motion #모션 센서 이용 
    platform: device
    device_id: cveg1111df2233xxxx # 모션 센서 디바이스id
    entity_id: binary_sensor.motion_sensor_xxxxxxx #모션센서 엔트리 id
    domain: binary_sensor
  condition: []
  action:
  - service: media_player.play_media #미디어 재생
    data:
      entity_id: media_player.xxxxxxx_mini #구글홈 id
      media_content_id: http://10.0.0.1:8123/local/music/{{ range(1, 2 | int ) | random}}.mp3 #주소 config/www/music
      media_content_type: music
  mode: single


- id: '1603882xxxx'
  alias: 화장실 노래 off
  description: 퇴장시 노래 OFF
  trigger:
  - type: illuminance #조도 센서 이용
    platform: device
    device_id: a6550bc518xxxxxx
    entity_id: sensor.light_detection_sensor_xxxxx
    domain: sensor
    below: 50 # 조도가 50 미만 일경우
  condition: []
  action:
  - service: media_player.media_stop #미디어 중지
    data: {}
    entity_id: media_player.xxxxxxx_mini 
  mode: single

 

모션센서는 엑션과 동시에 통신을 하고 2분동안 status 가 변하지 않습니다

조도 센서는 조도 변화 후 약 5초 후 통신을 합니다

 

조도 센서만 이용시 조도 변화 후 5초 이후 노래가 나오기 때문에 노래는 ON은 

모션센서로 움직임과 동시에 노래 ON으로 지정 했고 모션 센서의 STATUS는 2분동안 

변경이 없기 때문에 조도 센서로 전등이 꺼지고 약 5초후 노래 OFF는 세팅으로 진행했습니다.

( 사용한 기기는 샤오미 모션 센서 , 샤오미 조도 센서 / 아카라 모션 센서도 동일하게 2분 딜레이가 있습니다)