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.deleteSysVarByName only softdeletes #118

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

JSON API SysVar.deleteSysVarByName only softdeletes #118

pmdevelopment opened this issue Jul 12, 2022 · 4 comments

Comments

@pmdevelopment
Copy link

To reproduce create a new SysVar, e.g. using SysVar.createEnum named "Test". Now call SysVar.deleteSysVarByName, the result shows success, SysVar.getAll won't list the variable anymore. Now create "Test" again, SysVar.getAll will show: it's listed as "Test 2", the original "Test" was only softdeleted. I couldn't figure out how to remove the original "Test" variable.

Creating and deleting using the WebUI will not reproduce this behaviour.

Hardware: CCU3
Software: 3.65.6

@jens-maus
Copy link

Please show an example payload with example response output and not just explain your issues with words. Show concrete examples!

@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.deleteSysVarByName:

{"name":"Test"}

Response is successful:

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

SysVar.getAll won't list the variable anymore, but e.g. SysVar.getValueByName will return:

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

Asking for a non-existing variable would look like this:

{"name":"Foobar"} => {"version": "1.1","result": "","error": null}

Now the payload to create the variable again:

{"name":"Test","valList":"A;B;C","internal":"0","chnID":"-1"}

The response shows our variable was created with a new name to prevent the conflict with our soft-deleted one:

{"version": "1.1","result": {'name':'Test 2','id':'6971','value':'A;B;C' },"error": null}

@jens-maus
Copy link

I am almost certain that the issue just happens because you have another object (device, channel, program, etc.) that has also the name "Test". Unfortunately, the SysVar.getValueByName function does not filter for system variables but applies the search to all objects, that's why your request for a "Test" system variable still matches, simply because the getValueByName function is doing the search wrong. This is something I will try to fix/optimized in RaspberryMatic.

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

It's definitly not because of "Test", my original Parameter was "APP_VENTILATION_STATUS". If you create, delete and recreate the same Systemvariable in the WebUI, the name won't add a number, it's only this behaviour with the JSON API.

I think the SysVar methods for the JSON API are just not used very often, i guess most software will program the channels directly instead of using a system variable change to trigger programs.

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