Communication between HA and Homey?

Hi!

My first post so be kind, pls :slight_smile: I have only used HA for about a week.

I want to send a request from my HA over internet to my Homey (on a different location). I just want my HA to check if my Homey is online (connected to internet). To connect to my HA a use a cloudflare tunnel.

My best guess is that I have to send an http (something, request?) to Homey. Homey then send an answer to HA. If HA gets an answer from Homey a button for example turns green. If no answer (after maybee 5 attempts) from Homey HA turns the button red (and starts an automation).

Can anyone pls point me in the right direction how to set upp the communication between HA and Homey?

Thank you!

//D

You could use a ping sensor for this, but this only checks if the host is reachable. Not if your Homey is working fully.

Yes I know but I´m not able to configure my router to allow ping :frowning: I have tried that for a couple of days (whiteout any success) and now I´m looking for another solution.

Maybe via MQTT? But I’ve only tried that locally

I think that my Cloudflare tunnel will cause problems with MQTT. But I don’t really know.

I wrote a post on the Homey forum on how to connect Homey with IFTTT without using the IFTTT app (that as about to be dropped, but in the end wans’t.). The principle described there (for both directions of communication) can also easily be done between HA and Homey:

You can either have Homey do a webrequest to HA to say it is alive, or have HA try to send something to Homey. The first is probably the most certainty Homey is working properly.

On the HA side you need a webhook trigger or a restful command, depending on the direction of communication:

Another option would be to see if the Homey/HA integrations work. That would open up a world of possibilities.

I Think MQTT will be local handled and not causing problem.
In the beginning I had a connection between HA and Homey by MQTT.
It worked also remotely

Thank you

The Homey/HA integration works but I dont see how it could communicate from HA to Homey, the integretion (as i understand it) only collects information from HA to Homey but i want information (Online Yes/no) from Homey to HA.

I think the best for me is to let HA send a question to Homey and depending on answer take action, in my case to turn of a shelly plug if no answer is giving. I´m trying to create some kind of failover function.

  1. Ha sends a question to Homey “are you alive?”
  2. A) Homey reply YES–> nothing happens in HA
    B) Homey doesn’t reply-> HA turns off a Shelly plug

The shelly plug powers my main router, so if no answer (2B above) my main router (inlc. Wifi) shuts off and my Huawei LTE then automatically switch from bridge (because wifi isn’t available anymore) mode to 4G.

If it can control entities, it can send information too. At least the community store version can expose scripts you can call from Homey. Or you could flip a switch from HA. But the webrequest method I suggested is by far the most lightweight. After that MQTT or other integrations require more resources, and internally rely on similar constructs.

I will try to implement the web request method tonight

Do you think it’s possible to send a request from Homey that restarts a timer in HA?

I set a timer in HA, 60 min

I configure Homey to send HTTP “restart timer” to HA. Send every 10 minutes.

If timer in HA finish it trigger an automation.

Yes, that could be done. You can create a timer helper for that. Be sure to check the box to restore the timer on reload. You could also put the actions in the webhook automation itself after a delay, and then set the automation to restart when it is called while it is still running. Or you could set a timestamp that you last saw Homey and react on when that hasn’t changed for a while. Come to think of it: the webhook automation itself remembers when it last ran, so you could just check for that. Possibilities are endless…

1 Like

I think I’m on the right way.

I configured a timer in HA. 60 minutes

I managed to get Homey to restart the timer every 10th minut. Thank you Edwin!

Next challenge is to configure what will happen when the timer ends. But I don’t really know where to put the code.

When time ends I want HA to turn off a Shelly plug.