Hi everybody,
I am trying to create a few automations that only run when two people are not at home. However, I cannot seem to create the right template for this. This is my test package
I added comments to the code rather then describing what I need beforehand… problem is, both device_trackers work fine, but the binary_sensor will always be true
.
# This sensor is supposed to be true/on when both people are home and false/off when either of them are away
binary_sensor:
- platform: template
sensors:
beide_home:
friendly_name: "Beide Home"
value_template: >
# this SHOULD return true when both are home and false otherwise, but will always return true
{% if states('device_tracker.ben_galaxys9') + states('device_tracker.jonna_honor10') %}
true
{% else %}
false
{% endif %}
# perhaps it'd be better to do this the other way round? Return true when both are NOT at home and false if EITHER is home?
# This doesn't do anything productive yet; just sends a notification if both parties have been back home for 10 minutes or have been gone for 30 minutes (so that I will get feedback to test). I have not implemented the actual things that are supposed to happen yet because I need the basics to work first.
automation:
- id: "beide_home_false"
alias: "[Anw] Beide != Home"
trigger:
- platform: state
entity_id: binary_sensor.beide_home
from: "off"
to: "on"
for: 00:10:00
action:
- service: notify.ben
data:
message: "🧪 Ihr seid beide seit 10 Minuten wieder zu Hause 🧪"
- id: "beide_home_true"
alias: "[Anw] Beide = Home"
trigger:
- platform: state
entity_id: binary_sensor.beide_home
from: "on"
to: "off"
for: 00:30:00
action:
- service: notify.ben
data:
message: "🧪 Ihr seid beide seit 30 Minuten nicht mehr zu Hause 🧪"
I thought creating a binary_sensor would be best so that I don’t have to include BOTH devices to be not_home
whenever I want an automation to trigger, but rather just “ask” the binary_sensor whether or not they are both gone or if one of them is home.
The planned automations do things like regulating the temperature, so they must not be triggered when one of the two is at home.
Thank you for your ideas