从 mqtt 配置二进制传感器
configure binary sensor from mqtt
我有启用了 MQTT 客户端的 zway 控制器和将状态发布到 mqtt 主题的二进制传感器。
zway95/data/ZWayVDev_zway_9-0-48-12
{
"creationTime": 1587157138,
"creatorId": 1,
"customIcons": {},
"deviceType": "sensorBinary",
"firmware": "3.80",
"h": 1979762458,
"hasHistory": false,
"id": "ZWayVDev_zway_9-0-48-12",
"location": 3,
"locationName": "Коридор",
"manufacturer": "Shenzhen Neo Electronics Co., Ltd",
"metrics": {
"probeTitle": "Motion",
"scaleTitle": "",
"icon": "motion",
"level": "off",
"title": "Движение - Коридор",
"isFailed": false
},
"nodeId": 9,
"order": {
"rooms": 0,
"elements": 0,
"dashboard": 0,
"room": 2
},
"permanently_hidden": false,
"probeType": "motion",
"product": "",
"tags": [],
"technology": "Z-Wave",
"visibility": true,
"updateTime": 1643685077
}
zway95/state/ZWayVDev_zway_9-0-48-12
off
或
on
我HA也有这样的配置
binary_sensor:
- platform: mqtt
state_topic: "zway95/state/ZWayVDev_zway_9-0-48-12"
name: "testmotion"
device_class: "motion"
payload_on: "true"
payload_off: "false"
availability_template: "{{ value_json.metrics.isFailed }}"
availability:
- topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
payload_available: false
payload_not_available: true
json_attributes_topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
在 HA 中,传感器看起来不可用并且缺少属性
我哪里弄错了?
这是工作配置:
binary_sensor:
- platform: mqtt
state_topic: "zway95/state/ZWayVDev_zway_9-0-48-12"
name: "testmotion"
device_class: "motion"
payload_on: "on"
payload_off: "off"
availability_topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
availability_template: "{{ value_json.metrics.isFailed }}"
payload_available: false
payload_not_available: true
json_attributes_topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
我的理解是home assistant documentation availability_template
是为了和availability_topic
一起使用。所以要么去
availability_template: "{{ value_json['metrics']['isFailed'] }}"
availability_topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
payload_available: false
payload_not_available: true
或
availability:
- topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
payload_available: false
payload_not_available: true
value_template: "{{ value_json['metrics']['isFailed'] }}"
我有启用了 MQTT 客户端的 zway 控制器和将状态发布到 mqtt 主题的二进制传感器。
zway95/data/ZWayVDev_zway_9-0-48-12
{
"creationTime": 1587157138,
"creatorId": 1,
"customIcons": {},
"deviceType": "sensorBinary",
"firmware": "3.80",
"h": 1979762458,
"hasHistory": false,
"id": "ZWayVDev_zway_9-0-48-12",
"location": 3,
"locationName": "Коридор",
"manufacturer": "Shenzhen Neo Electronics Co., Ltd",
"metrics": {
"probeTitle": "Motion",
"scaleTitle": "",
"icon": "motion",
"level": "off",
"title": "Движение - Коридор",
"isFailed": false
},
"nodeId": 9,
"order": {
"rooms": 0,
"elements": 0,
"dashboard": 0,
"room": 2
},
"permanently_hidden": false,
"probeType": "motion",
"product": "",
"tags": [],
"technology": "Z-Wave",
"visibility": true,
"updateTime": 1643685077
}
zway95/state/ZWayVDev_zway_9-0-48-12
off
或
on
我HA也有这样的配置
binary_sensor:
- platform: mqtt
state_topic: "zway95/state/ZWayVDev_zway_9-0-48-12"
name: "testmotion"
device_class: "motion"
payload_on: "true"
payload_off: "false"
availability_template: "{{ value_json.metrics.isFailed }}"
availability:
- topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
payload_available: false
payload_not_available: true
json_attributes_topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
在 HA 中,传感器看起来不可用并且缺少属性
我哪里弄错了?
这是工作配置:
binary_sensor:
- platform: mqtt
state_topic: "zway95/state/ZWayVDev_zway_9-0-48-12"
name: "testmotion"
device_class: "motion"
payload_on: "on"
payload_off: "off"
availability_topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
availability_template: "{{ value_json.metrics.isFailed }}"
payload_available: false
payload_not_available: true
json_attributes_topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
我的理解是home assistant documentation availability_template
是为了和availability_topic
一起使用。所以要么去
availability_template: "{{ value_json['metrics']['isFailed'] }}"
availability_topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
payload_available: false
payload_not_available: true
或
availability:
- topic: "zway95/data/ZWayVDev_zway_9-0-48-12"
payload_available: false
payload_not_available: true
value_template: "{{ value_json['metrics']['isFailed'] }}"