1mfaasj
(Bowa)
March 14, 2024, 10:28am
1
Hi
I’ve got 2 light bulbs in my living room, which I want to light on both at the moment the (physical) lamp button is pressed.
But the problem I have is that the automation triggers twice, when pushing one of the two lamp buttons.
Is there a way to solve this?
Because now I have to press the button twice, physically, to see enabling both light bulbs. That’s why I configured the Shelly devices first and then Hue, but I’m not sure this is best practice.
One note: both light bulbs have a Shelly device behind the buttons, and both have a Hue bulb.
alias: Light bulbs living room buttons On
description: ""
trigger:
- platform: state
entity_id:
- switch.shellyeettafellampknop
- switch.shellywoonkamerlampknop
from: "off"
to: "on"
id: "1"
condition: []
action:
- if:
- condition: state
entity_id: switch.shellyeettafellampknop
state: "off"
then:
- type: turn_on
device_id: f1e8f510ad14049da00b939d51e0874f
entity_id: b3b7c89f7963f545f030ed3fb7a9719d
domain: switch
enabled: true
- if:
- condition: state
entity_id: switch.shellywoonkamerlampknop
state: "off"
then:
- type: turn_on
device_id: bc78fb09efb103a6933aae0aa723ef4a
entity_id: 4c88ff3da2c18cae103ffebd241ad042
domain: switch
- service: light.turn_on
data:
color_temp: 500
brightness_pct: 100
target:
device_id:
- 3fa16a522e51ed71372f19b5ba58e1b8
- 47378b359391d12b879b289eb6b7aebf
mode: single
max_exceeded: silent
tom_l
March 14, 2024, 10:40am
2
Can you do us a favour and rewrite your automation actions to use service calls with entity_ids (switch.turn_on
) rather than device actions?
Then we could tell what switches you are actually turning on/off. Rather than these meaningless numbers:
I’m guessing one of those is also used in your triggers, but without entity_ids it is impossible to say for sure.
1mfaasj
(Bowa)
March 14, 2024, 10:46am
4
Thanks for the suggestion. Are service calls more best practice than using device calls?
But the device names on top are indeed the same devices as mentioned by ID at the end of the automation
Troon
(Troon)
March 14, 2024, 10:57am
6
You have two lamps and two lamp buttons. What do you want to happen?
The automation is (as I think you know) doing what it is told: you press one of the buttons which triggers it, it then “presses” the other button which triggers it again.
Are you wanting to operate both lamps from either button?
1mfaasj
(Bowa)
March 14, 2024, 11:04am
7
When I press one of the two lamp buttons, it should enable both bulbs
When the bulbs are on and I push one of the buttons again, both bulbs should go off.
Thats it basicly
@Troon
1mfaasj
(Bowa)
March 14, 2024, 11:46am
8
are you sure this works?
I get the message
Message malformed: Integration ‘timer’ does not provide trigger support
Troon
(Troon)
March 14, 2024, 11:50am
9
1mfaasj:
are you sure this works?
It doesn’t, no idea where that’s come from. It’s not in the docs and doesn’t make sense as a trigger. Ignore.
1 Like
Troon
(Troon)
March 14, 2024, 11:56am
10
OK, and the problem here is that the automation is pressing the other button for you, forcing a re-trigger.
Replace your empty condition block with a condition that blocks re-triggering for a couple of seconds:
condition:
- "{{ now()|as_timestamp - state_attr('automation.ENTITY_ID', 'last_triggered')|as_timestamp > 2 }}"
Substitute in the correct entity ID for the automation, possibly automation.light_bulbs_living_room_buttons_on
.
petro
(Petro)
March 14, 2024, 12:02pm
11
They just need a ‘follow me’ automation. Their automation needs some debouncing.
- alias: Light bulbs living room buttons On
id: dkjsiofuozneahtosihasiodfu
trigger:
- platform: state
entity_id:
- switch.shellyeettafellampknop
- switch.shellywoonkamerlampknop
variables:
entities:
- switch.shellyeettafellampknop
- switch.shellywoonkamerlampknop
state_list:
- 'on'
- 'off'
continue: >
{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
to_state: >
{{ trigger.to_state.state | default(none) if continue else none }}
targets: >
{{ entities | reject('eq', trigger.entity_id) | reject('is_state', to_state) | list if continue else [] }}
condition:
- condition: template
value_template: "{{ continue and to_state in state_list and targets | count > 0 }}"
action:
- service: switch.turn_{{ to_state }}
target:
entity_id: "{{ targets }}"
I ripped this from one of my old automations that works fine with a few updates
condition:
- condition: template
value_template: "{{ continue and to_state in ['on','off'] }}"
action:
- service: switch.turn_{{ to_state }}
target:
entity_id:
- switch.basement_cans
- alias: Toggle - Deck String Lights
id: toggle_deck_string_lights
trigger:
- platform: state
entity_id: &deck_string_entities
- switch.deck_mood_lighting
- switch.patio_string_light
variables:
entities: *deck_string_entities
state_list:
- 'on'
There are blueprints that do this too.
clarky860
(Alistair Clark)
March 15, 2024, 8:44am
12
Apologies, I will be more diligent next time