User Tools

Site Tools


интеграция_с_homeassistant

Контроллер LightHub прекрасно интегрируется в систему Home Assistant с использованием MQTT

В настоящее время, реализованы и используются следующие интеграции:

  • Реле и дискретные выключатели
  • Диммируемые одноцветные светильники
  • Диммируемые цветные светильники (RGB/RGBW)
  • Термостаты теплого пола
  • Кондиционер
  • Сенсоры температуры
  • Сенсоры влажности
  • Сенсоры CO2

Общая настройка MQTT

      
mqtt:
  broker: 192.168.88.2
  port: 1883
  client_id: home-assistant-1
  keepalive: 60
#  username: !secret mqtt_login
#  password: !secret mqtt_password
  protocol: 3.1
  birth_message:
    topic: "myhome/hass1/LWT"
    payload: "Online"
    qos: 1
    retain: true
  will_message:
    topic: "myhome/hass1/LWT"
    payload: "Offline"
    qos: 1
    retain: true

Сенсоры

В примерах ниже: Имя контроллера: light-d2

Предположим, что к этому контроллеру подключен датчик качества воздуха CCS811 и HDC1080 и в конфиге контроллера для этого заданы такие вот настройки:

"98":{"T":5,"emit":"myhome/sensor/airq"},
"99":{"T":6,"emit":"myhome/sensor/humidity"}

Также, на pin3 подключен сенсор температуры и влажности dht-22, расположенный в ванной, с такой вот настройкой в JSON конфиге контроллера:

 "3":{"T":4,"emit":"dht"},
 

ну и к шине 1-wire подключен термометр в прихожей

 "ow":{"28EEA76713160204":{"emit":"t_aentr"}
 }               

В этом случае, конфигурация HomeAssistant будет выглядеть вот таким образом:

sensor:
  - platform: mqtt
    name: "CO2"
    icon: "mdi:periodic-table-co2"
    expire_after: 600
    state_topic: "myhome/sensor/airq/CO2"
    unit_of_measurement: 'ppm'
    availability_topic: "myhome/light-d2/$state"
    payload_available: "ready"
    payload_not_available: "disconnected"
    
  - platform: mqtt
    name: "TVOC"
    expire_after: 600
    state_topic: "myhome/sensor/airq/TVOC"
    unit_of_measurement: 'ppm'
    availability_topic: "myhome/light-d2/$state"
    payload_available: "ready"
    payload_not_available: "disconnected"
    
  - platform: mqtt
    name: "Влажность"
    icon: "mdi:water-percent"
    expire_after: 600
    state_topic: "myhome/sensor/humidity/H"
    unit_of_measurement: '%'
    availability_topic: "myhome/light-d2/$state"
    payload_available: "ready"
    payload_not_available: "disconnected"     
    
  - platform: mqtt
    name: "Влажность ванная DHT"
    icon: "mdi:water-percent"
    expire_after: 600
    state_topic: "myhome/s_out/dhtH"
    unit_of_measurement: '%'
    
  - platform: mqtt
    name: "Воздух ванная DHT"
    icon: "mdi:thermometer"
    expire_after: 600
    state_topic: "myhome/s_out/dhtT"
    unit_of_measurement: '°C'   
    
  - platform: mqtt
    name: "Воздух прихожая DS"
    icon: "mdi:thermometer"
    expire_after: 600
    state_topic: "myhome/s_out/t_aentr"
    unit_of_measurement: '°C'        
   

Светильники

  


light:
# дискретный выключатель света (вкл-выкл)
  - platform: mqtt
    name: "Прихожая"
    state_topic: "myhome/s_out/spots_en"
    command_topic: "myhome/in/spots_en"
    qos: 1
    
# Диммируемый одноцветный светильник    
  - platform: mqtt
    name: Кухня точки
    command_topic: "myhome/in/ktc/cmd"
    state_topic: "myhome/s_out/ktc/cmd"
    brightness_scale: 100
    brightness_command_topic: "myhome/in/ktc/set"
    brightness_state_topic: "myhome/s_out/ktc/set"
    
# Цветной LED светильник    
  - platform: mqtt
    name: Кухня LED
    command_topic: "myhome/in/kuh/cmd"
    state_topic: "myhome/s_out/kuh/cmd"
    hs_command_topic: "myhome/in/kuh/set"
    hs_state_topic: "myhome/s_out/kuh/set"  
    hs_value_template: "{{ value.rsplit(',', 1)[0] }}"
    brightness_scale: 100
    brightness_command_topic: "myhome/in/kuh/set"
    brightness_state_topic: "myhome/s_out/kuh/set"
    "{%set a=value.split(',')%}       {% if a[1] -%}          {{a[0]+','+a[1]}}      {%- endif %}"

