Hello,
Sorry for my delayed answer, I was working on my HA challenge
And I will now post the full answer in case someone want to do a similar thing.
So my initial goal was to build a dashboard showing some meteo messages (METAR, TAF) for airplane pilot needs.
Parts circled in red are dynamics messages updated each 30 or 60 minutes (in the real life) and are available (for example) through the API of this website : https://www.checkwxapi.com
What I have done :
- Create a powershell script to execute a request to these API for a specific airport (LFLV or LFLC for examples) and test it outside of HA
- Have then to install Powershell in my HA instance (and I lost a lot of time on this because I only found some old post around this, not updated, not compatible with the last version of Alpine distro on HA, …).
a. Use this post to install and configure AddOn “SSH & Web Terminal” on HA : Install PowerShell on Home Assistant – Josh's IT-Blog
(don’t use it to install powershell as it no longer relevant with the last version of HA)
b. From the SSH & Web Terminal execute the following command lines :
sudo su
docker exec -it homeassistant /bin/bash
and then check the distro of your HA instance :
cat /etc/os-release
and finally, create a folder on your HA instance to store your powershell scripts :
mkdir /config/pwsh
c. Install Powershell into the HA docker instance (and not only into the terminal session in order to be persistent over time) :
apk add powershell
(PowerShell 7.4.2-0 has been installed for me as I write this post, for your information)
d. Finally, check that powershell has been well installed into your HA docker instance, lauching powershell :
pwsh
- Modify YAML files of your HA in order to references and create your sensors
a. Modify the configuration.yaml file in order to reference the command_line sensors that we will create, adding the following line in the configuration.yaml :
b. Create a new yaml file, command_line.yaml in your HA repository and add your sensor definition, like the following example (share a screenshot in order to maintain indentation) :
You can see that my command call my powershell script, stored in the pwsh folder created previously and with specific parameters to be passed to the script.
(Personal API Key have been modified in the screenshot but you can have one for you from the checkwxapi website)
- Make some vérifications in order to check that everything works as it is supposed to
a. You can check that the command line works fine from the “Advanced SSH and Web Terminal”
b. Check HA configuration and then restart your HA instance
Check that there is no error in your yaml files that will prevent HA to restart in the good way and then restart the HA instance so that new sensors and configurations done through yaml files are injected in your HA configuration.
c. Check HA log from the Log Viewer section and you must see something similar to the following screenshot (actually I’m not sure at 100% that it is a good thing that these lines appears in the log file but seems to be better than an error)
d. Check that the state of the new sensor has been well updated with the expected information
- Modify the dashboard in order to include the new sensor and check that this is well updated from the end user perspective.
a. Modification of the dashboard
Add the following yaml code to any HA card so that the sensor value will be integrated in the dashboard
{{ states(‘sensor.aero_meteo_metar_lflc’) }}
b. Final result :
Hope this step by step procedure could help you to build something similar for another personal project. Do not hesitate to share your advices or any suggestions in order to optimize my work, I’m pretty new with HA so I won’t be offended.
Aurélien