Hat3
(Hat3)
December 5, 2022, 11:47am
1
Hello everybody,
I have and esphome with this:
binary_sensor:
- platform: gpio
pin:
number: GPIO32
mode: INPUT_PULLUP
inverted: False
name: "Ingresso1"
id: ingresso1
- platform: gpio
pin:
number: GPIO33
mode: INPUT_PULLUP
inverted: False
name: "Ingresso2"
id: ingresso2
And an automation on HA like this:
alias: Toggle luce ingresso1
description: ""
trigger:
- type: turned_on
platform: device
device_id: 2081ba6b59d7ef7e067a1535cb2cc120
entity_id: binary_sensor.ingresso1
domain: binary_sensor
- type: turned_off
platform: device
device_id: 2081ba6b59d7ef7e067a1535cb2cc120
entity_id: binary_sensor.ingresso1
domain: binary_sensor
- type: turned_on
platform: device
device_id: 55eda31c2c13273b5d67df85e9ccdde3
entity_id: binary_sensor.ingresso1_2
domain: binary_sensor
- type: turned_off
platform: device
device_id: 55eda31c2c13273b5d67df85e9ccdde3
entity_id: binary_sensor.ingresso1_2
domain: binary_sensor
condition: []
action:
- type: toggle
device_id: 15752ce8270ff436092087ed22486dda
entity_id: switch.ingresso1
domain: switch
mode: restart
I don’t understand why after e restart of esp the trigger is triggered by esp.binary_sensor,
Someone have any idea?
Because the binary sensor state changed from unavailable
to on
or off
which then triggers your automation
You can actually just look at the binary sensor history to see that
Quick fix might just to use something like:
from: 'off'
to: 'on'
and vice-versa in your automation
1 Like
Hat3
(Hat3)
December 5, 2022, 4:06pm
3
Thank you, for the suggestion about logbook
Hat3
(Hat3)
December 5, 2022, 4:15pm
4
The sequence is:
beginning:
Ingresso1 turned off
esp restart:
Ingresso1 became unavailable
esp come online:
Ingresso1 turned off
Triggered:
Toggle luce ingresso1 triggered by state of Ingresso1 turned off
The issue is in the automation:
action:
- type: toggle
device_id: 15752ce8270ff436092087ed22486dda
entity_id: switch.ingresso1
domain: switch
Troon
(Troon)
December 5, 2022, 4:27pm
5
The issue is in your triggers, not your action. I don’t like the unnecessarily-complicated device trigger syntax you’re using (from the UI, I assume), so to implement @orange-assistant ’s suggestion above, I’d use:
trigger:
- platform: state
entity_id: binary_sensor.ingresso1
from: 'off'
to: 'on'
…and similarly for the other sensors. This will not react to changes from unavailable
to on
.
1 Like
Hat3
(Hat3)
December 5, 2022, 4:39pm
6
I can’t do that…
im stupid and i called for 3 esphome that control the light of ingresso the same name… so i need to specify the device id
i’ll change the name in all 3 esp…
Hat3
(Hat3)
December 5, 2022, 5:10pm
7
Now itis working correctly, thank you @Troon
alias: Ingresso1 state change
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.cameras_ingresso1
- binary_sensor.cucina_ingresso1
- binary_sensor.studio_ingresso1
from: "on"
to: "off"
- platform: state
entity_id:
- binary_sensor.cameras_ingresso1
- binary_sensor.cucina_ingresso1
- binary_sensor.studio_ingresso1
from: "off"
to: "on"
condition: []
action:
- type: toggle
device_id: 15752ce8270ff436092087ed22486dda
entity_id: switch.ingresso1
domain: switch
mode: single
1 Like