Выключатели

    
switch:
  - platform: mqtt
    name: "Air heat"
    icon: "mdi:radiator"
    state_topic: "myhome/s_out/fm_t/cmd"
    command_topic: "myhome/in/fm_t/cmd"
  - platform: mqtt    
    name: "Air auto"
    icon: "mdi:auto-fix"
    state_topic: "myhome/s_out/fm_auto"
    command_topic: "myhome/in/fm_auto"    
  - platform: mqtt
    name: "Перекрыть воду"
    icon: "mdi:water-off"
    state_topic: "myhome/s_out/alock_leak"
    command_topic: "myhome/in/alock"
    qos: 1
  - platform: mqtt
    name: "Сушилки"
    icon: "mdi:radiator"
    state_topic: "myhome/s_out/h_polotenc"
    command_topic: "myhome/in/h_polotenc"
    qos: 1
  - platform: mqtt
    name: "Бойлер большой"
    state_topic: "myhome/s_out/h_boil1"
    command_topic: "myhome/in/h_boil1"
    qos: 1    
  - platform: mqtt
    name: "Бойлер малый"
    state_topic: "myhome/s_out/h_boil2"
    command_topic: "myhome/in/h_boil2"
    qos: 1      

Климат и термостаты

    
climate:
  - platform: mqtt
    name: Кондиционер
    modes:
      - "off"
      - "cool"
      - "fan_only"
      - "heat"
      - "auto"
    fan_modes:
      - "auto"
      - "high"
      - "medium"
      - "low"
    swing_modes:
      - "on"
      - "off"      
    swing_mode_state_topic: "myhome/s_out/ac/swing"
    swing_mode_command_topic: "myhome/in/ac/swing"
    swing_mode_state_template: "{{value|lower()}}"
    mode_command_topic: "myhome/in/ac/cmd"
    mode_state_topic: "myhome/s_out/ac/cmd"
    mode_state_template: "{{value|lower()}}"
    temperature_command_topic: "myhome/in/ac/set"
    temperature_state_topic: "myhome/s_out/ac/set"
    fan_mode_command_topic: "myhome/in/ac/fan"
    fan_mode_state_topic: "myhome/s_out/ac/fan"
    fan_mode_state_template: "{{value|lower()}}"
    current_temperature_topic: "myhome/s_out/ac/temp"

  - platform: mqtt
    name: "Теплый пол душ"
    modes:
      - "off"
      - "heat"
      - "auto"
    mode_command_topic: "myhome/in/h_bath1/cmd"
    temperature_command_topic: "myhome/in/h_bath1/set"
    mode_state_topic: "myhome/s_out/h_bath1/cmd"
    mode_state_template: "{{value|lower()}}"
    temperature_state_topic: "myhome/s_out/h_bath1/set"
    current_temperature_topic: "myhome/s_out/t_bath1"

  - platform: mqtt
    name: "Климат спальня"
    modes:
      - "off"
      - "heat"
      - "auto"
      - "cool"
      - "fan_only"
    mode_command_topic: "myhome/in/c_bedr/cmd"
    temperature_command_topic: "myhome/in/c_bedr/set"
    mode_state_topic: "myhome/s_out/c_bedr/cmd"
    mode_state_template: "{{value|lower()}}"
    temperature_state_topic: "myhome/s_out/c_bedr/set"
    current_temperature_topic: "myhome/s_out/t_bedr"    

    

Приточка

climate:
  - platform: mqtt
    name: Вентиляция
    modes:
      - "off"
      - "fan_only"      
      - "heat"
      - "auto"
    mode_command_topic: "myhome/in/fm/cmd"
    mode_state_topic: "myhome/s_out/fm/cmd"
    mode_state_template: "{{value|lower()}}"    
    temperature_command_topic: "myhome/in/fm_t/set"
    temperature_state_topic: "myhome/s_out/fm_t/set"
    current_temperature_topic: "myhome/s_out/fm_stat"
    current_temperature_template: "{{ value_json.t }}"
    
sensor:    
- platform: mqtt
    name: "Heater power"
    state_topic: "myhome/s_out/fm_stat"
    icon: "mdi:radiator"
    unit_of_measurement: '%'
    value_template: "{{ value_json.pwr }}"
  - platform: mqtt    
    name: "Fan RPM"
    icon: "mdi:fan"
    state_topic: "myhome/s_out/fm_stat"
    unit_of_measurement: 'RPM'
    value_template: "{{ value_json.RPM }}"
  - platform: mqtt  
    name: "Fan Current"
    icon: "mdi:current-ac"
    state_topic: "myhome/s_out/fm_stat"
    unit_of_measurement: 'A'
    value_template: "{{ value_json.I }}"
  - platform: mqtt    
    name: "Fan Fault"
    icon: "mdi:alert"
    state_topic: "myhome/s_out/fm_stat"
    value_template: "{{ value_json.flt }}"   
#  - platform: mqtt    
#    name: "Fan Temp"
#    state_topic: "myhome/s_out/fm_stat"
#    unit_of_measurement: '°C'  
#    value_template: "{{ value_json.t }}"    
#  - platform: mqtt    
#    name: "Fan Temp set"
#    state_topic: "myhome/s_out/fm_stat"
#    unit_of_measurement: '°C'  
#    value_template: "{{ value_json.set }}"     
    
интеграция_с_homeassistant.txt · Last modified: 2020/05/17 10:48 by 192.168.88.1