I am trying to make automation in ESPhome but I can’t get it working. I need 2 switches and a binary sensor. If I turn on switch1 and the binary sensor is off i need to turn on switch 2 for 1s and then turn it off. I tried with script and with custom component but I cannot get timers and MQTT to work with the custom component so I just give up on that option. Can anyone help with that? I use Arduino IDE usually but I need this in esphome now.
Post your attempt
1 Like
I found why my automations wasn’t working. I used binary sensor but pin isn’t going to 3.3V which I forgot and I will change it to adc and it will work.
switch:
- platform: gpio
pin: 15
name: "PC2"
id: pc2
on_turn_on:
then:
if:
condition:
binary_sensor.is_on: pcstate
then:
- logger.log: "Done"
else:
if:
condition:
binary_sensor.is_off: pcstate
then:
- switch.turn_on: pc1
- delay: 1s
- switch.turn_off: pc1
on_turn_off:
then:
if:
condition:
binary_sensor.is_on: pcstate
then:
- switch.turn_on: pc1
- delay: 1s
- switch.turn_off: pc1
- platform: gpio
pin: 14
name: "pc1"
id: pc1
binary_sensor:
- platform: gpio
pin: A0
name: "pcState"
id: pcstate