Using bash to send a signal to homeassistant

Hello everyone!

I am using docker home assistant on ubuntu 18.04.
I want to execute a bash script through my host that access the docker container and executes a script.
I want the script to toggle a Sonoff device on and off.

I imagine something like this:

$sudo docker exec -it home-assistant /bin/

However I am not sure what should be inside
I will then attach this command to a keyboard shortcut on my server so that I can remotely without a laptop or a phone toggle the lights on and off using a remote keyboard if available.
How can I make communicate with HA to actually toggle the light?


I’m using mqtt for such things.

  • Setup mqtt if you don’t already have it.
  • On your host install mosquitto-clients.
  • In HA create a mqtt sensor or a switch

Now you can monitor/control everything in HA from the command line on your host.

BTW: Welcome to HA! :slightly_smiling_face:

Thanks man :slight_smile:
I will research what you just said and try it out!

By the way after a few hours i found the restful api doxumentation and used that successfully in case someone is researching this.

1 Like


Have a look at this command line utility, I have used it for a while successfully and I believe it will allow you to meet your requirements. It runs from any where you can access Home Assistant via a browser inside your network as it uses same web api calls, you do not run it from within the HA container environment: