I’m currently flashing some Shelly 1 devices (wall mount relay ESP based: https://shelly.cloud/shelly1-open-source/
I’m going to use one to replace a traditional relay that was controled by multiple “impulsive” buttons wired in parallel. As I’m replacing it with an “intelligent” device I’d like to add an auto-off feature. If light keeps more than 3 minutes on, switch it off automatically.
Here is the code I wrote but it doesn’t want my delay part of code whatever if I put in switch part or in output part. What am I doing wrong ?
Side question: is the delay cancelled and actions in it cancelled if state goes back off ? to avoid false triggers if there is multiple ON in a short time !
Solved nearly the problem (out of the timer that I would need to cancel if switch goes off to avoid multiple delayed timer in case of multiple on/off in a short time !, so still looking for a way to do that correctly !).
While trying to figure out a solution, I think I’m nearly done with it but have a syntax problem here and I have checked in doc but it looks fine so if anyone has an idea what’s the problem ? It complains on the script_stop line and for the if
ERROR Error while reading config: while parsing a block collection in "/config/esphome/Escaliers.yaml", line 31, column 9 expected <block end>, but found '?' in "/config/esphome/Escaliers.yaml", line 33, column 9
In fact as indicated in my original message the two errors triggered are on the script.stop line and on the if ! If I do the change you suggest by tabbing the if and subsequent lines I get then that new error so not sure it’s really the way to correct the errors no ?
INFO Reading configuration...
Failed config
binary_sensor.gpio: [source /config/esphome/Escaliers.yaml:24]
platform: gpio
pin:
number: GPIO5
name: Bouton Escaliers
on_press: [source /config/esphome/Escaliers.yaml:29]
then: [source /config/esphome/Escaliers.yaml:30]
- script.stop:
id: script_minuterie
Cannot have two actions in one item. Key 'switch.toggle' overrides 'if'! Did you forget to indent the block inside the action?.
- [source /config/esphome/Escaliers.yaml:31]
switch.toggle: relay
if:
condition:
switch.is_on: relay
then:
- script.execute: script_minuterie
As I didn’t succeed to find out if problem was again with f*cking yaml syntax or if I was trying to do something not possible in esphome logic, I rewrote it in a different way and now it works perfect (no risk of retrigger in case of fast multiple on/off
If someone wants to include it in cookbook of ESPHome, feel free to go Checked how to do that but gosh so complicated so gave up on it