Trying to setup a binary sensor to represent motion based on a MQTT payload. I’m sure it’s something I’m missing, but here’s my sensor definition in configuration.yaml
mqtt:
binary_sensor:
- name: driveway_mus_motion
unique_id: driveway_mus_motion
device_class: motion
state_topic: "zoneminder/1"
value_template: "{{ 'ON' if value_json.eventtype == 'event_start' else 'OFF'}}"
off_delay: 120
enabled_by_default: false
Here’s my raw jason:
{
"name": "Driveway (MUS):(32687) Linked",
"detection": [],
"eventtype": "event_start",
"hookvalue": "1",
"eventid": "32687",
"monitor": "1",
"state": "alarm"
}
So, what happens right now is that the trigger for ON seems to work, but when the state is Unlown, it shows as ON in the icon. So, what I’m looking for is, if the topic doesn’t exist, or the payload doesn’t match either because “eventtype” doesn’t exist or is a different value, that the sensor is in an OFF state. The “off_delay” only seems to work when the sensor was set into the ON state. The “enabled_by_default” seems to do nothing.
1 post - 1 participant