Each media player box is running a copy of mopidy mpd. The same boxes run rhasspy as a voice assistant. Events coming from rhasspy include a _site_id field that can be used in automation to pick the correct entity_id for doing the standard media player commands. I however have a number of shell commands on these boxes that I use voice commands to activate using HA shell_commands. Right now I have a separate copy of the shell command for each media player that has the IP address hard coded. Here is an example:
The IP address is hard coded. Does anyone know how I can access the “host” configuration parameter from he media_player configuration in an automation? I would then pass the host value to the shell script.
No it doesn’t show as an attribute. I could use domain names if there is someway to add domain names in as local resolution values. Any idea if there is a way to resolve domain names locallly?
The trigger event from rhasspy has a data field “_site_id”, which identifies the media player/rhasspy device that generated the event. I named the services and entities related to the media player to match the contents of the _site_id. This way I can use _site_id to construct the name of the service to execute. The service is a shell command that runs ssh as previously indicated. In a similar fashion I can construct the entity_id as it’s name also based on the _site_id. I think I could create an input_text for each media player an populate it with the associated IP address. I’ve not used mappers and all the examples I found were templates within an automation. Any chance you can point me to an example on how I would set up a mapper outside an automation and then access it inside the automation?
Thanks, this is very helpful. I have 6 automations that all require this same logic. Is there someway to put the template or mapper logic in a macro or function so replication of the code in each antomation isn’t required?