Yeah, thanks for making me aware! Can’t wait to get home from work again
Okay, I deleted the previous created scenes and created new ones with the lights off. GET of /scenes shows that they are in place.
But now the option “Aus” is not working anymore. This is in the logs:
2019-09-25 16:09:18 ERROR (MainThread) [homeassistant.components.script] Error executing script script.set_hue_scene. Unknown error for call_service at pos 1:
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/script/init.py”, line 209, in async_turn_on
await self.script.async_run(kwargs.get(ATTR_VARIABLES), context)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 162, in async_run
await self._handle_action(action, variables, context)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 246, in _handle_action
await self._actions[_determine_action(action)](action, variables, context)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 329, in _async_call_service
context=context,
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 98, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context
File “/usr/src/homeassistant/homeassistant/core.py”, line 1234, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File “/usr/src/homeassistant/homeassistant/core.py”, line 1259, in _execute_service
await handler.func(service_call)
File “/usr/src/homeassistant/homeassistant/components/hue/bridge.py”, line 156, in hue_activate_scene
await group.set_action(scene=scene.id)
File “/usr/local/lib/python3.7/site-packages/aiohue/groups.py”, line 80, in set_action
json=data)
File “/usr/local/lib/python3.7/site-packages/aiohue/bridge.py”, line 64, in request
_raise_on_error(data)
File “/usr/local/lib/python3.7/site-packages/aiohue/bridge.py”, line 78, in _raise_on_error
raise_error(data[‘error’])
File “/usr/local/lib/python3.7/site-packages/aiohue/errors.py”, line 39, in raise_error
raise cls(“{}: {}”.format(type, error[‘description’]))
aiohue.errors.AiohueException: 7: invalid value, L8L88zy2Ecyild3, for parameter, scene
“Aus” is spelled the same in Home Assistant and the Hue bridge, including upper / lower case. Appearantly it doesn’t like my scene…?
Nevermind, I restartet Home Assistant and the Hue Bridge and now it works.
added this in my Buttons setup, to replace the Tiles cards, now showing as:
needs some further tweaking, (move many of the styles bits to the templates, add some background maybe), but get the idea…
type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: custom:button-card
template: horizontal-filler
- type: 'custom:button-card'
name: Set Hue scene
template: button_default_title
- type: custom:button-card
template: horizontal-filler
- type: horizontal-stack
cards:
- type: custom:button-card
template: horizontal-filler
- type: custom:button-card
template: button_picture_script_small
name: Arctic
entity_picture: '/local/hue_scenes/arctic.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Arctische dageraad'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Arctische dageraad'
]]]
color: '#00d0a0'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: button_picture_script_small
name: Savanna
entity_picture: '/local/hue_scenes/savanna.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Savanne zonsondergang'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Savanne zonsondergang'
]]]
color: '#ff7935'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: button_picture_script_small
name: Tropic
entity_picture: '/local/hue_scenes/tropical.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Tropische schemering'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Tropische schemering'
]]]
color: '#a03aa3'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: button_picture_script_small
name: Spring
entity_picture: '/local/hue_scenes/spring.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Lentebloesem'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Lentebloesem'
]]]
color: '#ba496c'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: horizontal-filler
- type: horizontal-stack
cards:
- type: custom:button-card
template: horizontal-filler
- type: custom:button-card
template: button_picture_script_small
name: Relax
entity_picture: '/local/hue_scenes/relax.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Ontspannen'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Ontspannen'
]]]
color: '#ffc059'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: button_picture_script_small
name: Read
entity_picture: '/local/hue_scenes/lezen.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Lezen'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Lezen'
]]]
color: '#fdfb9f'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: button_picture_script_small
name: Concentr
entity_picture: '/local/hue_scenes/concentrate.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Concentreren'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Concentreren'
]]]
color: '#a2eaf2'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: button_picture_script_small
name: Energy
entity_picture: '/local/hue_scenes/energize.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Energie'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Energie'
]]]
color: '#a8dfed'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: horizontal-filler
- type: horizontal-stack
cards:
- type: custom:button-card
template: horizontal-filler
- type: custom:button-card
template: button_picture_script_small
name: Clear
entity_picture: '/local/hue_scenes/clear.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Helder'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Helder'
]]]
color: '#fcdb97'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: button_picture_script_small
name: Dimmed
entity_picture: '/local/hue_scenes/dimmed.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Gedimd'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Gedimd'
]]]
color: '#8c642b'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: button_picture_script_small
name: Night
entity_picture: '/local/hue_scenes/nightlight.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Nachtlampje'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Nachtlampje'
]]]
color: '#814346'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: button_picture_script_small
name: 'Off'
entity_picture: '/local/hue_scenes/off.png'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: 'Off'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state === 'Off';
]]]
color: 'lightgrey'
styles:
name:
- color: '#555B65'
- operator: default
color: '#555B65'
styles:
name:
- color: '#F0C209'
- type: custom:button-card
template: horizontal-filler
- type: custom:button-card
template: horizontal-divider-grey
- type: horizontal-stack
cards:
- type: entities
# title: Hue set scenes
show_header_toggle: false
entities:
- input_select.hue_groups
- script.set_hue_scene
- type: custom:button-card
template: vertical-filler
It appears that the “Off” scene created with CLIP is working with Hue groups that are rooms, but not with areas. Thats a problem as I often want to turn off lights i.e. on the upper floor, including all rooms.
I just created a intent script / script for Snips that can differentiate if we want a scene or “Off” and run the appropriate service. That way it becomes completely unnecessary to create “Off” scenes on the bridge. I created the same for this scene selector:
set_hue_scene:
alias: HUE Szene wählen
sequence:
- service_template: >
{% if states("input_select.hue_scenes") == "Aus" %}
script.licht_aus
{% elif states("input_select.hue_scenes") == "An" %}
script.licht_an
{% else %}
script.setze_szene
{% endif %}
data_template:
temp_group: '{{ states("input_select.hue_groups")}}'
temp_scene: '{{ states("input_select.hue_scenes")}}'
setze_szene:
alias: Szene setzen
sequence:
- service: hue.hue_activate_scene
data_template:
group_name: '{{ temp_group }}'
scene_name: '{{ temp_scene }}'
licht_aus:
alias: Licht aus
sequence:
- service: light.turn_off
data_template:
entity_id: light.{{ temp_group | lower }}
licht_an:
alias: Licht an
sequence:
- service: light.turn_on
data_template:
entity_id: light.{{ temp_group | lower }}
As you can see “On” is also working, of course.
In my Snips script I also extended this with brightness and color. Can be done here, too you will just need two more inputs. Didn’t make sense to me, but it’s possible.
Attention: For the room / area names to work with HA I had to make them lower case (| lower), Might be possible that this won’t work for room or area names including spaces (because in HA they will be named “bla_blub” instead of “bla blub”). Will test that later. If failing, spaces need to be replaced by _ in addition to making it lower case.
Because i am new user (a few days ago install HA) and happen to had Hue system, i find this Project very interesting.
Could you help me to install it in my occasion?
Running Hassio in Docker at Ubuntu 19.04 (Laptop).
Just i copy all of the codes that you supply and paste them at configuration.yaml ? Because when i did it i receive a lot of errors at Notifications.
HI, Since we had a Pm discussion, I take it you are addressing this to me ?
Not really sure what you mean by casting all the code into configuration.yaml, but that is not what you should do…
Also which notifications are you talking about?
just so we are clear on the code (it has been renewed because of the move from Tiles to Button custom card (which you need to have installed as resources for Lovelace)) Ill repost it here:
the Lovelace setup (so this is not intended to go into the configuration.yaml…):
type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: custom:button-card
template: horizontal-filler
- type: 'custom:button-card'
name: Set Hue scene
template: button_default_title_fixed
- type: custom:button-card
template: horizontal-filler
- type: horizontal-stack
cards:
- type: custom:button-card
template: horizontal-filler
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: 'Arctische dageraad'
- entity_picture: '/local/hue_scenes/arctic.png'
- name: Arctic
- color: '#00d0a0'
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Savanne zonsondergang
- entity_picture: '/local/hue_scenes/savanna.png'
- name: Savanna
- color: '#ff7935'
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Tropische schemering
- entity_picture: '/local/hue_scenes/tropical.png'
- name: Tropic
- color: '#a03aa3'
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Lentebloesem
- entity_picture: '/local/hue_scenes/spring.png'
- name: Spring
- color: '#ba496c'
- type: custom:button-card
template: horizontal-filler
- type: horizontal-stack
cards:
- type: custom:button-card
template: horizontal-filler
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Ontspannen
- entity_picture: '/local/hue_scenes/relax.png'
- name: Relax
- color: '#ffc059'
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Lezen
- entity_picture: '/local/hue_scenes/lezen.png'
- name: Read
- color: '#fdfb9f'
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Concentreren
- entity_picture: '/local/hue_scenes/concentrate.png'
- name: Concentr
- color: '#a2eaf2'
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Energie
- entity_picture: '/local/hue_scenes/energize.png'
- name: Energy
- color: '#a8dfed'
- type: custom:button-card
template: horizontal-filler
- type: horizontal-stack
cards:
- type: custom:button-card
template: horizontal-filler
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Helder
- entity_picture: '/local/hue_scenes/clear.png'
- name: Clear
- color: '#fcdb97'
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Gedimd
- entity_picture: '/local/hue_scenes/dimmed.png'
- name: Dimmed
- color: '#8c642b'
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: Nachtlampje
- entity_picture: '/local/hue_scenes/nightlight.png'
- name: Night
- color: '#814346'
- type: custom:decluttering-card
template: set_hue_scene
variables:
- option: 'Off'
- entity_picture: '/local/hue_scenes/off.png'
- name: 'Off'
- color: 'lightgrey'
- type: custom:button-card
template: horizontal-filler
# - type: custom:button-card
# template: horizontal-divider-grey
- type: horizontal-stack
cards:
- type: custom:button-card
template: horizontal-filler
- type: entities
show_header_toggle: false
entities:
- input_select.hue_groups
- script.set_hue_scene
- type: custom:button-card
template: horizontal-filler
- type: custom:button-card
template: vertical-filler
and the decluttering template set_hue_scene
:
card:
type: custom:button-card
template: button_picture_script_small
entity_picture: '[[entity_picture]]'
name: '[[name]]'
tap_action:
action: call-service
service: script.tiles_set_hue_scene
service_data:
option: '[[option]]'
state:
- operator: template
value: >
[[[
return states['input_select.hue_scenes'].state == '[[option]]'
]]]
color: '[[color]]'
styles:
name:
- color: '#555B65'
and, the button_picture_script_small button card template:
button_picture_script_small:
size: 70%
show_state: false
show_label: false
show_name: true
show_entity_picture: true
color_type: card
aspect_ratio: 1/1
tap_action:
action: none
haptic: light
hold_action:
action: more-info
haptic: success
color: '#555B65'
styles:
name:
- padding-left: 3px
- font-weight: bold
- font-family: Helvetica
- font-size: 13px
- color: 'lightgrey'
now this of course also expects some Homeassistant backend code I am afraid…
script:
set_hue_scene:
alias: 'Set Hue scene'
sequence:
service: hue.hue_activate_scene
data_template:
group_name: >
{{ states('input_select.hue_groups')}}
scene_name: >
{{ states('input_select.hue_scenes')}}
tiles_set_hue_scene:
alias: 'Tiles set Hue scene'
sequence:
service: input_select.select_option
entity_id: input_select.hue_scenes
data_template:
option: >
{{ option }}
and the input_selects which need the exact names as in the Hue system, in my setting:
input_select:
hue_scenes:
name: Select Hue Scenes
icon: mdi:creation #palette
options:
- Arctische dageraad
- Savanne zonsondergang
- Tropische schemering
- Lentebloesem
- Concentreren
- Gedimd
- Energie
- Helder
- Lezen
- Nachtlampje
- Ontspannen
- 'Off'
initial: Ontspannen
hue_groups:
name: Select Hue Group
icon: mdi:group
options:
- Buffet
- Dining table
- Living
- Living ceiling 1 Cds
- Living ceiling 2 Terrace
- Living ceiling 3 Wall
- Living ceiling 4 Sofa
- Hall
- Corridor
- Master bedroom
- Mobile
for the groups you just select your own named groups like the above.
Also, you’ll need the pictures, let me know if you have these.
Seems i need to understand a few more stuff over the HomeAssistant platform before start installing it.
Ty for replay will try to set it up.
hi there,
Is there a way to adapt your code for lights other than hue.
Thank you very much for you help.
well, this is a thread for Hue scenes, using Hue lights, in Hue groups…
not sure what you would want to adapt tbh.
Hi Marius,
I guess I need to do this script in lovelace yaml? Do I also need to add things in the configuration file of the backend? I would also need the pictures to fix this
Could you help me with this?
which script do you want ‘to do in lovelace yaml’? scripts are done in the backend, they are merely displayed in the Lovelace frontend. Depending on your setup of course.
This is what I now have:
We can help you if you post what you have yourself, so we can go from there.
Thanks for posting this. This looks just what I’m looking for to finish off my Living Room controller. A couple of questions;
How do I get the horizontal and vertical filler template?
Can you share your icons as well?
I’m trying to add this but I keep getting the error: horizontal-filler is missing. Where do I add this?
horizontal-filler is nothing more than an empty button card to fill put the edges. I no longer use these and have the edges touched by the button-cards.
same goes for the vertical-filler, which I still use to create some space before the next card.
I was just asking since I keep getting errors when adding button card templates. I added my resources in the configuration file like this:
lovelace:
mode: yaml
resources: !include lovelace/resources/resources.yaml
I have the set_hue_scene and tiles_set hue_scene scripts added, with the input selects. They work fine.
this at the top of my ui-lovelace.yaml
button_card_templates:
button_picture_script_small:
size: 70%
show_state: false
show_label: false
show_name: true
show_entity_picture: true
color_type: card
aspect_ratio: 1/1
tap_action:
action: none
haptic: light
hold_action:
action: more-info
haptic: success
color: ‘#555B65’
styles:
name:
- padding-left: 3px
- font-weight: bold
- font-family: Helvetica
- font-size: 13px
- color: ‘lightgrey’
And I keep getting the error that a template is missing
That’s correct if you don’t have it added under the button card templates
nothing more than this:
vertical-divider-grey:
color_type: blank-card
styles:
card:
- color: dimgray
- width: 2px
horizontal-filler:
color_type: blank-card
styles:
card:
- width: 3px
vertical-filler:
color_type: blank-card
styles:
card:
- height: 3px
so I added this, but still getting the same error. Not sure what I’m doing wrong. Seems like the I have it at the wrong spot or something
no templates are being found.
You need to set the place where you save them in your config. Check the instructions on button-card repo