Hi! I’m trying to configure switch (id_relay
) that will be turned off automatically after few seconds. Exact time depends on relay will be turned on via service (then after period specified by duration
variable) or manually (then after period specified by g_overtime_default
). Below is simplified configuration, but rest is not important now. It works fine for manual on (changing state of id_relay
from HA), but unfortunately after calling service turn_on
, the on_turn_on
trigger is called and switch is turned off after g_overtime_default
period. Is it possible to call id(id_relay).turn_on
without executing on_turn_on
trigger? Or any workaround?
globals:
- id: g_overtime_default
type: int
restore_value: yes
initial_value: '10'
- id: g_overtime_current
type: int
restore_value: no
initial_value: '0'
api:
services:
- service: turn_on
variables:
overtime: int
then:
- lambda: |-
id(g_overtime_current) = overtime;
id(id_relay).turn_on;
- service: turn_off
then:
- lambda: |-
id(g_overtime_current) = 0;
id(id_relay).turn_off;
switch:
- id: id_relay
name: id_relay
platform: gpio
pin: GPIO12
on_turn_on:
then:
- lambda: |-
id(g_overtime_current) = id(g_overtime_default);
on_turn_off:
then:
- lambda: |-
id(g_overtime_current) = 0;