再次感谢大佬的分享,今天研究了一下,大佬是以call service形式来控制,在HA里面貌似没有实体entity的,我这这里稍微修改了一下,加了一个Mqtt返回节点,然后在HA的配置文件添加以下代码,让遥控按钮已开关形式存在,这样有entity之后,在Lovelace的写法,或者自动化的写法都要简单点,homekit也会映射对应的按钮,纯属个人意见,楼主大佬勿怪。
[{"id":"3add3a82.d95796","type":"mqtt out","z":"c2589335.0f2d5","name":"返回值","topic":"homeassistant/remote/status","qos":"0","retain":"","broker":"91154f6f.d4cc4","x":670,"y":220,"wires":[]},{"id":"91154f6f.d4cc4","type":"mqtt-broker","z":"","name":"HA Mqtt","broker":"192.168.2.100","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
HA配置示例:
switch:
- platform: mqtt
name: "gimi_left"
state_topic: "homeassistant/remote/status"
command_topic: "homeassistant/remote/GIMI"
qos: 2
payload_on: "left"
payload_off: "left"
retain: true
- platform: mqtt
name: "gimi_right"
state_topic: "homeassistant/remote/status"
command_topic: "homeassistant/remote/GIMI"
qos: 2
payload_on: "right"
payload_off: "right"
retain: true
- platform: mqtt
name: "gimi_up"
state_topic: "homeassistant/remote/status"
command_topic: "homeassistant/remote/GIMI"
qos: 2
payload_on: "up"
payload_off: "up"
retain: true
- platform: mqtt
name: "gimi_down"
state_topic: "homeassistant/remote/status"
command_topic: "homeassistant/remote/GIMI"
qos: 2
payload_on: "down"
payload_off: "down"
retain: true
后面就有了实体显示了:
|