Light Animation Add-On

Hey Keith. I’ve been after this, too. I can’t offer a pretty UI, but I did write a Pyscript module that implements a HA service for long-running Philips Hue-based animations. It comes with some pre-canned color/timing schemes, but you can add more by modifying a simple JSON-like structure embedded in the script.

I use this in combination with a Lovelace widget that lets me pick the room and the color scheme and start/stop the animation. (See below.) Note that this requires the Pyscript integration, which is available in HACS.

Screenshot_20210311_150642

2 Likes

That’s one way to handle it!

One issue is with Node-Red if I restart the container for an update or something I get knocked out of my loop.
I know I could add a input bool to check on startup maybe but it’s all so tiresome…

I’ll look at this later, like I said in our other chat if I could get something a bit more hands off going then I’d switch my bulbs over to deCONZ entirely.

The above is using the Hue integration in HA, not deCONZ.

I absolutely love your approach.
Installing pyscript and importing the script, works well.
But I’m struggling building the LoveLace and the scripts.
Maybe you could give me some help, getting this running?

Many thanks

The Lovelace widget is just a couple of input_select helpers and two scripts that call the pyscript.color_swarm_turn_on and pyscript.color_swarm_turn_off services, respectively. This is the YAML for it:

type: entities
entities:
  - entity: input_select.color_swarm_group
  - entity: input_select.color_swarm_name
  - entity: script.start_color_swarm
  - entity: script.stop_color_swarm
title: Color Swarm

The first input_select is a list of rooms/zones exactly as they appear in the Philips Hue app. The second is a list of color swarm names from the JSON file. Ideally, I’d populate both of these lists automatically, but I haven’t found a simple way to do that so I just update them manually. They don’t change very often.

The scripts are also simple. They just call the pyscript services. Here’s the start script:

service: pyscript.color_swarm_turn_on
data:
  hue_group_name: '{{ states.input_select.color_swarm_group.state }}'
  swarm_name: '{{ states.input_select.color_swarm_name.state }}'

And the stop script:

service: pyscript.color_swarm_turn_off
data:
  hue_group_name: '{{ states.input_select.color_swarm_group.state }}'

Note that starting a new color swarm in the same room will interrupt any previously running swarm so you don’t need to worry about conflicts. Good luck!

2 Likes

Thank you very much.
Everything is working great now.
I’ve added some ‘Northern Lights’ Scene to your script.

    "Northern Lights": {
        "transition_secs": 1,
        "max_hold_secs": 8,
        "palette": [
            {
                "rgb_color": (23, 35, 71),
                "brightness": 255,
            },
            {
                "rgb_color": (2, 83, 133),
                "brightness": 255,
            },
            {
                "rgb_color": (14, 243, 197),
                "brightness": 200,
            },
            {
                "rgb_color": (4, 226, 183),
                "brightness": 200,
            },
            {
                "rgb_color": (3, 132, 152),
                "brightness": 220,
            },
            {
                "rgb_color": (1, 82, 104),
                "brightness": 255,
            },            
        ],
    },    
3 Likes

Cool! I’m gonna try this out!

This looks like a really great idea. I have been using an Android app called Hue Pro that has a GUI for achieving similar effects in the same way by setting color, length of transition, brightness etc. However you have to let the android app run which is a huge downside.

Huh that stinks it needs to be running. IConnectHue really is cool, it all runs on the Hue bridge.

1 Like

Hi there

Since I updated HA to version 2021.12.4 the color-swarm script stopped working.
I got the error in the log:
This error originated from a custom integration.

Logger: custom_components.pyscript.file.color_swarm
Source: custom_components/pyscript/global_ctx.py:337
Integration: Pyscript Python scripting (documentation, issues)
First occurred: 12:20:20 PM (2 occurrences)
Last logged: 12:22:22 PM

Exception in </config/pyscript/color_swarm.py> line 7: from aiohue.bridge import Bridge ^ ModuleNotFoundError: No module named ‘aiohue.bridge’

Do you have any idea about that?
I didn’t have any success searching for the module ‘aiohue.bridge’

Many thanks…

Kind regards and Merry Christmas
Christoph

I was using the same script and ran into similar situation.
I manually installed the aiohue using the SSH & Web Terminal integration. I got it pre-compiled from https://pypi.org/project/aiohue/
Checking the aiohue repo I saw that they changed the functions structure, so I edited my scripts to update the calls.

#from aiohue.bridge import Bridge
from aiohue import HueBridgeV2
...
#bridge = Bridge(host, session, username=username)
bridge = HueBridgeV2(host, session, username=username)

Finally restarting HomeAssistant made the script available again.
Hope it works for you.

1 Like

So, in the past, I tried the hass-animated-scenes integration to control a group of Wiz bulbs I have around the exterior of my house with little success.

The colorswarm idea struck me as interesting, so I modified the existing pyscript so that it should (theoretically) work with any color changing bulb.

Instead of a room_id or whatever the param was, supply the script with an “area_id” param instead, which is obv. the area id of the area containing the lights you want to control.

This should also do away with the requirement for the aiohue library, as I’ve just hacked the device registry to supply area ID’s for entities when not present, which then lets us find all entities in the light domain which have the “hs” flag in supported color modes.

Mileage may vary, but it definitly works with my Wiz bulbs, so mission accomplished on my end.

Also, added a “Halloween” swarm, as this was my main goal in getting it working in the first place. :wink:

One more time. Now I’ve added a schedule function where I can define what times of the year I want what swarms to run, and then just define a routine that starts and stops the swarms at a specific time:

Does this still work for you? I am using the first built of 2023 of HA and it seems that due to some changes related to the configuration of bridge credentials it does no longer work. Did you perform some additional adjustments?

Not that I really mind the info, but I’m not overly interested in Color Swarm.
Can we move it to it’s own topic?
Perhaps this one?

It’d be good to keep the initial explanation of what it is and what it does but it’s not really what the topic is intended for, even though it’s dead.

1 Like

Sorry, I can’t confirm anymore as I’m not using this script for a long time now.

I’m going to bump this. I’m surprised there isn’t more interest in creating a way to automate colors and animations directly in Home Assistant.
I used to use iConnectHue but that’s limited to Hue lights and requires a Hue hub.
Here’s an example of what the UI looks like.
It’s pretty intuitive, just pigeonholed into the Hue ecosystem.

I use this one myself. It works very well and is not hue specific. It installs with HACS.

Here are the “presets” that it supports to whichever lights you target.

1 Like

Thanks a lot! I’ll take a look later.

So am i, the demand must be kinda big? Im using Hypfers custom component and have started making a view with presets. Unfortunately they are bound to specific lights. So much better if i could choose what lights or group of lights i wanna start the scene on and then just pick the scene of my choice. Maybe it’s not that hard to fix something like that?