Activate HA script from remote Windows computer?

I run Hass.io on a Pi and I want to trigger a script (or turn of a switch) from a Windows computer on my LAN. Typically by running a manually triggered or scheduled batch/cmd/vbs script locally on the Windows computer.

Any suggestions how I would accomplish that?

There are some ideas here (and link to more in the last post):

Thanks!

I try to avoid curl or other installations to keep the Windows untouched if possible.

I am curious if the API approach (https://my-site:8123/api/services/switch/turn_on?api_password=) would be possible to use - but I don’t seem to be able to address which switch that way.

Otherwise that would have been great.

Did you have any luck with this? Looking to do the same.

Yes, it works great!

I realized that you actually can use curl natively in Windows 10, build 17063 and later, so I went for that approach. The main hassle was to get the " right since it differs from Linux.

My command on the Windows client:

curl -X POST -H "Authorization: Bearer ***my_key***" -H "Content-Type: application/json" -d {"""entity_id""":"""switch.switch_name"""} https://mysite.mydomain.org/api/services/switch/toggle

I use this to switch off a monitor from an old MCE remote.
MCE remote + MCE keyremapper (mapping keypress to keypress combination) + AutoHotKey (to run the command) + the command above = Profit

Works reliably, flawlessly and is actually really fast. No delay at all.

1 Like

Awesome! Thanks for the help!

I got the switch working perfectly thanks to your sample, do you know how you would check for a state in a batch script? Like if media_player.tv == on then do this …

I think it would be to complex to do it in the batch script outside of HA.
But you could use the above to start a script in HA instead of toggle a switch.

And in that HA script, you could use conditions as usual.

Hmm… not sure I can do that, since I need to check the status of a sensor and based on that turn on a windows app (ex: if the TV is on open SteamVR).