Feller-AG / wiser-api

MIT License
12 stars 1 forks source link

API/Product suggestions #30

Open kinnkler opened 2 weeks ago

kinnkler commented 2 weeks ago

@woodworm @oliver-joos Hello everyone I have been using Wiser (20 devices) for 1 year now and have been very satisfied so far. ๐Ÿ˜ƒ I still have a few wishes/suggestions, which I would like to mention below:

It would be cool to hear from you whether certain things can be implemented in the future. Many thanks

grobotka commented 2 weeks ago

Hi, I find the suggestion "different lighting colors for on/off" very useful. I miss this feature very much.

woodworm commented 1 week ago

What I can say at the moment... An open MQTT client and more flexible color settings for the LEDs are on our roadmap. It is difficult to change the behavior of a scene-button because it is deeply embedded in the DNA of the Wiser system. It is important to us that many things work immediately after installing a device. That's why the scene-button behaves like this ๐Ÿคทโ€โ™‚๏ธ. But you can change the function of the button-type. But it is secret like the spiciest secret of Switzerland ๐Ÿคซ

If you have this Nebenstelle device

+---------------------------+
|  +--------+   +--------+  |
|  |        |   |        |  |
|  |   S1   |   |   S3   |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
|  +--------+   +--------+  |
|  |        |   |        |  |
|  |   S2   |   |   S4   |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
+---------------------------+

and you would love to have one like this

+---------------------------+
|  +--------+   +--------+  | 
|  |        |   |        |  |
|  |   I    |   |    I   |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
|  +--------+   +--------+  |
|  |        |   |        |  |
|  |   0    |   |    0   |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
+---------------------------+ 

run this curl line curl -X PUT http://<ip>/api/devices/<device-id>/register/c/0x9000 -d '{"value": "0x0002"}' a power-up of the device or curl -X PUT http://<ip>/api/devices/<device-id>/register/a/0x0A00 -d '{"value": "0x0001"}' is necessary afterwards. โš ๏ธ Please be careful with further commands... make sure the device-id is correct... you can break a lot of things!

woodworm commented 1 week ago

the whole thing would also be possible via the web interface. but... โš ๏ธ please be careful!

cmd

kinnkler commented 1 week ago

@woodworm Thank you very much for your answer. I still have a couple of follow-up questions:

Regarding the change of the 4 scene buttons to groupctrl buttons: Is there no possibility to use only 1 button (toggle-button) per light group? I consider the implementation with a separate on (I) and off (O) button to be inconvenient, as the I button no longer has any function when the light is switched on. And this implementation could also be solved with the scene button for undimmed lamps. Scene on and scene off. It would also be cool if 4 separate lamp groups could be controlled with one device. I think the best solution would be if the group-ctrl part of a job could also be executed for scene buttons. I think the distinction between scene and groupctrl makes no sense for people who configure with the API. The job has 4 parts (target_state, group_ctrl, script, system flag) and these should simply be executed by a smartbutton. All 4 parts always and not just 3 depending on the button would be cool. I can understand that many things should work simply by plugging in the system and without configuration and therefore 2 push buttons (I and O) in the grid of 4 are considered as one group. However, is there no way to have the 4 buttons separately via API and assign 4 separate jobs to them. So I could then assign 4 different group-ctrl jobs and configure the buttons as toggle.

It's cool that the button layout can be adjusted afterwards using the Write register. In the GUI, it says at 0x9000 See TODO_DOC_NAME. Could you provide me with this documentation? I would also like to know the values for other button configurations like this one:

Bildschirmfoto 2024-06-21 um 02 36 13

I have already analyzed that the format 0x0abc, a is the button type, b is the number of scene buttons and c is the number of group_buttons. Unfortunately I don't know what the button type is, does it have anything to do with I/O seperat = 0 and toggle = 1? So could I write value 0x0104 in register 0x9000 and then have 4 group-ctrl buttons?

My absolute "Dream-Nebenstelle" would be this one ๐Ÿ˜ƒ :

+---------------------------+
|  +--------+   +--------+  | 
|  |        |   |        |  |
|  |  I/0   |   |   S1   |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
|  +--------+   +--------+  |
|  |        |   |        |  |
|  |  I/0   |   |   S2   |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
+---------------------------+ 

