Rebooting Homey from a flow

Update March 4

Homey v2.0.5-rc.2 has been release to the experimental channel, amongst other improvements it adds a new experimental functionality: Power user.

This new function enables advanced Flow cards & system profiling in Insights.

These are the Flow cards (in the System category) that become available when you enable the Power users Experiment:

image

The Restart Homey card makes the instruction below superfluous but I will leave it here for informational purposes.

This flow will let you reboot Homey
Sometimes you just want your Homey to reboot, with this flow you can for example schedule a reboot or reboot when a certain condition is met.

  • Disclamer: This is an advanced flow, use this information at your own risk.
    Make sure you use it wisely and understand what your flow will do. You don’t want to get your Homey into a boot loop from which you can not recover it!

What is needed to create this flow?
For this flow the HTTP request flow cards app needs to be installed. You also need your Bearer Token. How to obtain this will be explained below.

Open your favorite text editor, for example Notepad, and copy paste the found information from the next steps into it.

Find your Bearer Token

Open Chrome and open the developer tools ( ctrl-shift-j on Windows, cmd-option-j on Mac)
Select the Network tab, enable Hide data URLs and click All

next navigate to https://developer.athom.com , make sure you’re logged on, and see the info appear. Now search for a line that shows me and click on it.

Check if the end of the Request URL in the right pane shows sessions/session/me and has a Status Code 200 OK

Now scroll down in the right pane and search for the authorization variable. Copy that code to your text editor.

So now you should have something like this in your text editor

Bearer 52c--------------------------------:------------------------------------------:-------------------------------------54a

The dashes would be numbers or letters

Now you need to prepare the actual information to send to Homey with a HTTP card. Copy the text below to your text editor

{
 "method":"POST",
 "protocol":"http:",
 "hostname":"127.0.0.1",
 "path":"/api/manager/system/reboot",
 "headers":
  {
   "Authorization":"authorization"
  }
}

and replace authorization with the information collected earlier, the result should look like this

{
 "method":"POST",
 "protocol":"http:",
 "hostname":"127.0.0.1",
 "path":"/api/manager/system/reboot",
 "headers":
  {
   "Authorization":"Bearer 52c--------------------------------:------------------------------------------:-------------------------------------54a"
  }
}

again, the dashes would be numbers or letters

Next step will be to transform the text to one line, it should look like this:

{"method":"POST","protocol":"http:","hostname":"127.0.0.1","path":"/api/manager/system/reboot","headers":{"Authorization":"Bearer 52c--------------------------------:------------------------------------------:-------------------------------------54a"}}

By now you know about the dashes, right?

Now open the webversion of the flow editor at flow.homey.app and click the + Create a Flow button.
image

Enter a name for the flow, Reboot Homey for example.

Next click on the Add card button in the When… ‘column’
image

and select the card you want to use as a trigger, for this example we will use the This Flow is started card so it will look like this:
image

Next will be the action card, the one where the magic happens. Click on the Add card button in the Then… column and select the POST form card from the HTTP request flow cards app.
image

This card will need the information you’ve collected so select the whole line you have prepared earlier and copy paste it into the top text box of the action card. Next put a space in the second text box and remove that again.

The flow should now look like this

Save the flow. If you now click the Test button your Homey will be rebooted.

If it doesn’t work for you, please double check the steps above. If that doesn’t fix it, please post the error you get in this topic, make sure when posting screenshots you make your Bearer token unreadable!

  • Your Bearer Token is information you need to keep secret
  • Remember that your Bearer Token can change over time! It’s basically a code with a limited lifetime that’s handed out when you successfully log on. So at some point your flow could stop working and you’ll have to replace the Bearer Token.
  • Ultimately there should now be no reason to reboot your Homey an a regular basis. If you see the need for it please try to find out why it’s needed and report that to Athom so a sustainable fix can be made for the benefit of all Homey users.
8 Likes

@Emile just confirmed on Slack that there will be an option in Homey to reboot Homey in an easier way then described above.

Edit:

Just posted on Slack:

2 Likes

Great Tip @DaneedeKruyff!
thank you

1 Like

@DaneedeKruyff great work.

I guess you can also use the standard logic flow card: “Make a webrequest” instead of using an additional app.

1 Like

Note: we do not advice this and the token used will expire after some time.

2 Likes

Will athom make this possible??

2 Likes

Didn’t know that card earlier :slight_smile: Just tried it but it’s giving me errors about headers so have to figure out what the right syntax would be.

That’s why I added quite some remarks and disclaimers.
I thought a while if I should or shouldn’t post it but decided I would as there’s a need (for some) to reboot their Homeys. I think @anon2681894’s question, if Athom will provide us with a card to reboot Homey, is valid and hope you will answer it.

1 Like

I use it to reboot Homey (by Candy app) if the cloud connection is lost for more than 30 minutes. Most of the time this is due to a connection problem between Homey and my router (Wi-Fi related). So i can’t do it manually remote even if i have access to my network because Homey is unreachable.

Question: will your solution work from a similar flow even if Homey has no cloud or even worse, no Wi-Fi connection?

Hi @PetervdK In the initial version I posted the connection was made to the Homey Cloud uri so it would require a working internet connection. I was still playing around with it and got it working with connecting to the localhost address of Homey and edited the first post with these changes.
So yes, this should work without a connection to the cloud.

@Emile just confirmed on Slack that there will be an option in Homey to reboot Homey in an easier way then described in this post

image

2 Likes

I have been using this method for over two years. I believe it was posted on the old forum. Didnt know this knowledge was lost over time and people where actually looking to get this done.

Although I understand the warning from Emile about the token I have a lot of automation using the authorization header with token. So far no issues with that on firmware 2.x. It does not seem to change that often. It is disheartening to read though that it is not adviced as it’s the only way to get different home automation tools to talk to each other over LAN (without having to use the cloud).

2 Likes

Yes, saw a lot of request for rebooting through a flow/on a schedule and people missing the Candy app on V2 so I dove into it. Didn’t know it was on the old forum, could have saved me some time :wink:

I also understand the warning but agree with you we can’t do without. Seeing Emile’s/Athom’s concern for security lately it would be nice if they looked into the possibility of (re-)enabling the parts needed for the Whitelist functionality in the HTTP request flow cards app.

I agree but that is also not gonna happen. See req object missing on args in api.js handler ¡ Issue #28 ¡ athombv/homey-apps-sdk-issues ¡ GitHub

I still disagree with Emile’s point of view on this though.

Interesting read. I also disagree with Emile’s point of view, yes an IP address can be spoofed but seriously there are enough other and easier attack vectors possible and not even wanting to build in a bit of a barrier for something that -will- be done (running a http server on Homey) is a bit ridiculous.
I understand and support the safety by design strategy they seem to be adopting but really question the way they implement it (and also not implement it!) seeing they use a well known attack vector (dns rebinding) to get their local https working.
In my opinion they got really carried away and started over engineering a solution for a non existing problem.

Homey v2.0.5-rc.2 has been release to the experimental channel, amongst other improvements it adds the new Flow cards, check the opening post for more information.

1 Like

I would really appreciate if Athom could introduce the option to select an app and restart it within Flows.
I would also appreciated the Reboot Homey option within Flows too.
Any reason this hasnt already been introduced? It seems a simple and obvious solution to me for a number of reasons.

These functions where introduced more than a month ago in 2.0.5.
You need to enable the power user experiment.

See here:

So closed and moved there…

3 Likes

Again Dijker, thanks. This is very helpful. Another menu I didn’t look into, experimental. :grin: Love it.