Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about socket and event in case of scenes #5

Open
swissboy22 opened this issue Oct 21, 2022 · 5 comments
Open

Question about socket and event in case of scenes #5

swissboy22 opened this issue Oct 21, 2022 · 5 comments

Comments

@swissboy22
Copy link

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

woodworm commented Jan 30, 2023

Sorry for the "schäbig" explanation!

  • Go to the web interface of your µGW ("http://" or "http://wiser-XXXXXXXX.local")
  • Click on tab scripts
  • Click on button [Create File]
  • Click into text-box and choose "hue_scene.py"
  • Click on save button
  • Click on pencil button behind the script
  • Now you can customize the script for your use case
  • Maybe you only need the function onButtonEvent() with the call aiocurl()
  • Click on ✅ to save the file
  • Now you can click on button [Link to SmartButton]
  • Choose your script
  • Choose Button Type "scene"
  • Click on button [Link to SmartButton]
  • Press the SmartButton on the wall

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

@woodworm
Copy link
Member

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
Copy link
Member

Use this link to play efficiently with the API 😉

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants