Is it possible to trigger an automation on a button press on the Philips Hue dimmer switch, instead of state?
I have this automation, that turns fluxer off if some one dims the light with the remote:
- id: 'turn_off_fluxer_when_manual_light_adjust'
alias: Turn off fluxer when manual light adjustment
initial_state: true
trigger:
- platform: state
entity_id:
- sensor.philips_hue_dimmer_switch
to: '2_click_up'
- platform: state
entity_id:
- sensor.philips_hue_dimmer_switch
to: '3_click_up'
condition:
- condition: state
entity_id: switch.fluxer
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.fluxer
And this works as intended, but not when the same button is pressed as the current state. Is there a way to trigger on button press and not state? or is there another way to do this?
The automation above only works when state is changed. So if the remote (sensor.philips_hue_dimmer_switch) is in state â2_click_upâ and fluxer (switch.fluxer) is on and i press the button for dim up the state is the same and the automation will not run. But if i press the button for dim down the state change to â3_click_upâ and it works. If the current state is â3_click_upâ the opposite donât trigger this automation.
So that is not really family friendly, because they donât know the current state. So if they press the button and nothing happens then they are not happy
So my current workaround is that when you want to manually change the lights (dim up or down), then you press the dim up button and then dim down button, then you can manually change the lights because that will always trigger this automation.
Thanks for your suggestions. I only have hue dimmer switches.
I started writing my first python script and then i noticed something, so i did some changes to automation and it works now.
- id: 'turn_off_fluxer_when_manual_light_adjust'
alias: Turn off fluxer when manual light adjustment
initial_state: true
trigger:
- platform: state
entity_id:
- sensor.philips_hue_dimmer_switch
to: '2_click'
- platform: state
entity_id:
- sensor.philips_hue_dimmer_switch
to: '3_click'
condition:
- condition: state
entity_id: switch.fluxer
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.fluxer
State 2_click_up is when button is released and state 2_click is on button pressed. So i changed the automation to trigger on click and not click_up and now it works.
BUT this means that using state 2_click_up should also works because when current state is 2_click_up and i press the button it changes to 2_click (for a short moment) and when i release button state changes to 2_click_up. So i tested this again and it also works.
So i donât know why it didnât work the first time, but now it works (both variants of this automation) and i have learned something new. So thanks for your input, it got me on the right path.
Forgot to say that to get this switches working in HA iam using 0.7 of this Hue-sensors-HASS custom component.
Iâve been experimenting with this and as far as I can see âx_clickâ captures a press and long hold on the switch while âx_click_upâ captures the switch being released which ends with the state as up.
As the state always has to end âupâ, if you long hold (itâs not very long but it is a clear press and hold not just click), youâll capture that state change from âclick_upâ to just âclickâ and can therefore capture a repeated press on the same switch.
This dost seem to be reliably working for me, sometimes the switch will report #_click and sometimes the state wont change but the last update time in the attributes section will. Thought this was going to be a simple fix
Is it possible for an automation to read the lust update tom and activate when it changes?
After some more research and trial and error I have worked out how to make the hue dimmer switch rock solid (sorry If this was obvious to some people but it wasnât to me).
To use the hue dimmer switch with home assistant (and the fantastic Hue sensors HASS component) in an automation a trigger should not be used to detect the state of the switch but a condition. This solves the issue of the state being the same for two subsequent button pushes as the trigger simply looks for any call from the switch to home assistant then the condition checks to see what button was pressed. Here is a photo of how a hue dimmer switch should be set up in an automation.
I am very, very new to HA. I have used the robmarkcole code in my configuration. I now can see my dimmer switches but I do not have a clue on how to set up the buttons to work my various smart home items in HA. Please direct me to a step by step understanding on what I need to put in automations, script and/or configurator to use more functionality of my dimmer switches!!