Шлюз SLS Gateway может быть легко интегрирован с системой домашней автоматизации Home Assistant. Для интеграции могут быть использованы программный продукт zigbee2mqtt совместно с разлиными вариантами zigbee-донглов, либо готовый апаратный шлюз Smart Logic System (SLS) Zigbee BLE gateway.
Модуль работает через MQTT. Установка mosqutto на raspberry или linux:
Mosqutto для windows можно скачать тут
Режим Discovery позволяет автоматически добавлять в систему новые устройства. Данный функционал в разработке.
Устройства шлюза SLS Zigbee Gateway можно добавить в Home-Assistant вручную. Для этого в конфигурационный файл configuration.yaml нужно добавить соответствующие типу устройств настройки. Ниже приведены протестированные примеры вырезок из конфигурационного файла:
- platform: mqtt
name: bathroom_leak
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/bathroom_leak_1"
value_template: >-
{% if value_json.water_leak == true %}
{{'ON'}}
{% else %}
{{'OFF'}}
{% endif %}
# Датчик протечки №1 (уровень заряда) SJCGQ11LM
- platform: mqtt
name: bathroom_leak_1_battery
icon: mdi:battery-high
unit_of_measurement: "%"
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/bathroom_leak_1"
value_template: "{{ value_json.battery }}"
- platform: mqtt # Температура
name: bathroom_temperature
icon: mdi:thermometer
unit_of_measurement: "°C"
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/bathroom_sensor"
value_template: "{{ value_json.temperature | round(2) }}"
- platform: mqtt # Влажность
name: bathroom_humidity
icon: mdi:water-percent
unit_of_measurement: "%"
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/bathroom_sensor"
value_template: "{{ value_json.humidity | round(2) }}"
- platform: mqtt # Уровень заряда
name: bathroom_sensor_battery
icon: mdi:battery-high
unit_of_measurement: "%"
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/bathroom_sensor"
- platform: mqtt # Давление
name: loggia_pressure
icon: mdi:gauge
unit_of_measurement: "мм рт.ст."
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/loggia_sensor"
value_template: "{{ (value_json.pressure | float * 7.501) | round | int }}"
- platform: mqtt
name: bathroom_button
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/bathroom_button"
value_template: >-
{% if value_json.click == '' %}
{{'OFF'}}
{% else %}
{{'ON'}}
{% endif %}
expire_after: 5
Замечание по кнопке - так как это именно кнопка, а не переключатель, то binary_sensor меняет свое состояние на очень короткий срок. Для работы с ним можно использовать автоматизацию типа этой (в данном случае при нажатии включается/отключается вентилятор):
- platform: mqtt
name: gateway
availability_topic: "/zigbee-ble/bridge/state"
command_topic: "/zigbee-ble/led"
rgb_command_topic: "/zigbee-ble/led"
rgb_command_template: >-
{
"mode": "manual",
"hex": "#{{ '%02x%02x%02x' | format(red, green, blue) }}"
}
on_command_type: "brightness"
payload_off: '{"mode": "off"}'
- platform: mqtt
name: sls_state
unique_id: cee1d05d-205a-4334-b257-723540c5d578
state_topic: "ZigBeeGW/bridge/state"
device_class: connectivity
payload_on: online
payload_off: offline
json_attributes_topic: "ZigBeeGW/bridge/config"
json_attributes_template: "{{ value_json | tojson }}"
- platform: mqtt
name: gateway_join
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/bridge/config"
value_template: "{{ value_json.permit_join }}"
state_on: true
state_off: false
command_topic: "/zigbee-ble/bridge/config/permit_join"
payload_on: "true"
payload_off: "false"
- platform: mqtt
name: gateway_uptime
icon: mdi:timeline-clock
unit_of_measurement: "%"
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/bridge/config"
value_template: "{{ value_json.UptimeStr }}"
### бойлер
- platform: mqtt
name: gas_boiler
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/gas_heating"
value_template: "{{ value_json.state_l1 }}"
command_topic: "/zigbee-ble/gas_heating/set/state_l1"
### Насос теплого пола switch
- platform: mqtt
name: warm_floor
availability_topic: "/zigbee-ble/bridge/state"
state_topic: "/zigbee-ble/gas_heating"
value_template: "{{ value_json.state_l2 }}"
command_topic: "/zigbee-ble/gas_heating/set/state_l2"
соответственно везде name и адреса топиков поменять на свои
- alias: toggle_bathroom_fan_when_button_pushed
trigger:
- platform: state
entity_id: binary_sensor.bathroom_button
to: "on"
action:
- service: fan.toggle
entity_id: fan.bathroom
- platform: mqtt
name: GardenBulbLeft
state_topic: "/zigbee-ble/GardenBulbLeft"
availability_topic: "/zigbee-ble/bridge/state"
brightness: true
color_temp: true
schema: json
command_topic: "/zigbee-ble/GardenBulbLeft/set"
- platform: mqtt
name: GardenBulbRight
state_topic: "/zigbee-ble/GardenBulbRight"
availability_topic: "/zigbee-ble/bridge/state"
brightness: true
color_temp: true
schema: json
command_topic: "/zigbee-ble/GardenBulbRight/set”
#Сенсор Движение Коридор
- platform: mqtt
name: "Motion koridor battery"
state_topic: "SLS/Sensor_Motion_Koridor"
unit_of_measurement: '%'
value_template: "{{ value_json.battery }}"
- platform: mqtt
name: "Motion koridor linkquality"
state_topic: "SLS/Sensor_Motion_Koridor"
value_template: "{{ value_json.linkquality }}"
- platform: mqtt
name: "Motion koridor dvigenie"
state_topic: "SLS/Sensor_Motion_Koridor"
value_template: "{{ value_json.occupancy }}"
expire_after: 10
- platform: mqtt
name: "Motion koridor yarkost"
state_topic: "SLS/Sensor_Motion_Koridor"
value_template: "{{ value_json.illuminance }}"
unit_of_measurement: 'lux'
#Сенсор Дверь Улица
- platform: mqtt
name: "Door Uliza battery"
state_topic: "SLS/Sensor_Door_Uliza"
unit_of_measurement: '%'
value_template: "{{ value_json.battery }}"
- platform: mqtt
name: "Door Uliza linkquality"
state_topic: "SLS/Sensor_Door_Uliza"
value_template: "{{ value_json.linkquality }}"
- platform: mqtt
name: "Door Uliza"
state_topic: "SLS/Sensor_Door_Uliza"
value_template: "{{ value_json.contact }}"
Создаете файл
#Victor Enot, [06.04.20 18:02]
#==========================================================================================
# python_scripts/set_state.py
#==========================================================================================
inputEntity = data.get('entity_id')
if inputEntity is None:
logger.warning("===== entity_id is required if you want to set something.")
else:
inputStateObject = hass.states.get(inputEntity)
inputState = inputStateObject.state
inputAttributesObject = inputStateObject.attributes.copy()
for item in data:
newAttribute = data.get(item)
logger.debug("===== item = {0}; value = {1}".format(item,newAttribute))
if item == 'entity_id':
continue # already handled
elif item == 'state':
inputState = newAttribute
else:
inputAttributesObject[item] = newAttribute
hass.states.set(inputEntity, inputState, inputAttributesObject)
В automations.yaml необходимо прописать следующий код
- id: '1579606187576'
alias: Tualet pir off
description: ''
trigger:
- entity_id: binary_sensor.tualet_pir
for: 00:02:00
platform: state
to: 'on'
condition: []
action:
- data_template:
entity_id: Binary_sensor.tualet_pir
state: 'off'
service: python_script.set_state
PS: раздел в разработке.