Different actions for switch clicks

Looking for help,
I am relatively new to Home Assistant, but learn a lot from this forum.
I am stuck with a problem though. I have a xiaomi switch that I use to turn light on and off, now I’d like to use the double click feature to lower and rasise brightness of the bulb. So if I double-click the brightness goes to 125 and if I double-click again, it goes back up to full brightness 250. How to I go about doing that?

Thanks, Siento

I’m pretty new to HA too so there are probably better ways to do this but using 2 automations should work.

Automation 1;
initial_state: ‘off’
Set the brightness to 125 and toggle automation 1 and automation 2

Automation 2;
initial_state: ‘on’
Set the brightness to 250 and toggle automation 1 and automation 2

As I said there may be a better way but that should work.

I kinda get it. 2 automations with 2 different brightness settings. But hw do I toggle between the 2 automations?

Only one of them will be active at a time. The initial_state will set which one is active when home assistant starts up and each automation would call the automation.toggle service on both automations to switch which one is currently active. I’m not currently at a computer so I’m afraid I can’t really type it out at the moment but I’ll try and post something later.

Hey Cain
it would be great to see an example, because I’ve been trying for hours now, and still don’t get it :slight_smile:

Thanks

I just created this in the automation editor;

- action:
  - data:
      brightness: '250'
      entity_id: light.lounge_lamp
    service: light.turn_on
  - data:
      entity_id: automation.double_click_bright
    service: automation.turn_off
  - data:
      entity_id: automation.double_click_dim
    service: automation.turn_on
  alias: double_click_bright
  condition: []
  id: '1516150479187'
  trigger:
  - event_data:
      click_type: double
      entity_id: binary_sensor.switch_158d0001714111
    event_type: click
    platform: event


- action:
  - data:
      brightness: '125'
      entity_id: light.lounge_lamp
    service: light.turn_on
  - data:
      entity_id: automation.double_click_dim
    service: automation.turn_off
  - data:
      entity_id: automation.double_click_bright
    service: automation.turn_on
  alias: double_click_dim
  condition: []
  id: '1516150479188'
  trigger:
  - event_data:
      click_type: double
      entity_id: binary_sensor.switch_158d0001714111
    event_type: click
    platform: event

and it seems to be working like you wanted.

Just change the light and button entity_id’s.

Thanks mate,

Doesn’t exactly work as intended, but I think it’s because of conflicts with other automations.
Anyways, now I have some thing to start with and I’ll work out the kinks - so thanks for getting me this far

Siento

No problem, you’ll notice I used automation.turn_on and automation.turn_off rather than automation.toggle. This was because I couldn’t set the initial_state using the automation editor, it obviously does the same thing.

Hi Cain, I am looking to do something similar but struggling a little.

I have LED lights that can go dimmer with each on off toggle, there are 4 settings for the light, so 1, 2, 3 and 4 on off cycles to change the bright/dim of these lights. I am looking to set up a switch for each of these settings, they will automatically cycle the switch to the correct on/off setting value (1,2,3,4 on/off cycles).

Hope that makes sense :slight_smile: