No, so they’re going to start cluttering up your device’s Advanced tab over time.
That also means that you need to nominate a value (empty string, or “0” or something else reasonable) that stands in for “deleted”, and when you read the variable check against this value as well as nil.
Create a user plugin and use this to hold the various user created variables, does add some complexity to make sure that the naming conventions are good to “find” the correct variable for a specific device, might need to think of using the device name + device ID to create the variable. not yet sure how do that with string conjugation. and might not even be possible with luup.
Is it possible to create a variable name using something like …
local name = “Sensor”+tostring(v)
luup.variable_set(SS_SID, name, somedata, v)
(where v is the device ID)
So if the variables get out of hand you should be able to delete the device and recreate the device. This will delete all user variables. In my case this is not a big issue I do not store long term variable so I will not lose valuable data, but it also smacks of bad programming techniques.
Is there a way to delete variables stored in a name space? For example, I can use the UI to create a new variable (the advanced tab). Is there a way to delete some? I know I can delete the whole device and create it again but I do not want to do that.
… or write a Luup plugin, that removes variables (VRD - Variable Remover Device) - but joking aside: is there a specific reason why removing variables isn’t implemented in MiOS?
Maybe it’s harder to implement and it’s not worth allocating time for it? We’ll never know… though a Luup plugin that does this is possible. Any volunteers?
Ok. So I could uncompress and edit. After edit do I have to restart some services? Or reboot? Can I copy the old file in place as a backup in case I make a mistake and destroy the whole system? How save is this operation?
In general, I would say you could just add a variable delete button to the advanced tab (I know, you probably don’t like the idea because you would have a lot of dopes that delete variables and then complain that the system is not working)
[ol][li]Stop LuaUPnP:
[tt]/etc/init.d/cmh stop[/tt][/li]
[li]Make a backup of you current user_data (/etc/cmh/user_data.json.lzo)[/li]
[li]Uncompress user_data
[tt]pluto-lzo d /etc/cmh/user_data.json.lzo /tmp/user_data.json[/tt][/li]
[li]Remove the variables you want (see how variables look in the user_data in the code below)[/li]
[li]Validate your new user_data on http://jsonlint.com[/li]
[li]Compress the new user_data
[tt]pluto-lzo c /tmp/user_data.json /etc/cmh/user_data.json.lzo[/tt][/li]
[li]Start LuaUPnP
[tt]/etc/init.d/cmh start[/tt][/li][/ol]
I’d say that the most important steps are to make a backup of the old user_data and to check your new user_data on http://jsonlint.com. If these steps are made, then the whole operation is pretty safe.
The above steps works fine, apart from the validator that times out in my FF browser.
This link is more stable and provides option to format the json for easier reading: [url=http://jsonformatter.curiousconcept.com/]http://jsonformatter.curiousconcept.com/[/url]
Voting +1 for a convenience method to delete variables, like so: luup.variable_delete(service, name, device_id)
Thanks.
[quote=“mcvflorin, post:14, topic:169472”]Follow these steps:
[ol][li]Stop LuaUPnP:
[tt]/etc/init.d/cmh stop[/tt][/li]
[li]Make a backup of you current user_data (/etc/cmh/user_data.json.lzo)[/li]
[li]Uncompress user_data
[tt]pluto-lzo d /etc/cmh/user_data.json.lzo /tmp/user_data.json[/tt][/li][/ol][/quote]
Do I need putty for the last code or run this in the terminal?[/list]
I can confirm this method works on Vera Edge, but WTF Vera? How 'bout a little ‘delete’ button next to the user created variable that let’s use do this easily? I’d even put up with an “Are you sure?” prompt.