External calls into home assistant to trigger zwave

Can someone link me to documentation or give examples of how to make external calls into home assistant to trigger automations? I’d like to set up a single page app on my home network that would let my wife trigger my zwave locks and lights.

I would start here.

You can fire an event through a URL - see the dev docs. Try it out with postman

or through the program

And in HA you could define your own custom events, if you do not want to disturb the existing ones

You could also setup a separate dashboard, as seen here.

Another option to consider…

I’ve set my world up by using MQTT - see https://www.home-assistant.io/integrations/mqtt/

MQTT allows you to send messages between programs - kind of like email but for computers. Programs send messages to “topics” which are analogous to mailboxes. Sending is called “publishing” in MQTT. Other programs on other machines can “subscribe” to desired topics and they will receive whatever messages are published to that topic.

You set this up in HA by adding the MQTT integration. I then used the MQTT-related functions in the NodeRed palette to set up various lights to be turned on/off when appropriate MQTT message arrived. E.g., I set up a topic “RecRoomLight”, and used NodeRed to configure it to respond to two possible messages: “off” or “on” which do the obvious things, making an HA service call to manipulate the light.

To turn a light off or on, in any MQTT client, on whatever device you want as long as it is on your LAN, you connect to the Broker and then publish a message to “RecRoomLight” with contents “off” or “on”. Obviously you can get much fancier than that too, and can even make this all work across the Internet, but I kept it simple and in-house LAN only.

You need a “broker” somewhere on your LAN. A broker is analogous to a mail server but for MQTT messages. There are public ones available online; I simply installed one in my Synology NAS, where it is always available inside the home LAN. It should be on a machine which is always up when you want MQTT to work. The HA MQTT configuration connects to the Broker on my NAS, and then “subscribes” to the topics it wants to receive, e.g., “RecRoomLight”.

To trigger automations, you then can use any “MQTT Client” program on any device with LAN access. I use “MQTT Dash” on Android to send “off” and “on” commands to the broker to a topic such as “RecRoomLight”. The broker then sends the message to my HA and NodeRed handles it, using the message contents (“off” or “on” in my case) to control specific lights, but you could also trigger scenes or whatever. The message contents being published is just the string “off” or “on”.

When you use this, all of the connecting, publishing, etc., is pretty much invisible and very fast - well under a second from tapping on a button to having the light respond.

If you’re into building apps, you can also use an MQTT library to give your app the ability to send messages to HA and hide a lot of the detail about how it works.

Thank you! I ended up using the REST API.

Thank you for the recommendation, I ended up using the REST api!

Thank you for the recommendation. It looks like your recommendation was to just set up another dashboard with only the tools I needed. However I was looking to just set up another web app that didn’t require her to go to HA at all. Am I correct in saying that this is just to add another dashboard within HA itself?

Thank you so much for your explanation! Super detailed. I’m actually using node red to fire an even to automatically check and lock my zwave locks every 5 minutes I just hadn’t thought of using MQTT. What made you go with MQTT over other ways of communicating with your zwave nodes? I’m not sure what HA is using under the hood to communicate with with my zwave devices but it doesn’t seem to be mqtt.

Sorry, just saw your question…

I tried MQTT in HA for 2 reasons:

  1. I was experimenting with MQTT in another project (Model Railroading, something called “JMRI”), and MQTT was a plausible way to have the two interact. E.g., when I fire up the railroad computer, it sends an MQTT message to HA, which sets the room lights appropriately.

  2. I tried doing this with HTTP, which I had used before, but it no longer worked. Something about security which was apparently “tightened up” and stopped working.

Somewhere in your setup must be a ZWave controller, that HA uses to interact with ZWave devices by radio. MQTT or HTTP are ways for other computers (like the one running my model RR) to interact with HA.

To confuse things more, the new “beta” version of the HA ZWave implementation actually uses MQTT internally for interactions between HA and ZWave devices. I haven’t gone there yet. But it may then be possible for my external computer to talk directly to ZWave devices through MQTT, bypassing HA. Not sure if that’s a good idea though.