This may seem like a simple thing to some of you but it took me some time to get this working and the exercise has planted a few ideas for me to try out. Also, I’m not very good with PowerShell, or any scripting or programming. Instead I furiously google and adjust the code I find. Eventually, it works, but usually not the best way to solve a problem. Fair warning.
Here is an example command:
./hass_powershell.ps1 -domain light -action toggle -object light.office
Save the linked text as hass_powershell.ps1
link: https://pastebin.com/T5ZB0Mh7
All this is great but the goal was for me to be able to toggle lights on my windows taskbar without having to open browser, use my phone, enter a command like the example above, or ask Alexa to do my bidding.
So I found a utility to convert ps1 files to exe (http://www.f2ko.de/en/p2e.php) and created a shortcut on my Windows 10 Taskbar to the exe with the arguments. Now I can click on a single icon on taskbar to toggle lights in my office.
Here is an example of shortcut on taskbar which I gave a pretty icon: https://imgur.com/4nViSTf
Other example commands:
Run script dog_bark:
./hass_powershell.ps1 -domain script -action turn_on -object script.dog_bark
Turn on input boolean motion_override:
./hass_powershell.ps1 -domain homeassistant -action turn_on -object input_boolean.motion_override