Change color of Hue lamp every hour

Hi,

is it possible to change the color of one hue lamp each hour randomly between two times?

Regards

Is this not possible or does nobody knows how it works?

Might not be the most eloquent way to do it, but…

Using the random sensor you can create a value between 0 and 255. Then place those values in the rgb color for the automation which will change every hour.

sensor:
  - platform: random
    minimum: 0
    maximum: 255

Automation:
  trigger: 
    platform: time
    hour: '/1'
  condition: time
  after: '15:00:00'
  before: '23:00:00'
  action:
    service: homeassistant.turn_on
    entity_id: light.example
    data:
      rgb_color: [states.sensor.random,states.sensor.random,states.sensor.random]

I think that will return the same value for each of the RGB colors as I don’t know how often the random sensor refreshes. To get around this you may be able to add 3 random sensors. Keep in mind that you may not always get a color you want, pure white or colors that look very close to white are an option and 0,0,0 (black) would also be an option if they came up randomly.

Thx for your help. I copy and paste it in my config file but got an error message

16-11-14 22:36:02 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: [hour] is an invalid option for [automation]. Check: automation->trigger->0->hour. (See /home/htpc/.homeassistant/automation.yaml:6). Please check the docs at Automation - Home Assistant

Any ideas about the error?

I assumed hour would be supported, sorry. Try replacing that line with…

minutes: 1

Tried that allready. If i change it, i got the next error message

16-11-14 22:54:01 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: expected a dictionary @ data[‘condition’][0]. Got None
extra keys not allowed @ data[‘after’]. Got {}
extra keys not allowed @ data[‘before’]. Got {}. (See /home/htpc/.homeassistant/automation.yaml:6). Please check the docs at Automation - Home Assistant

What is the entity id of your random sensor? It may not be sensor.random.

Check out this post

@silvrr
It is. I copy your code in my configuration.yaml. Depending on the docs the default name is random. So it have to be.

If your sure the entity ID is right then Im guessing HA doesn’t like the way is used state.sensor.random. May need to adjust the code a bit. Sorry don’t have any RGB lights to test on.

I know this is an old thread, but to save hours of time for anybody finding this thread in the future, presuming it is definitely Hue, the answer here is to use the ‘effect: random’ option instead of ‘rgb_color’…

Correct code:

Automation:
  trigger: 
    platform: time
    [...your interval here]
  condition: time
  [..your conditions]
  action:
    service: homeassistant.turn_on
    entity_id: light.example
    data:
      effect: random
      brightness: 255

Note that the brightness option is not required, or can be templated, but not using it will set the brightness of the lights to their previous setting before the automation was run, so if that was very dim, so will this effect.

Hope this helps.

1 Like

As a beginner in the home assistant world, I find it hard to find out what data can be passed.
The built in Developer Tools > Services doesn’t list the effect and brightness options: “No description is available”

@anon43302295 How did you know about this?

If you look at the doc page for any of the light platforms like Philips Hue for instance, you should see a link on the upper right for the Lights component itself:

Here you’ll see all the options that the light platforms support. It’s the same with other platforms as well; if you go to the Pushbullet platform as an example, you’ll see a similar link for the Notification component which gives you additional information including what options are there, what data can be passed and how.

Once you get used to it, the docs are laid out pretty well.

1 Like