Home Assistant 삽질기 4 (Automation, id와 alias)

Home Assistant(이하 HA) Automation 설정 중에 Automation 자체를 on, off 하려고 찾아보니 automation.turn_on, automation.turn_off 서비스를 호출하여 사용하면 된다고 확인할 수 있었다.

그래서 먼저 on, off 할 Automation 설정을 살펴보았다.

- id: '1573778895083'
  alias: u_bedroom_humidifier_on
  trigger:
  - below: '60'
    entity_id: sensor.bedroom_humi
    platform: numeric_state
  condition: []
  action:
  - data:
      entity_id: fan.bedroom_humidifier
    service: fan.turn_on

위의 Automation은 침실 습도가 60이하로 떨어지면 침실 가습기를 켜라는 자동화였다. 그래서 아래와 같이 코드를 작성해보았다.

- id: '15737788950892'
  alias: ' s_bedroom_humidifier_on_on'
  trigger:
  - at: '22:00:00'
    platform: time
  condition: []
  action:
  - data:
      entity_id: automation.1573778895083
    service: automation.turn_on

위의 Automation은 22:00:00 에 Automation, 1573778895083를 켜라라는 의도로 작성되었다. 테스트를 위해 강제 트리거 시키고 결과를 보니 에러가 나타났다.

Error while executing automation automation.system_bedroom_humidifier_on_on. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data['entity_id']

entity_id 값이 잘못되었다는 것이었다. 구글을 검색해서 이리저리 찾아보니 이미 의견이 분분했다. Automation에서 id 부분은 GUI에서 자동으로 만드는 것이지 실제 이름은 alias를 참조한다는 것이었다. 해당 이슈에 대해서는 여러 의견이 있었지만 일단 alias로 적용 해보았다.

- id: '15737788950892'
  alias: ' s_bedroom_humidifier_on_on'
  trigger:
  - at: '22:00:00'
    platform: time
  condition: []
  action:
  - data:
      entity_id: automation.u_bedroom_humidifier_on
    service: automation.turn_on

위의 코드는 기존 작성한 코드에서 alias 내용으로 호출하도록 수정한 것이다.

테스트 결과 정상 작동하는 것을 확인했다. 즉, Automation에서는 id값이 아닌 alias값을 호출해야 한다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다