如何使用Home assistant的mqtt discovery或自定义MQTT主题设备


  • administrators

    此文需要将您的RAFTLINK设备的homehub插件升级到0.1.61或以上版本。可支持下面两种方式 一种是固件支持HA MQTT discovery,不用配置能自动发现使用,另外需要通过RAFTLINK WEB UI上传配置到homehub.

    MQTT Discovery文档说明:
    https://www.home-assistant.io/docs/mqtt/discovery/

    一个例子:

    {
    	"name": "McLighting01",
    	"type": "light",
    	"schema": "json",
    	"state_topic": "home/McLighting01_ha/state/out",
    	"command_topic": "home/McLighting01_ha/state/in",
    	"brightness": "true",
    	"rgb": "true",
    	"optimistic": "false",
    	"color_temp": "true",
    }
    

    上面是对应 https://github.com/toblum/McLighting 你必须有实际设备 并连接到RAFTLINK自带的MQTT BROKER才行

    现在此模块支持开关类设备、灯、人体红外和温度传感器,将来会支持空调,您可以上传下面的样本测试(现在还暂时不支持),来自https://github.com/huexpub/IRMQTT:

    [mqtt0]
    platform=mqtt
    name=zwaircon
    modes=off auto cool heat dry
    fan_modes=auto min low medium high max
    swing_modes=off auto highest high middle low
    power_command_topic="ir_server/ac/cmnd/power"
    mode_command_topic="ir_server/ac/cmnd/mode"
    mode_state_topic="ir_server/ac/stat/mode"
    temperature_command_topic="ir_server/ac/cmnd/temp"
    temperature_state_topic="ir_server/ac/stat/temp"
    fan_mode_command_topic="ir_server/ac/cmnd/fanspeed"
    fan_mode_state_topic="ir_server/ac/stat/fanspeed"
    current_temperature_topic="tele/bksensor/SENSOR"
    current_temperature_template="{{ value_json['SI7021'].Temperature }}"
    swing_mode_command_topic="ir_server/ac/cmnd/swingv"
    swing_mode_state_topic="ir_server/ac/stat/swingv"
    min_temp=16
    max_temp=30
    temp_step=1
    retain=false