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

JSON API SysVar.setEnum is not working as expected #117

Open
pmdevelopment opened this issue Jul 12, 2022 · 5 comments
Open

JSON API SysVar.setEnum is not working as expected #117

pmdevelopment opened this issue Jul 12, 2022 · 5 comments

Comments

@pmdevelopment
Copy link

pmdevelopment commented Jul 12, 2022

To reproduce create a "List" system variable, e.g. named "Test" with values "Foo;Bar;Other" (But use the WebUI, i am still looking for a way to delete a variable with the JSON API).

Now call SysVar.setEnum with {name: "Test", valueList: "Bar"}. The result will return some invalid JSON (#113), but will "Bar" is successfully selected.

Now we would call SysVar.setEnum with {name: "Test", value: "Bar"} or {name: "Test", value: 1} to set a new value index, but the method only excepts valueList, there is no way to change the selected index?

Now use SysVar.getAll, SysVar.getValue or SysVar.getValueByName and there will always be the same: result: "0" or value: "0". The value will always be "0", the first element of the list, because i am not able to change it.

Hardware: CCU3
Software: 3.65.6

@jens-maus
Copy link

Now call SysVar.setEnum with {name: "Test", valueList: "Bar"}. The result will return some invalid JSON (#113), but will "Bar" is successfully selected.

Please show the actual payload you are sending and the concrete example response which you feel is invalid JSON. And please state if you have tested this also already with RaspberryMatic.

@pmdevelopment
Copy link
Author

pmdevelopment commented Jul 12, 2022

Sure, payload for SysVar.createEnum:

"{"name":"Test","valList":"Foo;Bar;Other","internal":"0","chnID":"-1"}

Response is successful:

{"version": "1.1","result": {'name':'Test','id':'6968','value':'Foo;Bar;Other' },"error": null}

Payload for SysVar.setEnum:

{"name":"Test","valueList":"Bar"}

Response is successful but invalid syntax (#113 is discussing this issue and has a fix, i just mentioned it):

{"version": "1.1","result": Bar,"error": null} 

Next Payload for SysVar.getValueByName:

{"name":"Test"}

Response is successful but looks wrong to me:

{"version": "1.1","result": "0","error": null}

"0" is not the right value, as we just set it to "Bar".

SysVar.getAll will now list valueList: "Bar" for this variable.

It's not tested with RasperryMatic, i will try it tomorrow.

Am i using the whole ENUM type wrong? My expectation was to define a list (valueList) of allowed values and to select one of these as current value. The documentation for SysVar.setEnum describes the method to "set the value", but expects "valueList" as parameter, maybe it's not a bug but a missunderstanding.

Here some example for a boolean variable:

{
  "id": "950",
  "name": "${sysVarPresence}",
  "type": "LOGIC",
  "unit": "",
  "value": "true",
  "channelId": "65535",
  "valueName0": "${sysVarPresenceNotPresent}",
  "valueName1": "${sysVarPresencePresent}",
  "isLogged": false,
  "isVisible": true,
  "isInternal": false
}

The value is as expected and can be seen in the WebUI.

My new conclusion is: SysVar.setEnum is just doing the absolute wrong thing. It should expect the value parameter as zero-based index integer and update the variable. Instead it only will update the valueList, so there is no way to set a value using JSON API.

@pmdevelopment pmdevelopment changed the title JSON API won't return SysVar values for "LIST" aka "Enum" JSON API SysVar.setEnum is not working as expected Jul 12, 2022
@jens-maus
Copy link

Am i using the whole ENUM type wrong? My expectation was to define a list (valueList) of allowed values and to select one of these as current value. The documentation for SysVar.setEnum describes the method to "set the value", but expects "valueList" as parameter, maybe it's not a bug but a missunderstanding.

Yes, you are IMHO expecting SysVar.setEnum to do something different. setEnum ist doing the exact same thing like creating a new valuelist variable. That means you use this function to actually set/change the value list and not the value of the sysvar itself. That's exactly why you supply a valueList and not just a value.

@jens-maus
Copy link

Next Payload for SysVar.getValueByName:

{"name":"Test"}

Response is successful but looks wrong to me:

{"version": "1.1","result": "0","error": null}

"0" is not the right value, as we just set it to "Bar".

"0" is a perfectly fine result here. You misunderstanding is, that you expect the actual value to be returned by SysVar.getValueByName for a valueList SysVar. But this is not the case. This method will return the actual index of the valueList as a value. Thus, the only "wrong" or incorrect thing in this issue ticket is the incorrect syntax of the SysVar.setEnum response json, which I will fix in the course of the RaspberryMatic development. This respository here is anyway the wrong one since no eq3 employee will take it and fix it. The right way is to post such things in the RaspberryMatic github and then a fix might flow back to the original CCU3 firmware one day...

jens-maus added a commit to jens-maus/RaspberryMatic that referenced this issue Jul 12, 2022
JSON related quoting fixes and also modify the SysVar.* json methods to
make sure that all these apply to system variable objects only and not
generally to all objects throughout rega (programs, devices, etc.).
This refs eq-3/occu#117 and eq-3/occu#118
@pmdevelopment
Copy link
Author

I got caught by the comment in the method, "Setzt den Wert einer Systemvariable", i was wondering why it asks for valueList but it was to logical for me, that this method should set the value 😄. At least setFloat and setBool are actual setting the value as expected, i will switch over to use some integer values to trigger my events.

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