I’m trying to use this for some toilet occupancy sensors (thanks Covid) in our bar. the sensors work great and the ping sensor is accurate, however I can only get one of the sensor templates to work reliably ,the other one seems to just flick between on/off constantly. I wonder if I have to define the two sensors differently?
sensor:
- platform: time_date
display_options:
- 'date_time'
input_number:
motion_sensor_idle_secs:
name: Motion Sensor Idle Seconds
initial: 130
min: 10
max: 3600
step: 1
binary_sensor:
- platform: ping
host: 192.168.2.62
count: 1
scan_interval: 1
name: ping_tuya_motion_sensor_gents_toilet
- platform: template
sensors:
ping_tuya_motion_sensor_gents_toilet:
friendly_name: "Gents Toilet Motion Sensor Alarm"
value_template: >-
{{ as_timestamp(states.sensor.date_time.last_changed) - as_timestamp(states.binary_sensor.ping_tuya_motion_sensor_gents_toilet.last_changed) < states('input_number.motion_sensor_idle_secs')|int }}
- platform: ping
host: 192.168.2.61
count: 1
scan_interval: 1
name: ping_tuya_motion_sensor_ladies_toilet
- platform: template
sensors:
tuya_motion_sensor_ladies_toilet:
friendly_name: "Ladies Toilet Motion Sensor Alarm"
value_template: >-
{{ as_timestamp(states.sensor.date_time.last_changed) - as_timestamp(states.binary_sensor.ping_tuya_motion_sensor_ladies_toilet.last_changed) < states('input_number.motion_sensor_idle_secs')|int }}