Hello. Help. write automation. We have 2 buttons to open the gate with different ids (car1), (Car2) and two person s. it is necessary to determine who arrived or left and on what. Considering that the status home or not_home is determined after a few minutes. ChatGPT and I have already broken our heads
To start with, forget about ChatGPT.
Could you show us what you’ve got so far? Please paste it into your post as preformatted text (</> in the cogwheel menu) - difficult to read otherwise.
description: ""
trigger:
- type: turned_on
platform: device
device_id: b3a91a4df41bce4fc58dd83a13a66d74
entity_id: befddc5898490592fed0f26c8b4799a9
domain: binary_sensor
id: Suzuki
- type: turned_on
platform: device
device_id: b3a91a4df41bce4fc58dd83a13a66d74
entity_id: d2bfa41074ec12923425fc2c24a137e1
domain: binary_sensor
id: Volga
condition: []
action:
- wait_for_trigger:
- platform: state
entity_id: person.timurlan75
from: not_home
to: home
id: Timur_home
- platform: state
entity_id: person.timurlan75
from: home
to: not_home
id: Timur-not_home
- platform: state
entity_id: person.chingiz
from: not_home
to: home
id: Chingiz_home
- platform: state
entity_id: person.chingiz
from: home
to: not_home
id: Chingiz-not_home
timeout:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
continue_on_timeout: true
- choose:
- conditions:
- condition: trigger
id: Suzuki
- condition: state
entity_id: person.timurlan75
state: home
- condition: trigger
id: ""
sequence:
- service: notify.family_telegram
data:
message: Тимур arrived on Suzuki
- conditions:
- condition: trigger
id: Suzuki
- condition: state
entity_id: person.timurlan75
state: not_home
sequence:
- service: notify.family_telegram
data:
message: Тимур left on Suzuki
- conditions:
- condition: trigger
id: Volga
- condition: state
entity_id: person.timurlan75
state: home
sequence:
- service: notify.family_telegram
data:
message: Тимур приехал на Volga
- conditions:
- condition: trigger
id: Volga
- condition: state
entity_id: person.timurlan75
state: not_home
sequence:
- service: notify.family_telegram
data:
message: Тимур уехал на Volga
- conditions:
- condition: trigger
id: Suzuki
- condition: state
entity_id: person.chingiz
state: home
sequence:
- service: notify.family_telegram
data:
message: Чингиз приехал на Suzuki
- conditions:
- condition: trigger
id: Suzuki
- condition: state
entity_id: person.chingiz
state: not_home
sequence:
- service: notify.family_telegram
data:
message: Чингиз left on Suzuki
- conditions:
- condition: trigger
id: Volga
- condition: state
entity_id: person.chingiz
state: home
sequence:
- service: notify.family_telegram
data:
message: Чингиз arrived on the Volga
- conditions:
- condition: trigger
id: Volga
- condition: state
entity_id: person.chingiz
state: not_home
sequence:
- service: notify.family_telegram
data:
message: Чингиз left on Volga
mode: single
Wow!
Well, the first question is… what are the devices triggering the automation? You describe them as buttons, but the automation describes them as binary sensors. If they are buttons, they won’t have an on/off state. What are their entity ids?
id “suzuki” and “volga” are RF remote control buttons for gates. it’s just esphome that’s how they’re written.
OK. So they are binary sensors then.
What’s going on here?
- choose:
- conditions:
- condition: trigger
id: Suzuki
- condition: state
entity_id: person.timurlan75
state: home
- condition: trigger
id: ""
There seems to be an extra condition that will never be met.
These are the consequences of experiments. it doesn’t matter . I need a way to connect these events.
- conditions:
- condition: trigger
id: Suzuki
- condition: trigger
id: Timur_home
will that work?
I don’t know. Press the button!
Since you’ve been using ChatGPT, I assume you’re writing this in yaml.
The best advice at this point is to start again using the UI editor, and use the state of the button entity_ids as the trigger, not device_ids. You should end up with something like:
trigger:
- platform: state
entity_id:
- binary_sensor.car1
from: "off"
to: "on"
id: suzuki
- platform: state
entity_id:
- binary_sensor.car2
from: "off"
to: "on"
id: volga
Using the UI you will be warned about errors when you try to save. You can then start running the automation and looking at traces (again in the UI) to make sure the logic is doing what you want it to.
So far I have come up with the idea of creating an “auxiliary switch” that will switch the remote control buttons and it will be in the Volga Suzuki position. and trigger events at home, not at home. the disadvantage is that if the person “leaves on foot”, he will still write “left”