Hello @B3rt ,
(thanks Robert for answering before me) as @robertklep mentioned, this app has 2 major advantages over the original webhooks: being able to completely decide the path to call on a given server port and the possibility of answering a given call with some text or with a JSON containing information saved on Flow Homey.
This means that not only can you use webhooks to start a flow, but at the same time you can expect a response to the same webhook (like a normal REST API).
In the future I will add a formal check on the JSON written by the user and the possibility to customize the port used (at the moment by default it occupies 3000).
The idea is great so i am gonna try, test and use it (if it works for me)
I installed it and tried to use it, currently i use 1 or 2 webhooks to process data i send from my NAS to Homey, but how do i proces the data what is received/send to Homey using this local API exactly?
How do i get the data what was send to /test
So how do i proces the ?result=true&msg=testing
Or simply only 1param: /test/simple or /test/result=true or /test/true etc
I cannot see any AND cards of the local API to proces the data, there is also no tag card available to use with a logic card to filter/proces the data which was send.
At the moment it seems i only can trigger something but no process any data send, it would be great if it was possible to also send data to homey which is put in a tag card, using logic it would be possible to proces this data and respond using your local API
Can you explain it further if this possible and to do this?
edit:
tip: add (via settings) an option to limit access, for example only local network (only IP range or specific ip 192.168.1.x 192.168.1.1,192.168.1.2, etc)
Consider that it is a first version, surely there will still be a lot of things to implement and improve.
The API at the moment is only “woken up” by the request on the URL (at low level it takes the exact match between URL and what is set in the Flow), this means that (in this first version) the App is not able to read a variable from the address, which is used only as an Entry Point.
The entry point can be used to trigger a Flow and the corresponding response can be used to export and expose data (in JSON or direct response) already present on the homey as a tag (in combination with other flows).
Any improvement proposal is welcome, as the next step I will first make the server port settable, limit access to only some IPs.
Before add the possibility of reading variables from the GET or from the POST body, I have to understand how to make the data “safe”.
I am experimenting at the moment. Your app could be very useful in interaction with Home Assistant, especially if some HA apps don’t migrate to SDK3 in time.
Triggering Homey Flows via HA works very well and without delay. I have created a template where I only need to change the name of the API request in the automation.
At the moment I’m still struggling to process the value reported back in HA. But I will get that right in the end.
It would be great if your app is able to receive json at some point. It could then also process values that are sent to Homey.
Thank you very much! This is exactly what i’ve been looking for! I’m trying to implement a dashboard on micro web server homey app and since there’s no access to backend i can only use javascript (or equivalent frontend language) for fetching data. Problem is that the requests halt on CORS error. With a little googling this seems to be a backend setting. I could of course run my dashboard on a raspberry and do the api calls in the backend and wouldn’t have this issue, but i’m trying to find a way to run a dashboard without needing to have another device for the task. I noticed that there is already issue open for this in github and I’d like to know if this can be fixed in the application near future (meaning also if homey even allows app developers to modify this setting)? Also would be great if anyone knows of a workaround for doing the api call from javascript (browser, not node.js backend) without getting the CORS error.
Hi all,
I’ve published an update (in Test at the moment, if you want to try it you can go here: Local API | Homey )
so, what’s new?
I’ve added the settings page,
you can now decide on what port the localAPI is listening, CORS support (please, note: by default is disabled, you can enable it from the settings page).
I’ll try it for a few days, if it’s all ok I proceed to submit the Test version for publish.
Thank you very much! I’m still however getting the same error when trying to fetch the results with browser side javascript: “Access to fetch at ‘http://192.168.1.10:3000/test6’ from origin ‘null’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.” I tried with CORS disabled on the Local API app and with setting it to enabled and using value *. Am I doing something wrong?
Hi! I understand that it’s still a test version and I’m also trying to help with testing Tried restarting, but didn’t help. Moved the webpage from my computer to homey micro web server and got the origin to show the ip address of my homey instead of null, but still the error remained.