for an alternative, see my earlier post here on how to auto-populate those
Thank you for answering.
I have seen your post now, and I must say your work is most impressive! Hats off to you.
What card you use to set up this?
But your scripts seems to populate an input select box that lists ALL lights that has Hue Scenes connected to them.
But how do I alter the template to list the scenes ONE light only?
This is because I have one card per room and therefor need scenes for that one room.
If I understand this correctly, it needs to be done in 2 rounds:
First use the light entity_id to find all hue scenes connected to that light and create a list.
And then use that list to find the scene entity_idâs for those scene into another list. And that list can be used to populate the auto-entities card?
Sorry for the stupid AF questions
You might not even need a template if I read your requirements.
Just add an area and if you want, the integration on domain scene. I do that in my rooms and works perfectly.
These are embedded the custom slider
I might have forgotten to mention I did customize all scenes to have their respective entity_picture
A bit off topic, but how did you get the images for all the Hue Scenes?
The actual image files I mean.
I made them
Iâve also posted that in the linked topic. every time the Hue app has new scenes, I make a png for those and set them in customize
Iâm struggling with calling a rest_command as a tap_action for an auto-entities entity.
While the template works fine for the display part (âprimary:â), the rest_command leads to the following error logged:
Template variable warning: âidâ is undefined when rendering 'ID={{ id }}'
The problem seems to be the line:
id: '{{ state_attr(entity, ''index'') }}'
For test purposes I used a constant (id: â17â) and this worked as expected.
Any suggestions?
This is the complete card:
type: custom:auto-entities
card:
square: false
columns: 1
type: grid
show_empty: false
card_param: cards
filter:
include:
- entity_id: input_text.xenia_script_*
options:
type: custom:mushroom-template-card
entity: this.entity_id
primary: '{{ state_attr(entity, ''name'') }} [{{ state_attr(entity, 'index') }}]'
tap_action:
action: call-service
service: rest_command.execute_xenia_script
service-data:
id: '{{ state_attr(entity, ''index'') }}'
sort:
method: entity_id
Are you sure that an input_text entity has an indes attribute?
although I am not familiar with the mushroom-template-card, I suspect your issue has to do with the quoting, which looks painful to my eyesâŚ
youâd help yourself a lot if youâd use multiline notation, and be done with all of these double single quotes.
As you state the primary works ( it uses 'index'
) , so single single quotes, youâd probably need to use that in the secondary too (now using double single quotes ''index''
)
this would probably make it work:
- entity_id: input_text.xenia_script_*
options:
type: custom:mushroom-template-card
entity: this.entity_id
primary: >
{{ state_attr(entity, 'name') }} [{{ state_attr(entity, index) }}]
tap_action:
action: call-service
service: rest_command.execute_xenia_script
service-data:
id: >
{{ state_attr(entity, index) }}
if index
is in fact a variable name. If it is an attribute, the question dibbler raises, youâd need to single quote them. that would be surprising though, given: Input Text - Home Assistant, and would have to been set via customize or some other option. Unless that would be some hidden option in either of the cards/integrationsâŚ
Sorry, youâre right regarding the quoting. This somehow was messed up while copying over to here.
Itâs currently in like this:
id: '{{ state_attr(entity, 'index') }}'
index is an attribute and currently already correctly interpreted for âprimaryâ in displaying the attribute value.
Repeating the currently used quoting in HA:
type: custom:auto-entities
card:
square: false
columns: 1
type: grid
show_empty: false
card_param: cards
filter:
include:
- entity_id: input_text.xenia_script_*
options:
type: custom:mushroom-template-card
entity: this.entity_id
primary: '{{ state_attr(entity, 'name') }} [{{ state_attr(entity, 'index') }}]'
tap_action:
action: call-service
service: rest_command.execute_xenia_script
service-data:
id: '{{ state_attr(entity, 'index') }}'
sort:
method: entity_id
but now you are having issues with the yaml, as the interpreter can not separate the correct strings. as is clearly displayed in the coloring
if you insist on using single lines, than use double outer quotes and single inner quotes.
its like that with all yaml, everywhere.
Chaging it to multiline notation, but the rest_command has still the same error:
Template variable warning: âidâ is undefined when rendering âID={{ id }}â
type: custom:mushroom-template-card
entity: this.entity_id
primary: |
{{ state_attr(entity, 'name') }} [{{ state_attr(entity, 'index') }}]
tap_action:
action: call-service
service: rest_command.execute_xenia_script
service-data:
id: |
{{ state_attr(entity, 'index') }}
that would be the outcome if you pasted the template in dev tools template, and replace entity
with an actual entity_id?
besides all of that, could it be the rest_command expects an entity_id, instead of an attribute only? this would make your challenge probably be rather Off topic for auto-entities.
DevTools - Templates â
This delivers the correct result:
{{ state_attr(âinput_text.xenia_script_17â, âindexâ) }} â 17
This provides âUndefinedError: âinput_textâ is undefinedâ:
{{ state_attr(input_text.xenia_script_17, âindexâ) }}
BUT quoting entity in primary: leads to an error.
In the mean time I also experimented with:
id: |
{{ states.this.entity_id.attributes.index }}
But the error log still lists the same error.
This is the rest_command:
execute_xenia_script:
url: "http://xenia.local/execute_script"
method: POST
payload: "ID={{ id }}"
content_type: "application/x-www-form-urlencoded"
this is all very odd. the second version is wrong ofc, you need to quote the entity_id.
can you screenshot the entity in dev tools state like this:
so this gets weirder per post⌠how is your entity created? Is this some custom integration, given the presence of an attribute index, and the absence of all core attributes �
also, given the example in the docs
are you sure payload shouldnt be inside brackets?
I have a python script. that creates those text_inputs (input_text.xenia_script_*) of data retrieved from an external device using hass.services.call and hass.states.set functions. Index is just a value, we could name it totally different.
I see, that would explain the out of the ordinary attribute indeed. Using the hass.states.set myself in python, and though powerful, it is prone to unexpected outcome.
Iâd suggest you take this in to a separate topic, and out of auto-entities, because it would be an issue of getting the correct attribute inside that payload template, and not so much the auto-entities part of it here. Itâs getting awfully off-topic because of that.
please check the brackets remark I added earlier, and see if thats relevant?
My understanding is, that the bracket is only used when using the Developer Tools.
Thanks so far for your support.
Regarding auto-entities and what I need to achieve:
- My device provides me with a list with an unknown quantity of data pairs: Text + ID
- The âTextâ part of each of these data pairs should be a button on my front.end.
- Pressing the button, a rest_command (an URL) should be called that ends with the provided ID for the button (http://<fixed.URL>/execute_script?ID=ID of data pair)
I started my implementation with generating the input_text entities to achieve this.
What would be your suggestion to approach this?