This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Flows

Advanced HTTP Get Request for Homey (::1)

GeurtDijkerGeurtDijker Member
edited April 2018 in Ideas & Suggestions
Wondering myself, should the title be automation of the automation? or Requesting Homeys own API's? 
I want to contribute and document the nice Advaced Geeky options of the "HTTP Get Request" in combination with Homey Self.
(I think these advanced options deserve a own thread to document them)

I will start with 3: 

- 1st:  setting the LED Idle mode

- 2nd: Restarting Homey from a Flow

- 3rd: Sending Logs to Athom ;-)

Any suggestions are welcome!

1st: setting the LED Idle mode

Prerequisites:

Do it yourself:

1) Get your own Bearer token
Get your  Bearer Token somewhere, fe when you log on and select your Homey, the link contains it: 
fe http://YourHomeysLocalIPAddress/?bearer_token=Deaf001000bad1000effe000hace000215c001
(everything after bearer_token=)

2) Create a flow with a Trigger (What you want, any trigger will work but you need one)
Place an "HTTP Request Flow Card" in the Then... Column, choose  Type "HTTP Put JSON"
Edit the string below in your favorite editor (fe Notepad) and replace the fake Bearer token for your own Bearer Token
I use ::1 as Loopback adres for Homey, no need to change to your local Homey's IP Address. (::1 is the IPv6 equivalent for 127.0.0.1 )

URL>>  {"method":"put","protocol":"http:","host":"::1","path":"/api/manager/ledring/settings/","headers":{"Authorization":"Bearer Deaf001000bad1000effe000hace000215c001","Content-Type":"application/json"}}

Choose from one of the options fr the LED ring (off, pulse, rainbow)
Option>>  {"uri":"homey:manager:ledring","name":"off","options":{}}
Option>>  {"uri":"homey:manager:ledring","name":"pulse","options":{}}
Option>>  {"uri":"homey:manager:ledring","name":"rainbow","options":{}}

Put the URL sting from { to }  (including first and last bracket ) in the URL field and the Option from { to } in the Option field. 

For the Martens Screensaver also change the uri in options, fe: 
{"uri":"homey:app:martens.screensavers","name":"TIFF","options":{}}
{"uri":"homey:app:martens.screensavers","name":"red_sleep","options":{}}
{"uri":"homey:app:martens.screensavers","name":"white_sleep","options":{}}

Other names for the current Martens Screensavers are white_sleep / white_slow_sleep / red_sleep / red_slow_sleep / TIFF / faint_rainbow / fainter_rainbow 

3) Save an Test !
Happy Homey Usage! 
Tagged:

