zoukankan      html  css  js  c++  java
  • (二 -2) 天猫精灵接入Home Assistant-自动发现Mqtt设备

    参考中文教程:  https://www.hachina.io/docs/7230.html

    英文官网 两个温度传感器:https://www.home-assistant.io/docs/mqtt/discovery/
     

    1HomeAssistant中MQTT设备的自动发现逻辑是:

    • MQTT设备将自身的配置信息发布在事前定义的主题位置上
    • HomeAssistant从这个主题位置读取信息,生成对应的系统内实体设备

    2支持自动发现的设备包括:

    • 开关型传感器(binary_sensor)
    • 摄像头(camera)
    • 窗帘(cover)
    • 电扇(fan)
    • 灯(light)
    • 传感器(sensor)
    • 开关(switch)

    3HomeAssistant支持自动发现,需要在配置文件中增加:

    mqtt:
      # 此处为mqtt原有的一些配置
      # ……
      # 配置自动发现
      discovery: true
      # 自动发现使用的主题位置前缀,缺省为homeassistant
      discovery_prefix: homeassistant

    4设备将自己的配置信息发布在主题位置:

    • <discovery_prefix>/<component>/[<node_id>/]<object_id>/config
    • <discovery_prefix>:配置文件中的discovery_prefix,缺省为homeassistant
    • <component>:设备所在的域,例如light、switch、binary_sensor等
    • <node_id>:可选,节点ID
    • <object_id>:设备ID

    配置信息采用JSON格式。


    例如,MQTT设备在主题:

    homeassistant/switch/irrigation/config
    

      

    发布信息:

    当HomeAssistant读取此信息,相当于配置文件中存在以下内容:

     
     

    警告:

     自动发现设备的时候,一定要改配置话题第三个参数ID,

    • 跟换设备名没关系。设备名重复,ID不重复,可以添加。
    • ID重复,不管设备名重复不重复,只能有一个

    第一个设备 名字 RGBlight  ID garden   存在

    homeassistant/light/garden/config

    {"name": "RGBlight", "command_topic": "hachina/rgb1/light/switch",

    第二个设备 名字light   ID garden1   存在

    homeassistant/light/garden1/config

    {"name": "light", "command_topic": "hachina/rgb1/light/switch",

    第三个设备 名字light   ID garden2   存在

    homeassistant/light/garden2/config

    {"name": "light", "command_topic": "hachina/rgb1/light/switch",

    第四个设备 名字light   ID garden    不存在

    homeassistant/light/garden/config

    {"name": "light", "command_topic": "hachina/rgb1/light/switch",

    ID和第一个配置ID冲突,只能存在一个

  • 相关阅读:
    unity ab包打包和加载的简单学习示例
    项目整理回顾1,关于单例使用
    关于lua闭包导致引用无法释放内存泄露
    unity lua require dofile loadfile 区别
    unity editor模式下读取文件夹资源
    unity texture 占用内存大小对比
    关于unity贴图压缩
    内聚,耦合,解耦和,依赖倒置
    lua type 获取 类型
    Unity+NGUI多分辨率适配方案
  • 原文地址:https://www.cnblogs.com/kekeoutlook/p/9471884.html
Copyright © 2011-2022 走看看