Hi guys,
disclaimer: This is NOT a Openhasp question. This is a generic question, so please dont judge the code or syntax of it.
Current AS IS:
I recently managed to get something working and I was wondering if it would be possible to define variables in my configuration.yaml instead of hardcoding “media_player.spotify_username_changeme” multiple times.
Example
See my example code how pesky it would be to change everything manually:
- obj: "p3b12" # artist label
properties:
"text": "{{ state_attr('media_player.spotify_username_changeme','media_artist') if state_attr('media_player.spotify_username_changeme','media_artist') else '-' }}"
- obj: "p3b13" # title label
properties:
"text": "{{ state_attr('media_player.spotify_username_changeme','media_title') if state_attr('media_player.spotify_username_changeme','media_title') else '-' }}"
- obj: "p3b14" # progressbar
properties:
"max": "{{ state_attr('media_player.spotify_username_changeme','media_duration') | int }}"
"val": "{{ state_attr('media_player.spotify_username_changeme','media_position') | int }}"
What I want:
Id rather define a var something like “m_player_name = spotify_username_changeme” so that I only have to change one var and the other code has “media_player.{{m_player_name}}” (or whatever the exaxt syntax is) defined.
Reading the docs, I could not find anything useful and every other Forum Thread is about automations or slightly different things.
Is this even possible natively and if yes: how? Does anyone have an example to tinker?
I know next to nothing about openhasp so perhaps what I had said above (which applies to Home Assistant’s scripting language) doesn’t apply to openhasp?
you basically define a button first as “button 1, page1” on the display itself for example and then you designate a function for it in configuration.yaml .
Creating a dashboard is a real pain in the butt, but it is hella lightweight and it seems pretty solid and unbuggy