Web API


#1

Is it someone who can make a simple Web-api that trigger a flow and show me the code?
And Yes, a have read the documentation but need some “hello word” code to start with and i want to trigger a flow from Wab-api.

Please Micke


#2

Triggers are usually triggered from within Homey,
It uses the arguments like changed temperature, wind, state or even Who came home as tokens in the flow.

but the ‘This Flow is started’ card can be triggerd from the Web Api.
fe. Homeyscript uses the Web API and this script triggers the flow with the mentioned id.
let result = await Homey.flow.triggerProgrammaticFlow({ id: '3c80f61d-e511-4e10-a4d7-e9d7b6b601be' })
console.log (result)

if it returns true it worked.


#3

Great. Thanks. Is it any way to trigger script website thru web-api.


#4

Have you looked at https://apps.athom.com/app/com.internet ?
Does it provide what you want?


#5

Yes. Exacly. I have try it and its great but i want to access my flows directly not thru a app.


#6

I agree! I would love to trigger a flow without needing to set up an additional flow that uses a http request


#7

I asked about the REST API, apparently its been completely forgotten and "why you would want to use REST’ when we have a JS api.

I was a little dumb founded.


#8

So. is there a way to trigger a flow externally via web-api? Think that ex. As you Jamie write, Rest is possible the easiest way. Is there anyone out there who knows how to do with the Web-api?


#9

I cobbled this up: https://github.com/robertklep/homey-web-api-example

Since it’s not possible to get custom OAuth2 client credentials (:soon:), I’ve borrowed the ones that belong to athom-cli. The token is being read from its configuration file, so you need to have a properly configured athom-cli before you can use the test code.

Even though the documentation states that there is a triggerFlow() method, there isn’t (perhaps it exists in the latest version of athom-api, 2.0.133, but that version doesn’t work properly). Instead, I used testFlow.