Skip to content

Valve 스키마 작성법 ​

가스 밸브 등 개폐 밸브는 valve 엔티티로 정의합니다. type은 valve이며 공통 필드(id, name, packet_parameters, device_class, icon)를 함께 사용할 수 있습니다.

필수 필드 ​

  • state: 밸브 상태를 식별하는 기본 패킷 서명.
  • 상태 판단용 state_open, state_closed 중 하나 이상 — StateSchema 또는 CEL 표현식.
  • 개폐 제어용 command_open, command_close 중 하나 이상.

옵션 필드 (상태) ​

  • 중간 상태: state_opening, state_closing — 열리는 중/닫히는 중.
  • 위치(0~100): state_position — StateNumSchema로 현재 열림 정도를 표현.
  • reports_position: 장치가 이동 중 위치를 주기적으로 보고하는지 여부(Boolean).

옵션 필드 (명령) ​

  • 추가 제어: command_stop.
  • 위치 제어: command_position — 입력 퍼센트 값을 바이트에 삽입.

MQTT 디스커버리 메시지 구성 ​

  • 토픽: homeassistant/valve/<unique_id>/config
  • 공통 필드
    • name, default_entity_id, unique_id
    • state_topic: ${MQTT_TOPIC_PREFIX}/${id}/state
    • availability: ${MQTT_TOPIC_PREFIX}/bridge/status
    • device: devices 설정 또는 브리지 기본 정보
    • 선택: suggested_area, device_class, icon
  • 밸브 전용
    • command_topic: ${MQTT_TOPIC_PREFIX}/${id}/set
    • value_template: {{ value_json.state }}
    • state_open: OPEN, state_opening: OPENING
    • state_closed: CLOSED, state_closing: CLOSING
    • payload_open: OPEN, payload_close: CLOSE
    • 선택: payload_stop (command_stop 설정 시)
  • 위치 지원 시
    • position_topic: ${MQTT_TOPIC_PREFIX}/${id}/state
    • set_position_topic: ${MQTT_TOPIC_PREFIX}/${id}/position/set
    • position_template: {{ value_json.position }}
    • position_open: 100, position_closed: 0
    • 선택: reports_position

예제: 가스 밸브 닫기 명령 ​

yaml
valve:
  - id: gas_valve
    name: 'Gas Valve'
    device_class: gas
    state:
      data: [0x20, 0x01, 0x11]
    state_closed:
      index: 4
      data: [0x00]
    state_open:
      index: 4
      data: [0x01]
    command_close:
      data: [0x20, 0x11, 0x01, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]

작성 체크리스트 ​

  1. 위치 보고가 없는 장치는 reports_position: false로 두고 state_open/closed만 채워 단순 제어로 유지합니다.
  2. 이동 중 패킷이 별도로 오면 state_opening/closing을 사용해 UI 표시를 정확히 합니다.
  3. 안전을 위해 닫기 명령 후 상태 변화를 확인하는 자동화나 CEL 표현식을 추가하는 것이 좋습니다.