By the way, it would be really great if you could publish a more detailed documentation. The system has many possibilities that are not really known, such as the register changes (to change button config). I have also started with system flags. Since there is no documentation regarding these things, it is very difficult to implement or change things because the exact implementation details are unknown. I think there are also some crazy nerds out there who would like to play more with the system ๐Ÿ˜ƒ Thanks a lot!

woodworm commented 1 week ago

I agree that a toggle button is usually sufficient... especially to turn a light on or off. Dimmers are a bit tricky... if you press the button for a long time, it's not clear to everyone whether it should dim up or down. It gets difficult with motors. These are almost impossible to operate with a toggle switch.

But thank you very much for your input. Here is the complete overview of the possible configurations that are possible today.

0x0001
+---------------------------+     +---------------------------+     +---------------------------+
|        +--------+         |     |        +--------+         |     |        +--------+         |
|        |        |         |     |        |        |         |     |        |        |         |
|        |   I    |         |     |        |   +    |         |     |        |   ^    |         |
|        |        |         |     |        |        |         |     |        |        |         |
|        +--------+         |     |        +--------+         |     |        +--------+         |
|        +--------+         |     |        +--------+         |     |        +--------+         |
|        |        |         |     |        |        |         |     |        |        |         |
|        |   0    |         |     |        |   -    |         |     |        |   v    |         |
|        |        |         |     |        |        |         |     |        |        |         |
|        +--------+         |     |        +--------+         |     |        +--------+         |
+---------------------------+     +---------------------------+     +---------------------------+

0x0002
+---------------------------+     +---------------------------+     +---------------------------+
|  +--------+   +--------+  |     |  +--------+   +--------+  |     |  +--------+   +--------+  |
|  |        |   |        |  |     |  |        |   |        |  |     |  |        |   |        |  |
|  |   I    |   |    I   |  |     |  |   +    |   |   +    |  |     |  |    ^   |   |   ^    |  |
|  |        |   |        |  |     |  |        |   |        |  |     |  |        |   |        |  |
|  +--------+   +--------+  |     |  +--------+   +--------+  |     |  +--------+   +--------+  |
|  +--------+   +--------+  |     |  +--------+   +--------+  |     |  +--------+   +--------+  |
|  |        |   |        |  |     |  |        |   |        |  |     |  |        |   |        |  |
|  |   0    |   |    0   |  |     |  |   -    |   |   -    |  |     |  |    v   |   |   v    |  |
|  |        |   |        |  |     |  |        |   |        |  |     |  |        |   |        |  |
|  +--------+   +--------+  |     |  +--------+   +--------+  |     |  +--------+   +--------+  |
+---------------------------+     +---------------------------+     +---------------------------+

0x0021
+---------------------------+     +---------------------------+     +---------------------------+
|  +--------+   +--------+  |     |  +--------+   +--------+  |     |  +--------+   +--------+  |
|  |        |   |        |  |     |  |        |   |        |  |     |  |        |   |        |  |
|  |   I    |   |   S1   |  |     |  |   +    |   |   S1   |  |     |  |   ^    |   |   S1   |  |
|  |        |   |        |  |     |  |        |   |        |  |     |  |        |   |        |  |
|  +--------+   +--------+  |     |  +--------+   +--------+  |     |  +--------+   +--------+  |
|  +--------+   +--------+  |     |  +--------+   +--------+  |     |  +--------+   +--------+  |
|  |        |   |        |  |     |  |        |   |        |  |     |  |        |   |        |  |
|  |   0    |   |   S2   |  |     |  |   -    |   |   S2   |  |     |  |   v    |   |   S2   |  |
|  |        |   |        |  |     |  |        |   |        |  |     |  |        |   |        |  |
|  +--------+   +--------+  |     |  +--------+   +--------+  |     |  +--------+   +--------+  |
+---------------------------+     +---------------------------+     +---------------------------+

0x0040
+---------------------------+
|  +--------+   +--------+  |
|  |        |   |        |  |
|  |   S1   |   |   S3   |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
|  +--------+   +--------+  |
|  |        |   |        |  |
|  |   S2   |   |   S4   |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
+---------------------------+

0x0101
+---------------------------+
|                           |
|    +-----------------+    |
|    |                 |    |
|    |                 |    |
|    |       T1        |    |
|    |                 |    |
|    |                 |    |
|    |                 |    |
|    +-----------------+    |
|                           |
+---------------------------+

0x0110
+---------------------------+
|                           |
|    +-----------------+    |
|    |                 |    |
|    |                 |    |
|    |                 |    |
|    |       S1        |    |
|    |                 |    |
|    |                 |    |
|    +-----------------+    |
|                           |
+---------------------------+

