I’m trying to create a binary sensor with multiple or conditions. I don’t get any errors when reloading the config, but something isn’t right because the sensor status is stuck on unknown. Each condition works as an individual sensor.
- binary_sensor:
name: Person Detected
off_delay: 90
state_topic: "frigate/events"
value_template: |-
{{ if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'dahua' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'front' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'rear' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'reolink' and value_json['after']['score'] | float >= 0.7) }}
- binary_sensor:
name: Person Detected
off_delay: 90
state_topic: "frigate/events"
payload_on: true
payload_off: false
value_template: >
{{ if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'dahua' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'front' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'rear' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'reolink' and value_json['after']['score'] | float >= 0.7) }}
Or:
- binary_sensor:
name: Person Detected
off_delay: 90
state_topic: "frigate/events"
value_template: >
{{ 'ON' if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'dahua' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'front' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'rear' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'reolink' and value_json['after']['score'] | float >= 0.7) else 'OFF' }}
I’ve changed to the on/off setup, but the status is still unknown
- binary_sensor:
name: Person Detected
off_delay: 90
state_topic: "frigate/events"
value_template: >
{{ 'ON' if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'dahua' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'front' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'rear' and value_json['after']['score'] | float >= 0.7)
or if (value_json['after']['label'] == 'person' and value_json['after']['camera'] == 'reolink' and value_json['after']['score'] | float >= 0.7) else 'OFF' }}