Comments

  • GeurtDijkerGeurtDijker Member
    edited September 2016

    2nd Restarting Homey from a Flow

    Prerequisites:

    • Homey ;-)
    • HTTP Request flow cards (1.2.0)
    • Your own Bearer token (See Top Post)

    Do it yourself:

    1) Get your own Bearer token (See Top Post)
    2) Create a flow with a Trigger (What you want, any trigger will work but you need one)
    Place an "HTTP Request Flow Card" in the Then... Column, choose  Type "HTTP Post JSON"


    URL>>  {"method":"post","protocol":"http:","host":"::1","path":"/api/manager/system/reboot","headers":{"Authorization":"Bearer Deaf001000bad1000effe000hace000215c001","Content-Type":"application/json"}}

    type {} in the second input field of the "HTTP Post JSON" card. (Default it shows an example {} but is empty! )

    3) Don't forget to name the flow and Press SAVE!  If you press TEST  your Homey wil ..... [Timeout on Connection...] 

    Disclaimer: 

    Restarting should not be necessary, Don't just do it if you don't have problems. But with the current sometimes les stable releases or just beta apps from other developers...... it could be a workaround to schedule a restart early in the morning to have a fresh homey each day  

    Happy Homey restarting!

    Update 2016-09-21: 

    This was the way to do it for advanced users ;-) 
    From now (Soon  ™) you can download a new Candy App (from version 0.4.0) and use one Action card:
    https://forum.athom.com/discussion/comment/31912/#Comment_31912

    and buy @MatjaLipu  a beer if you like it .....

  • GeurtDijkerGeurtDijker Member
    edited May 2016

    3rd Sending Logs to Athom ;-)

    Sometimes you have to send Logs to Athom when something doesn't work. Shouldn't it be possible to automate this?
    Lets see: 

    Prerequisites:

    Do it yourself:

    You need two flows, one to send the log, the second to get the LOG ID.

    1) Get your own Bearer token (See Top Post)
    2) Create a flow with a Trigger (What you want, any trigger will work but you need one, I have one on my Scan NFC Card with a scanned RFID)
    Save it ans Name it. fe: SendLogs
    Place an "HTTP Request Flow Card" in the Then... Column, choose  Type "Get Variable step 1"
    Note: I also want an audible feedback (Say Something: Sending Logs!) 

    That card needs 4 options, so edit in your favorite editor, and paste ;-)


    From left to right:
     - http://url/ = {"method":"post","protocol":"http:","host":"::1","path":"/api/manager/system/journalctl","headers":{"Authorization":"Bearer Deaf001000bad1000effe000hace000215c001","Content-Type":"application/json"}}
     - {} = {}
     - JSONpath = result
     - trigger = GetLogNr

    3) Create in the Better Logic a String variable with a name fe. LastLogSend

    Create a second new flow, name it fe GetLogNr, with a Trigger "HTTP Request Flow Card" in the When ... Column, choose  Type "Get Variable step 2". Enter GetLogNr as the "Trigger from step 1".

    "Get Variable step 2" has a token <Value] that contains the result of the post to Homey. in this case the Log ID you have to send to Athom to investigate your logs to research the problem. I like it to get this as a Push Message, and in case I send logs using my NFC card i like a spoken message. As last I like to save the Log ID in the BetterLogig variable LastLogSend. This way the Better Logic Settings shows it including the date and time  I send the logs even after a reboot.


    Use whatever you like in the Then... colomn. You could probably also send an email ;-)

    I don't know if it happens ( in some future or not yet discovered bug) that I am not able to log on to Homey, but Homey is  still able to communicate with the Athom Log receiving server and Homey is able to trigger the flow using my NFC card..... Then I will still be able to send my logs :smile: 

    (Sorry Athom for sending several logs without msg about problems, I had to know if this was possible and to troubleshoot the building of this Flow!)

  • Nice examples Geurt! Thanks for explaining here. I think this is how the community should work. Some people program stuff, others document them  ;).

  • Fire69Fire69 Member
    edited May 2016
    Can't get the automatic reboot working.
    Created a flow that should reboot daily at 2am.
    Used a HTTP Post JSON card with this in the first field
    URL>>  {"method":"post","protocol":"http:","host":"::1","path":"/api/manager/system/reboot","headers":{"Authorization":"Bearer 6b474bdf6071xxxxxxxxxxxxxxxxxxxxx0a2ef","Content-Type":"application/json"}}
    Second field has {} in it.
    When I test it, I get "Cannot read property 'indexOf' of null"
  • @Fire69 ;
    I guess I was not clear by inserting URL>> before the actual string. That came from my RAW notes, 
    Put the URL sting from { to }  (including first and last bracket ) in the URL field! ;-) 
  • Fire69Fire69 Member
    Lol, much better now  :p
    Thanks!!
  • PeaoPeao Member
    #2 resulted in a red ring after boot for me :neutral: . Manual reboot worked good all the time until now. Only a full wipe fixed it.
  • bvdbosbvdbos Member
    Peao said:
    #2 resulted in a red ring after boot for me :neutral: . Manual reboot worked good all the time until now. Only a full wipe fixed it.
    That's interesting (sorry :#)... So maybe this is the cause for the RROD's which have been reported and now there is a way to replicate the RROD? Then there's a start for a solution...
  • Fire69Fire69 Member
    Think it's just a coincidence actually. 
    Lot of people with the red ring lately, I don't think they all used this method... 
  • PeaoPeao Member
    edited May 2016
    No problem at all  :wink: 
    My Homey Flow Backup is still working (a .jpg with screenshots of all flows :smiley: ) So its not a big deal. 

    Jep maybe they can reproduce it. I followed your steps, but it resulted in a the booting animation (orange ring) for over 10 minutes, then i powercycled. After this the red ring appeared shortly after the booting animation.
    When I tried to restore without wipe the same occured: first a neverending booting animation, then a powercycle followed by the RROD. 
  • PauluzPauluz Member
    edited May 2018
    Hi all,

    I am struggeling to find a solution.

    I am using Domoticz with Imperihome on a tablet, now I want to create a button that can trigger a flow, I  already know  how to configure and use the "HTTP request flow cards app" in Homey.

    I first tried to create a few examples and got the "reboot example" to work, within a flow itself, but what I want, is to use a line of code in Imperihome, It has the option to create a generic widget that will execute a HTTP request, and that is exactly what I need, but I need some help..

    Thank you @GeurtDijker for these examples!

    Thanks in advance fellow Homey's!

    Pauluz
  • Dont know where you are stuck,
    but in my Example ::1 is the shortest notation for localhost or 127.0.0.1  the looback IP address
    From another host you need the IP address of your Homey 
    But i have no experience with imperihome and widgets.

  • PauluzPauluz Member
    Dont know where you are stuck,
    but in my Example ::1 is the shortest notation for localhost or 127.0.0.1  the looback IP address
    From another host you need the IP address of your Homey 
    But i have no experience with imperihome and widgets.

    That’s to bad Geurt, but Thanks for your answer.
    I hope someone more experienced with Imperihome and Widgets will respond and point me into the right direction.
  • Modbreak: @Pauluz , @Eternity

    To keep this Discussions to it's  topic and understandable for others I moved your comments regarding Domoticz  here:
    https://forum.athom.com/discussion/3088/how-to-domoticz-to-homey-using-httplink

    and about ImperiHome  here: 
    https://forum.athom.com/discussion/383/imperihome-homey-interface-waiting-for-the-rest-api-and-new-sdk

    Hope to keep the Forum informative for everyone this way, 
    Thanks for your understanding and keep up the Support!
  • Had anybody in here managed to use the http get function to turn. Off a Windows PC remotely on the network?
  • Don't know if you have a WebServer running on the PC that allows for a shutdown with a http request?
    That would be a possible solution, 

    an other option would be:
    Enable ssh server on  your pc and use the ssh app on Homey. (didn't test)
  • VleegeVleege Member
    edited June 2018
    skandshus said:
    Had anybody in here managed to use the http get function to turn. Off a Windows PC remotely on the network?
    Someone asked somewhat the same question. App I suggested supports sleep, restart, hibernate, shutdown and calling a remote app through http request.

    Link to thread:
    https://forum.athom.com/discussion/5266/wake-computer-from-sleep-using-homey
  • WindefalkWindefalk Unconfirmed, Member
    Hi! I'm trying to get my IFTTT applet to work with homey and its soundcloud app.
    The thing I'm missing is Homey's IFTTT app to execute the soundcloud URL. Would this HTTP request solve it and if so, how?
    My applet in IFTTT looks like this: 
    If anyone I follow on soundcloud trigger "Homey" IFTTT card
    The IFTTT applet has 3 variables whereas one is the track URL - {{TrackUrl}}

    The trigger card in Homey import those 3 variables as a tag. 
    Could I use the tag {{TrackUrl}} to request the URL with this HTTP request app?

    N00b here =)

    Thanks!
  • Windefalk said:
    Hi! I'm trying to get my IFTTT applet to work with homey and its soundcloud app.
    The thing I'm missing is Homey's IFTTT app to execute the soundcloud URL. Would this HTTP request solve it and if so, how?
    My applet in IFTTT looks like this: 
    If anyone I follow on soundcloud trigger "Homey" IFTTT card
    The IFTTT applet has 3 variables whereas one is the track URL - {{TrackUrl}}

    The trigger card in Homey import those 3 variables as a tag. 
    Could I use the tag {{TrackUrl}} to request the URL with this HTTP request app?

    N00b here =)

    Thanks!
    Hi!
    Did you figured it out yet? If not, can you add some screenshots of the flows you try to get to work?
    What URL do you want to request? 
    You are able to use tags in flow card parameter fields:

Sign In or Register to comment.