I’m trying to create an automation that turns on one of three automations and the other two are turned off on a button press, cycling to the next at each button press.
Button pushed: once automation 1 is on, automations 2 and 3 are turned off
Button pushed again : automation 2 is turned on on and 1 and 3 are turned off
…
And then it cycles round.
I know that it’ll involve input_select.select_next. But I’m a bit confused about how to use it in an automation.
It’s basically to get multiple uses out of a single button.
So the goal is to make the rotary switch serve three separate functions?
The input_select has three options where each option represents one of the rotary switch’s three functions?
Pressing the button steps through the input_select’s options?
If the answer is ‘Yes’ to all three questions then your requirements can be easily achieved without turning automations on/off. One automation can be used to step through the input_select’s options whenever the button is pressed. Another automation is triggered by the rotary switch and controls the appropriate device depending on the input_select’s current selection.
That’s two automations and neither are turned on/off to achieve the goal.
That would be perfect and much cleaner than my solution, I was just grasping at straws to how I could do it and landed on turning automations on and off.
Which Zigbee integration are you using to receive data from the IKEA Rotary Switch? ZHA, deCONZ, or Zigbee2MQTT?
The one you use will determine the configuration of the Event Trigger in each of the two automations.
I assume that when you press the IKEA Rotary Switch, it should step from one operating mode to another? Or will you be using another kind of switch to do that?
You will need to modify the names of its entities to match the ones you have.
sensor.your_ikea_rotary
input_select.modes
media_player.amplifier
light.kitchen
light.living_room
It also requires you create an input_select with three options:
Amplifier
Kitchen Light
Living Room Light
You will need to modify the option names to what you prefer (and update the names used in the automation accordingly).
For now, you can manually change the input_select to test the automation. After the automation is modified, tested, and confirmed to work properly, we can create the second automation to make a button-press step through the input_select’s options.
NOTE
In case the automation’s operation is unclear, here’s is pseudo-code explaining how it works:
trigger:
When the rotary switch is rotated
action:
Choose which direction it rotated:
1. It rotated left (decreased)
Choose which entity to control:
1. input_select is set to Amplifier
Decrease amplifier's volume
2. input_select is set to one of the two lights:
Decrease the light's brightness
2. It rotated right (increased)
Choose which entity to control:
1. input_select is set to Amplifier
Increase amplifier's volume
2. input_select is set to one of the two lights
Increase the light's brightness
Invalid config for [automation]: not a valid value for dictionary value @ data[‘action’][1][‘choose’][0][‘sequence’][0][‘choose’][1][‘sequence’][0][‘target’][‘entity_id’]. Got None. (See /config/configuration.yaml, line 35).
But I assume that’s because the option setup is not done yet.
I can change names later when I get a hang on how input_select works. Is my config correct in relation to your automation because I’m still getting an error when I manually set the state.
Also, I’m not sure if brightness_move_up/down are used. This is the log entry when I rotate the switch :
Am getting all sorts of syntax errors and can’t get your code through without errors no matter what I do to indentation or formatting, I think it’s related to you not using a hyphen on your code (- id) where mine is indented and the syntax of the conditions and formatting is too complicated for me to get my head around to fix.
I had assumed you were using the “simulated_brightness” feature described in the documentation. However, your configuration publishes the payload in JSON format with a brightness value so that will require a different approach to receive it.
If you have a sensor.ikeaswitch_brightness already then I believe the automation will simply need to use a State Trigger (instead of an Event Trigger). In addition, only one choose is required.
It’s difficult for me to determine why you’re experiencing that. The revised automation I just posted passes Check Configuration on my system and executes without generating errors.
The original version I posted was meant to be pasted into the Automation Editor in YAML mode. If you create your automations with a text editor then, yes, you must include a hyphen on the automation’s first line. That’s what I’ve done in the revised version of the automation.
I am using simulated brightness since that is the only way to get smooth operation of the dimmer, I assumed that I’d need to use the same entity_id here that I was referencing in my simple on mode dimmer operation since that worked.
I’ve pasted the above in text editor and since you kindly changed the entities for me I’ve made no changes. Unfortunately I’m still getting the automation error :
Invalid config for [automation]: not a valid value for dictionary value @ data[‘action’][1][‘choose’][1][‘sequence’][0][‘target’][‘entity_id’]. Got None. (See /config/configuration.yaml, line 35).
That’s a syntax error right?
Is this related to my input_select configuration? I was unsure whether mode: “{{ states(‘input_select.modes’) }}” refers to the name with the colon (modes:) or the name after name.
modes: #< here
name: modes #< or here
options:
- Amplifier
- Living room light
- Kitchen light
Unless you actually have light.front and light.back entities, it’s the likely cause of the error message.
Also, the values of the options in your input_select must exactly match the strings used in the template. For example, the template looks for “amplifier” (all lowercase):
conditions: "{{ mode == 'amplifier' }}"
However, in your latest post, you have defined it as “Amplifier” in the input_select. In your previous post, you defined it as “amplifier”. Whichever way you want it, you will have to ensure the template uses the correct spelling.
modes: #< here <<<<------- Always this one when referring to it in a template.
name: modes #< or here. <<<<------ This is just for display in the Lovelace UI.
options:
- Amplifier
- Living room light
- Kitchen light
I’ve checked capitalisations and they’re the same now, Amplifier lost its capital somewhere along the way, light.front and light.back are the correct names for two of my bulbs.
Now I know why I could not replicate the problem and why it doesn’t work for you:
You changed the automation and introduced an error.
Question: Where in your automation is the variable switchoption defined?
Answer: Nowhere and that’s why your modified automation fails.
You have to understand the increased difficulty of providing assistance when you make changes that you don’t reveal publicly. That’s why I asked you to post your automation because I suspected as much.
In this line:
mode: "{{ states('input_select.switchoption') }}"
Replace the word “mode” with “switchoption” so that the variable is defined for use elsewhere in the template.