I don’t get an error. The automation triggers ok, but it doesn’t turn off the sensors.
Group config is:
phone_display_on:
name: Phone Display On
entities:
- binary_sensor.sm_g970u_interactive
- binary_sensor.sm_s901b_interactive
The reason for all this, is that the interactive sensor in the companion app sticks at ‘on’ when I power off my phone at night, which stops other stuff triggering in the morning.
A binary_sensor (as far as I know) cannot be updated using Home Assistant services. This binary_sensor reflects the state of a device but you cannot change the state of the device by changing the binary_sensor…
Look at this post for a possible solution to “force” a sensor/binary_sensor to change its value:
Hmmm, thanks. What a hassle that looks like, cos I can set the binary sensor state in the UI.
Just thinking… maybe I should make a dummy input boolean and a trigger that updates it according to the binary sensor. Then I could at least switch the input boolean on and off as I need to.
Maybe take a step back. Why do you want a binary sensor to go off one minute after it goes on? What does the binary sensor represent? Maybe you could have a template binary sensor that goes on when a binary sensor goes on, then goes off one minute later.
Whole reason for this is that I have an automation that is triggered in a morning when the ‘interactive’ binary sensor on the companion android is turned on.
The interactive sensor directly relates to whether the phone screen is on or off. In a morning, I might look at my phone as soon as I wake up, if I do (or one of other other unrelated triggers fire), the automation starts a ‘waking up’ script that sorts other bits and bobs out.
Problem is… that if I decide to power off my phone when I go to bed, the interactive sensor never updates to say the screen is off - presumably because the app is terminated before it can turn off the sensor. So the sensor stays on all night, even though the phone screen is off (because I powered it off).
So I’m trying to get an automation to set the binary sensor to off, if it gets stuck at ‘on’ for a period of time. I set it to 1min just to test it, but in reality, I’ll set it to an hour.
Ok, I don’t use the companion app, so can’t help with that, but yeah, it sounds like an intermediary input_boolean can help here. I actually have a similar scenario with a Z-Wave multisensor. It’s motion sensor is represented by two sensor entities, and sometimes one of them gets “stuck” on for some reason. I’ve created an input_boolean that is turned on and off via an automation. It’s probably more than you need, but here’s what I have:
input_boolean:
hf_motion:
automation:
# binary_sensor.house_front_sensor and sensor.house_front_burglar will both
# generally change when motion is detected and no longer detected. However, not
# always. Sometimes only one changes to "on". Also, sometimes one of them will
# not go back "off" (until the next motion event.)
#
# To make sure we get one trigger event per motion event we can't simply "or"
# them. So instead we'll turn an input_boolean on whenever either indicates
# motion, and then back off whenever either of them stops indicating motion.
# We'll also turn off the input_boolean if either of the sensors gets "stuck"
# in the on state for too long.
- alias: HF Motion - On
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.house_front_sensor
to: 'on'
- platform: numeric_state
entity_id: sensor.house_front_burglar
above: 0
action:
- service: input_boolean.turn_on
entity_id: input_boolean.hf_motion
- alias: HF Motion - Off
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.house_front_sensor
to: 'off'
- platform: numeric_state
entity_id: sensor.house_front_burglar
below: 1
- platform: state
entity_id: binary_sensor.house_front_sensor
to: 'on'
for:
minutes: 30
- platform: numeric_state
entity_id: sensor.house_front_burglar
above: 0
for:
minutes: 30
action:
- service: input_boolean.turn_off
entity_id: input_boolean.hf_motion
- alias: HF Motion - Stuck Sensor
trigger:
- platform: state
entity_id: binary_sensor.house_front_sensor
to: 'on'
for:
minutes: 15
action:
- service: zwave.refresh_entity
# Must use data:, otherwise entity_id will be turned into a list,
# and zwave.refresh_entity only accepts a single entity_id.
data:
entity_id: binary_sensor.house_front_sensor
- service: persistent_notification.create
data:
message: House Front Sensor was stuck!
- alias: HF Motion - Stuck Burglar
trigger:
- platform: numeric_state
entity_id: sensor.house_front_burglar
above: 0
for:
minutes: 15
action:
- service: zwave.refresh_entity
# Must use data:, otherwise entity_id will be turned into a list,
# and zwave.refresh_entity only accepts a single entity_id.
data:
entity_id: sensor.house_front_burglar
- service: persistent_notification.create
data:
message: House Front Burglar was stuck!
Yep, I kind of thought of that, but I wrote my code years ago and haven’t bothered to update it. Also, I’m stuck on an old version of HA for some lame reasons. lol