mwarning / trigger

Android app to lock/unlock/ring doors. Supports generic HTTPS/SSH/Bluetooth/MQTT and Nuki Smartlock.
GNU General Public License v3.0
134 stars 22 forks source link

status URL doesnt help (probably as method is different?) #74

Open vv01f opened 2 years ago

vv01f commented 2 years ago

I use your Trigger App from f-droid with https://github.com/astro/spacemsg/tree/master/schalterd/ and unfortunately the answer for the commands lock and unlock (POST method) are both simply {} with HTTP Status Code 200. But there also is the "Status URL" /door.json (GET method) and that is either {"locked":true} or {"locked":false} … just the App answers "Not Found" only, I guess is uses POST method for all requests and thus does not get the expected response.

mwarning commented 2 years ago

Something like this should work for the status: HTTP method: GET Status URL: http://192.168.0.1:8000/door.json Reply Pattern (locked): "locked":true Reply Pattern (unlocked): "locked":false

The Open URL could be something like http://192.168.0.1:8000/door.json&action=open. But that really depends on your implementation.

vv01f commented 2 years ago

yep, that actually works for status with method GET, just then open/close needs the POST method and there is just a single setting for it – which is sensible when thinking about e.g. iterating over simple links for open/close but not for status.

although I proposed to fix the method constraint on the other project, maybe it might be a more general solution if the method was customizable also per command.

mwarning commented 2 years ago

Yes, this is a limitation, I will change it in the future. When I find a good way to make in configurable without an overload of options.

mwarning commented 2 years ago

You also might want to return <tag "door"="open" /> instead of JSON, if you do not want a message to be displayed. HTML tags are stripped after matching.