0x0102
+---------------------------+
|                           |
|                           |
|                           |
|  +--------+   +--------+  |
|  |        |   |        |  |
|  |   I/0  |   |   I/0  |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
|                           |
|                           |
|                           |
+---------------------------+

0x0111
+---------------------------+
|                           |
|                           |
|                           |
|  +--------+   +--------+  |
|  |        |   |        |  |
|  |   I/0  |   |   S1   |  |
|  |        |   |        |  |
|  +--------+   +--------+  |
|                           |
|                           |
|                           |
+---------------------------+
woodworm commented 1 week ago

We are aware that the documentation could be more detailed ๐Ÿ™ˆ. As soon as we find time we will work on it ๐Ÿ˜‘

kinnkler commented 1 week ago

@woodworm Thank you very much for your answer. Nice to hear that you have taken note of my input regarding toggle switch implementation.

Also thanks for sharing the buttons configuration codes. If I write 0x0104 in register 0x9000, is there any chance that this will work and create 4 groupctrl toggles or will the device stop responding because it considers it invalid? ๐Ÿ™ˆ

Another question regarding something completely different, where I am currently looking for a solution for implementation ๐Ÿ˜ƒ : I would like enable or disable a timer via a button (I guess a scene button). This can be done for the "Anwesenheitssimulator" and then it can be assigned to a scene button. This is solved there using the "present" system flag, and "blocked_if_present: true" is then added to the timer according to the API. I would now like to be able to enable and disable another timer besides the "Anwesenheitssimulator" with a button. Is there a way (possibly with system flags) to implement this? Thanks for your help!

btw: what is the difference between timer and scheduler or system flags and system conditions in the API? I have only seen that a scheduler is created for several timers...

woodworm commented 1 week ago

0x0104 currently not working... only the ยตGW itself can do this. But it is not tested!

Do not use "blocked_if_present" it is deprecated!

create a new system flag POST /api/system/flags {"symbol": "automation", "value": true, "name": "Alles got vu allei"}

create a new system conditions (could be more complex "automation and not cleaning or not weather_alarm") POST /api/system/conditions {"expression": "not automation"}

now you can create all jobs you need for your automation POST /api/jobs and add {"blocked_by": , ....} in the job

and finally all timers with a reference to your jobs POST /api/timers

woodworm commented 1 week ago

Totally forgot! Now you can set the system_flag via the API or create a job again with "flag_values": [{"flag": , "value": true}]. If you now link this job with a smart_button, you can switch on your automation with a Scene-Button. If the Button-LED is switched on, the LED lights up if automation==true

kinnkler commented 6 days ago

0x0104 currently not working... only the ยตGW itself can do this. But it is not tested!

Do not use "blocked_if_present" it is deprecated!

create a new system flag POST /api/system/flags {"symbol": "automation", "value": true, "name": "Alles got vu allei"}

create a new system conditions (could be more complex "automation and not cleaning or not weather_alarm") POST /api/system/conditions {"expression": "not automation"}

now you can create all jobs you need for your automation POST /api/jobs and add {"blocked_by": , ....} in the job

and finally all timers with a reference to your jobs POST /api/timers

@woodworm Thank you very much. This is exactly what I was looking for.

Regarding "blocked_if_present": I did not create this job myself, but via the "Anwesenheitsimulator" in the iOS app. This apparently still uses "blocked_if_present". Do I have to change anything or will this continue to work? I also see an offset = random there. Can you give more details on how this offset works exactly? Can I also use offsets for other timers to implement a temporal randomness or is there only the offset regarding sunrise/sunset? That is the timer, which was created by the iOS-App "Anwesenheitsimulator" { "job": 478, "offsets": "Random", "when": { "every": "Mon,Tue,Wed,Thu,Fri,Sat,Sun", "at": "15:23" }, "blocked_if_present": true, "id": 479, "enabled": true },

kinnkler commented 6 days ago

0x0104 currently not working... only the ยตGW itself can do this. But it is not tested!

Do not use "blocked_if_present" it is deprecated!

create a new system flag POST /api/system/flags {"symbol": "automation", "value": true, "name": "Alles got vu allei"}

create a new system conditions (could be more complex "automation and not cleaning or not weather_alarm") POST /api/system/conditions {"expression": "not automation"}

now you can create all jobs you need for your automation POST /api/jobs and add {"blocked_by": , ....} in the job

