Hello;
I have been working in HA for only a week, steep learning curve. And first post.
I have a dashboard that uses a small string (2 or 3 characters), to create button labels, and is also inserted into various entity and sensor names. Currently this is accomplished by setting the string as a default variable in 7 decluttering templates; here’s one as an example:
charger_status_status_card:
default:
- var_charger_number: '05'
card:
type: custom:button-card
entity: input_text.[[var_charger_number]]_charge_type
show_state: true
show_name: false
show_icon: false
show_label: false
color_type: card
card_size: 1
aspect_ratio: 7/1
icon: '[[var_icon]]'
styles:
card:
- background-color: transparent
Now: I need to make 25 or more of these dashboards, all identical except for that small string. I have a “parent” dashboard with 25 buttons, each of which performs a tap_action: navigate. Each of the 25 subview dashboards live in their own directory, conveniently named with their own string of interest. So the “05” charger dashboard is in /config/dashboards/05/.
The only difference between all the 25 dashboards is that string. I am trying to figure out how to do something that provides that string when the dashboard loads.
- I do not believe that the navigate tap_action can pass along a variable.
- I have created a one-line shell script which successfully gets the string of interest, and which I have wrapped into an action:
/bin/pwd | awk -F/ '{print $NF}'
- I have read in config-template-card about the possibility of dashboard wide variables.
- I have tried (and failed) various pieces of Javascript in places (window.location.pathname for example).
And of course I am swimming in understanding how HA ties things together, being pretty new.
I am hoping I can be guided to how to do something like:
- pass the string variable along with the navigate call
- use shell_command or command_line to read the dashboard’s directory and insert the string into the dashboard - either into the template or the view - when it loads
- some other way to insert the (correct) string into the dashboard in the right places
Once the dashboard loads, this value is static and does not need to be re-checked.
If I can get and use this one item, I can create all 25 dashboards from two generic files, the decluttering template and the dashboard view. Here would be an entire dashboard:
decluttering_templates: !include /config/decluttering_templates/charger_dashboard.yaml
views: !include /config/dashboards/charger_dashboard_master.yaml
Any help appreciated greatly,
hugh