sure, glad if you would, thanks
I can’t replicate the warning message you received.
Tested with 2021.11.1.
input_select:
stub:
name: Stub
options:
- 'stub'
This automation successfully sets options for input_select.stub
on startup without generating a warning message.
## Test setting an input_select's options on startup.
- alias: Set Stub Options
id: set_stub_options
trigger:
- platform: homeassistant
event: start
action:
- service: input_select.set_options
target:
entity_id: input_select.stub
data:
options: "{{ expand('group.battery_level') | map(attribute='name') | list }}"
I’m not familiar with this event type: delayed_homeassistant_start
.
In my automation, I replaced:
- platform: homeassistant
event: start
with:
- platform: event
event_type: delayed_homeassistant_start
and the automation failed to run after a restart.
the event is a custom event:
- alias: Run at startup
id: Run at startup
trigger:
platform: homeassistant
event: start
action:
- service: script.notify_startup
- delay:
seconds: >
{{states('input_number.ha_delayed_startup')|int}}
- event: delayed_homeassistant_start
after which you can do:
- alias: Run at delayed startup
id: Run at delayed startup
trigger:
platform: event
event_type: delayed_homeassistant_start
action:
- service: script.notify_delayed_startup
- service: input_boolean.turn_off
entity_id: input_boolean.just_started
- service: script.run_after_delayed_startup
for the options, I added a bit of a hack:
input_select:
hue_group_v2:
name: Select Hue group
options:
- Alarm
Alarm being one of my Hue groups, so that will always be there and wont cause any startup template issues.
Amazing you don see the warning, even though the ‘stub’ isnt in you options list… Now I need to take a step back.
thanks a bunch for being so thorough, truly appreciated!
did take out the relative_time out of the secondary: template:
secondary: >
{% set object = states('input_select.hue_group_v2')|lower|replace(' ','_')%}
{% set group = 'light.' + object %}
{% set bri = state_attr(group,'brightness') %}
{% set rgb = state_attr(group,'rgb_color') %}
{% if states(group) == 'on' %} Bri: {{bri}}, Rgb: {{rgb}}
{% else %} Off {% endif %} since {{relative_time(states[group].last_changed)}}
because that too gives startup warning I can not mitigate. And there’s no way I can think of a default value to add.
I left this experiment with input_select on my test system. While restarting the system for other reasons, this appeared:
So it can happen but why I don’t know.
apparently thats what happens when the Template is evaluated. you probably wont see that if you use the Family Battery Level as option in the input_select config.
that’s better:
homeassistant:
customize_glob:
scene.*concentreren:
entity_picture: /local/hue_scenes/concentreren.png
scene.*arctische_dageraad:
entity_picture: /local/hue_scenes/arctische_dageraad.png
scene.*energie:
entity_picture: /local/hue_scenes/energie.png
scene.*gedimd:
entity_picture: /local/hue_scenes/gedimd.png
scene.*helder:
entity_picture: /local/hue_scenes/helder.png
scene.*herfstgoud:
entity_picture: /local/hue_scenes/herfstgoud.png
scene.*lentebloesem:
entity_picture: /local/hue_scenes/lentebloesem.png
scene.*lezen:
entity_picture: /local/hue_scenes/lezen.png
scene.*nachtlampje:
entity_picture: /local/hue_scenes/nachtlampje.png
scene.*ontspannen:
entity_picture: /local/hue_scenes/ontspannen.png
scene.*savanne_zonsondergang:
entity_picture: /local/hue_scenes/savanne_zonsondergang.png
scene.*tropische_schemering:
entity_picture: /local/hue_scenes/tropische_schemering.png
with @petro 's help:
for some amazing templating power in the auto-entities card:
filter:
template: |
{% set select = states('input_select.hue_group_v2')|lower|replace(' ','_') %}
{% set ns = namespace(ret=[]) %}
{%- for s in states.scene
if select == s.object_id.split('_')[:-1]|join('_') or
select == s.object_id.split('_')[:-2]|join('_') %}
{% set ns.ret = ns.ret + [{"entity":s.entity_id,
"name": s.object_id.split(select +'_')[1]|capitalize|replace('_',' ') }] %}
{%- endfor %}
{{ ns.ret }}
taken me some time, but finally made the template not throw startup warnings:
secondary: >
{% set x = ['unknown','unavailable'] %}
{% if states('input_select.hue_group_v2') not in x %}
{% set object = states('input_select.hue_group_v2')|lower|replace(' ','_')%}
{% set group = 'light.' + object %}
{% set bri = state_attr(group,'brightness') %}
{% set rgb = state_attr(group,'rgb_color') %}
{% if states(group) == 'on' %} Bri: {{bri}}, Rgb: {{rgb}}
{% else %} Off
{% endif %} since {{relative_time(states[group].last_changed) if (states[group]
and states[group].last_changed not in x) else 'Initializing....'}}
{% else %} Not yet set
{% endif %}
be sure to refresh the frontend with the new template a couple of times, because if you dont, the warnings/errors will persist over restarts.
I’m probably missing something incredibly obvious … but how do I get access to the new V2 API stuff? I assume it’s in some form of beta testing?
I was literally about to start trying to figure out how to write a bunch of code to do things that it sounds like the new the integration will give me for free, which would obviously be amazing .
It’s in the 2021.12 beta release. At this point, you may as well wait for 2021.12.0 which is due to be released today (December 11).
So is there some more documentation about this new way of using scenes in 2021.12? The Hue integration page does not contain much extra info. I have a similar sort of setup where I have a input_select with all the scene names and a Node RED flow that loops through it when holding down a switch. I’m wondering how to change this now that we have individual entities for all scenes.
not sure what more than the above you would need? simply click one of the scenes and it activates. You can also call them directly in script/automations.
I have a strange effect, when I activate a Hue scene an automation or the developer tools section (Home Assistant 2021.12.3).
If activated like this:
service: scene.turn_on
target:
entity_id: scene.livingroom_relax
… the scene is properly activated, but after a few minutes it starts cycling through all the colors in the scene. That is like pressing the (newly introduced?) “play” symbol on the scene in the Hue App.
So how can I activate a Hue scene without it starting to “play”?
Just tested in development tools with the same configuration and everything works fine, stable without color transitions.Test 30 minutes
I just noticed that some scene’s in the Hue App don’t have the “play” button once you activate them (most of the standard/default scenes, but strangely enough not all of them).
So these will not cycle through the colors, when activated from Home Assistant.
You may also not notice the cycling if the colors of the scene are similar or the dynamic cycle speed is set to a low value.
Could you try one that does have the “play” button and has many colors and a high cycling speed set?
(you can set this by changing the scene details, after pressing the “pencil” button)
Yes you’re right. If a scene that contains playback is used, playback starts immediately after the scene is activated.
Default HUE scenes have this behavior if they have multiple colors. If I create my own scene, it works as expected because it doesn’t have playback.
This behavior doesn’t happen with the, now being depreciated, old way of calling Hue scenes using the hue.hue_activate_scene method.
In fact, I now see in the developer tools it has an optional V2-API boolean parameter “dynamic” that you can give to activate the dynamic behavior.
IMO it appears that this parameter is missing in the current scene.turn_on command, or a default behavior where this is not activated.
Yes it works, but you get a warning in the log.
Use of service_call 'hue_activate_scene' is deprecated and will be removed in a future release. Please use scene entities instead
I assume that in the new V2 way of calling the scene it will be fixed because now I could consider it a mistake. But if that’s not the expected behavior?
Good news: I wanted to open an issue on GitHub about this, but just found out it is already being worked on, with default behavior being not to activate the dynamic scenes:
Philips Hue v2 When using scene entities dynamic is always set to true · Issue #61554 · home-assistant/core · GitHub
Conclusion: for the short term you can still use the hue_activate_scene (with warnings) while for the permanent fix in scene.turn_on this will be fixed in the next major release next year.
Thank you for the information.