and finally all timers with a reference to your jobs POST /api/timers

A few more questions about the implementation of the "automation button" before I put it into practice.

  1. Can POST /api/jobs {"blocked_by": , ....} also be a system flag directly or is the path via conditions necessary? Does the blocked function only work for jobs that are assigned to a timer or can I also define this for normal jobs so that certain smart buttons no longer works when I am absent (and set a according system flag), for example?

  2. I have seen that there are also triggers in the jobs API. Can you say more about these? Are these system flags/conditions or loads id's that trigger the job?

  3. You wrote that it is possible to set the system flag in a job. I have tested this. Is it possible that this only works for scene buttons and that the "flag_values" of the job is not executed for "Nebenstellen"-smartbuttons?

  4. Another question about toggling (my favorite topic ๐Ÿ˜œ). Is it possible to toggle the system flag in the job instead of assigning a true or false value to the system flag? So if true, then toggle to false or if false then to true. That way I wouldn't have to sacrifice two buttons to switch the timer on and off, but could do the whole thing with one button. With the current implementation, I would need two buttons for on and off. It would be cool to have a button where you can see from the LED whether the timer (system flag) is active or not. I have seen that "flag_values": [{"flag": , "value": true}] only accepts boolean and no logic. Perhaps this is possible using the script function? Is there a way to change the value of the systemflags object directly with the python script without the need for localhost API CALLs?

  5. What is the correct way to remove a job from a smartbutton? do you have to delete the job or should you simply assign an empty job to the smartbutton?

I would be really grateful if you could answer my 5 points. The API really has a lot of great "hidden functions" with which you can implement a lot of gimmicks ๐Ÿ˜ƒ . Thank you very much for your great support!

woodworm commented 5 days ago
  1. {"blocked_by": , ....} can also be a system flag. "blocked_by" works for all jobs, no matter how they are called.

  2. api/jobs//trigger checks "blocked_by" and handles "flag_values", "target_states", "button_ctrl" and "scripts" api/jobs//setflags checks "blocked_by" and handles "flag_values" api/jobs//run checks "blocked_by" and handles "target_states" api/jobs//ctrl checks "blocked_by" and handles "button_ctrl" api/jobs//execute checks "blocked_by" and handles "scripts"

  3. Smart-Button of type "ctrl", checks "blocked_by" and handles "button_ctrl" and "scripts" Smart-Button of type "scene", checks "blocked_by" and handles "target_states" and "scripts" and "flag_values"

  4. Doesn't work today... but I recorded it ๐Ÿ‘๏ธ But with a script it would be possible. I can support you with this.

  5. Delete the job or set the job reference to "null" in the Smart-Button.

kinnkler commented 5 days ago

Thank you very much for your fast reply and for recording the thing with the system flag "toggle". I would therefore like to solve it with a script in the meantime. Can you help me with how I can access the objects directly in the script? I mean system flags, jobs or, if possible, loads. To switch the lights on and off, start a job or change the system flags value using the script engine. ๐Ÿ˜ƒ

EDIT: I have just noticed that timers that are created via the API are not displayed in the Mobile APP, or that it is not visible in the Mobile APP that a timer job is blocked due to a system flag. Therefore, I think the best option would be if I could access the timer object via script and set the "enabled" attribute to true or false with the script. This would allow me to activate or deactivate the timer with the smart button and the mobile app and I would always have an insight into whether the timer is active or not via the mobile app. Is there a way to access this "enabled" attribute directly with the script engine? In short, is there a way to directly access and change these system objects (timers, jobs, loads, system flags) with the script engine?

Bildschirmfoto 2024-06-28 um 04 58 45

In short, is there a way to directly access and change these system objects (timers, jobs, loads, system flags) with the script engine?

Regarding point 2, I may have expressed myself too unclearly. In the job (see example 1 below from the Swagger UI) it also has triggers after "blocked by". Are these the IDs of the smart buttons that trigger this job? However, I do not have this attribute "triggers" anywhere in my jobs, although certain jobs are linked to smartbutton. On the other hand, I have "scene_input_channel": 16 (see example 2), which are automatically added to the job after I link the job to a smartbutton. can you say more about these "triggers" and "scene_input_channel"?

example 1:

Bildschirmfoto 2024-06-27 um 16 40 42

example 2:

Bildschirmfoto 2024-06-27 um 16 38 28

Thank you very much for your support!