Can someone please help me with 3 more automations?

I think the Sonoff’s R5 Scene Controller is a state less device. I mean when I press a button on my R5 it shows in the log as “Main Bedroom R5 changed to button_3_single
7:43:07 AM - 2 hours ago”.
But when I pressed the same button again, it just shows “Main Bedroom R5
7:43:08 AM - 2 hours ago”.
Although I have used the same button on my R5 to toggle switch & it successfully toggles the switch even if I single press the desired button once & then again within the next 2-3 seconds if I press the same button again, it succesddfully toggles the switch again.


scrsht3

Go to Developer Tools > States and observe how the state value of sensor.sonoff_bedroomr5 changes when you press the button.

When I press any button on my R5 it shows the exact button that I pressed & then it disappears.
Example when I Single Press the Button 3 on my R5, it shows button_3_single for a second then the state goes blank. BTW it is being able to detect each button single press within 1.5s of each press.

Create an Input Select containing the names of the colors want:

  • red
  • blue
  • green
  • white

Then create the following automation:

alias: color changer
trigger:
  - platform: state
    entity_id:
      - sensor.sonoff_bedroomr5
    to: button_3_single
condition: []
action:
  - service: light.turn_on
    data:
      color_name: "{{ states('input_select.colors') }}"
      brightness_pct: 100
    target:
      device_id: bedroomled
  - service: input_select.select_next
    target:
      entity_id: input_select.colors

EDIT

Correction. Added missing quote.

1 Like

I’m unable to create input_select because there is no input select option under Helpers. I checked my configuration.yaml file & it has default_config:
But because i was not seeing the input select option under the helpers; i searched online & it said that if it was deleted them i should add input_select: to my yaml file. I did that & checked the config and restarted. But i still can’t see the input select. Attaching screenshot of the helper section.


It’s the one called “Dropdown” in the Helpers menu.

For reasons unknown to me, some Helpers are named differently in the UI from their documented integrations. :man_shrugging:

1 Like

Oh. Thanks for pointing that out. BTW using the code worked for me. Another thing the code that you posted has a small mistake;
color_name: "{{ states(input_select.colors') }}"
It should be;
color_name: "{{ states('input_select.colors') }}"
I want to ask another thing is there any way to assign each color different brightness level. Example: Red at 80%, Green at 60%, Blue at 40%, etc.?

Corrected.

Yes, but it changes the automation significantly. Are there any other features you want to add because it’s more efficient (for me) to know all of the requirements in advance.

1 Like

No more extra features. I just want to be able to assign cutom brightness level to indivisual colors.

Create an Input Select containing the names of the colors you want and their brightness level in JSON format.

{"c": "red", "b": 80}
{"c": "blue", "b": 60}
{"c": "green", "b": 40}
{"c": "white", "b": 20}

Then create the following automation:

alias: color changer
trigger:
  - platform: state
    entity_id:
      - sensor.sonoff_bedroomr5
    to: button_3_single
condition: []
action:
  - variables:
      x: "{{ states('input_select.colors') | from_json }}"
  - service: light.turn_on
    data:
      color_name: "{{ x.c }}"
      brightness_pct:  "{{ x.b }}"
    target:
      device_id: bedroomled
  - service: input_select.select_next
    target:
      entity_id: input_select.colors

NOTE

If you prefer to use rgbw values instead of color names, I can show you how to modify the automation to support it.

Yeah sure. Please tell me how to use rgbw values too.

The value of the c key is now a list (not a string like for color name) containing the desired rgbw values.

{"c": [255, 0, 0, 0], "b": 80}
{"c": [0, 255, 0, 0], "b": 60}
{"c": [0, 0, 255, 0], "b": 40}
{"c": [0, 0, 0, 255], "b": 20}

The light.turn_on service call uses the rgbw_color option (instead of color_name).

alias: color changer
trigger:
  - platform: state
    entity_id:
      - sensor.sonoff_bedroomr5
    to: button_3_single
condition: []
action:
  - variables:
      x: "{{ states('input_select.colors') | from_json }}"
  - service: light.turn_on
    data:
      rgbw_color: "{{ x.c }}"
      brightness_pct:  "{{ x.b }}"
    target:
      device_id: bedroomled
  - service: input_select.select_next
    target:
      entity_id: input_select.colors

Thanks. BTW this post is solved. But there are 3 different automations that were solved. So which one should i select as the solution? Or you want to create one final post including all the three automations, so that i can select it as the solution?

Any one of the three is fine; I suggest you select the third one.

1 Like

1. Increment/decrement temperature

mode: single
trigger:
  - platform: state
    entity_id:
      - sensor.sonoff_mainbedroomr5
    to: button_1_single
action:
  - service: climate.set_temperature
    data:
      temperature: "{{ state_attr('climate.bedroom', 'temperature') | float(21) + 1 }}"
    target:
      entity_id: climate.bedroom

2. Restore light to previous state

action:
  - service: scene.create
    data:
      scene_id: before
      snapshot_entities: light.bedroom
  - service: light.turn_on
    data:
      rgbw_color:
        - 255
        - 0
        - 0
        - 0
      brightness_pct: 30
    target:
      entity_id: light.bedroom
  - delay: '00:00:10'
  - service: scene.turn_on
    target:
      entity_id: scene.before

3. Cycle through colors and brightness

Input Select configuration:

{"c": [255, 0, 0, 0], "b": 80}
{"c": [0, 255, 0, 0], "b": 60}
{"c": [0, 0, 255, 0], "b": 40}
{"c": [0, 0, 0, 255], "b": 20}

Automation:

alias: color changer
trigger:
  - platform: state
    entity_id:
      - sensor.sonoff_bedroomr5
    to: button_3_single
condition: []
action:
  - variables:
      x: "{{ states('input_select.colors') | from_json }}"
  - service: light.turn_on
    data:
      rgbw_color: "{{ x.c }}"
      brightness_pct:  "{{ x.b }}"
    target:
      device_id: bedroomled
  - service: input_select.select_next
    target:
      entity_id: input_select.colors
1 Like

Hi. I am reviving this as i face the same issue, and the shelly integration still does not let you handle the RGBW2 like a simple LED…

I am unclear where I would need to put this array?
The Helper is not accessible via YAML or any other editor.
Or what am I missing?

Also is there a way to extract the values from a color wheel?
I find it in particular frustrating that the frontend in HA gives you a color way but no way to adress it within an automation.