Feller-AG / wiser-api

MIT License
12 stars 1 forks source link

Question about socket and event in case of scenes #5

Open swissboy22 opened 1 year ago

swissboy22 commented 1 year ago

Hello

Thanks very much the Wiser Api ist perfect and very useful. I have please one question. Till now i dont know how to solve..

We have a button with a special scene.. lets say all off and you press before you leave the house

How is it possible to receive the event that this scene or button was pressed? Websocket delivers only information about on of dimm states i dont see one for pressing button.

Thanks very much

woodworm commented 1 year ago

Since version 5.1.19 we support user scripts. The scripts can be executed by SmartButtons events. You will find examples on the scripts webpage. Maybe this will help you.

swissboy22 commented 1 year ago

Thanks for answer.. but where exactly I can find this examples how to do my own scripts and add it as an action to be executed by smartbuttons? Did find nothing in the public normal api section.

woodworm commented 1 year ago

Sorry for the "schäbig" explanation!

By the way... as soon as we find time we will document everything on Github

woodworm commented 1 year ago

I just had another idea...

Maybe there is another way for your use case. Call GET api/jobs. One of these jobs is your scene. You can use GET api/jobs/<id>/run to find out which one it is. Now create a systemflag with POST /api/system/flags { "symbol": "lights_off", "value": true, "name":"Lampe us"}. If you call now PATCH api/system/flags {"value": false} and after PATCH api/system/flags {"value": true} and so on... you can see every time a message on the websocket connection. Now you can append with PATCH api/jobs/<id> {"flag_values": [{"flag": <id>,"value": true}]} the systemflag to your job. You should get a websocket message every time if you run the job and the system flag changes to true.

woodworm commented 1 year ago

Use this link to play efficiently with the API 😉

image