OpenZWave / python-openzwave

Python wrapper for openzwave
Other
200 stars 141 forks source link

1.6 Update - UserCode CommandClass (python-openzwave) #169

Open Fishwaldo opened 5 years ago

Fishwaldo commented 5 years ago

As per the OZW 1.6 Release Notes, The UserCode CommandClass has been rewritten

Refer the the release notes on the background, but basically, the UserCode CommandClass will not expose all usercodes as a String ValueID rather than a RAW ValueID. As there are some devices that are not compliant with the specifications, a config option will revert those devices to a Raw ValueID type.

Need to confirm no update is required.

kdschlosser commented 5 years ago

I have some questions. on this.

A usercode gets stored into it's own value I am guessing. because of the access to a specific usercode via the index.

Since support for changing labels has been added, does this also include the labels for the usecodes? It would be nice if the user was able to provide a human friendly name to a usercode instead of an index.

I added a class that acts partially like a list and partially like an array that has key, value pairs. so the user can either use the index of the code to get or set the code. or they can also use a key that will check the label of the code entry. if it matches then return/set the code. if the user is setting the code and it does not exist then it will create a new one. I am hoping my assumptions on the labels is correct. It would be a pretty nice feature to have.

use example

print(node.usercodes[1])
node.usercodes[1] = '123456789'

print(node.usercodes['Some Code Name'])
node.usercodes['Some Code Name'] = '123456789

there are several ways to add a code


node.usercodes += ['123456789']
node.usercodes.append('123456789')

# if you want to add a bunch of codes
node.usercodes += ['123456789', '987654321', '567894321']
node.usercodes.extend(['123456789', '987654321', '567894321'])

the append and extend mechanisms will return True if the code(s) were added successfully and False if not. Not added would mean that the device cannot store any more codes.

for removing you can specify the index, code or label


node.remove(;123456789')
node.remove(1)
node.remove('Some Code Name')

the remove mechanism also return True or False

adding the above was all done in 80ish lines of code.

Fishwaldo commented 5 years ago

There is a Manager::SetValueLabel call, but I've honestly never seen anybody use it :)

kdschlosser commented 5 years ago

And it works?? LOL I ask that because it is a really simple idea. I am shocked that no one is doing it.

This would be a fantastic use for it. because it is far easier to remember say a persons name then the index. plus if an application has user authentication then the logged in user would only be able to change their own password.

and this is the bonus. an application author would not need to write code to maintain some kind of a config file entry if they wanted to attach a code to a user friendly name.

I've honestly never seen anybody use it :)

I bet you will see it get used now. LOL

Fishwaldo commented 5 years ago

The only challenge with using it is if you lose the ozwcache file the information gets lost.

I’d encourage people to do it in the application and not in OZW 😜

kdschlosser commented 5 years ago

you will lose the name to code mapping.. not the actual values. correct?

I may be wrong in this assumption as I have not looked at the contents of an ozwcache file. In that file I would image is the node name, node location. things of that nature. Those things are not actually stored on the controller or on the nodes themselves. so if the file gets lost then the names do as well. and it would have to be recreated.

if that is the case then the same would apply here.

This is for anyone that happens to read this issue. this is a suggestion and some information.

This is the reason why backups are essential. and not a backup on the same machine. or even in the same location. google drive, microsoft onedrive..... there are 100's of available free cloud storage servers.. Quite a few of them have applications that allow a type of drive/folder mapping to the storage space. so a simple file copy utility or script can be used to make a copy of the file.

Windows use RoboCopy to set up an automatic copy of the file. this can be done so it will make the copy if the file changes at all.

Linux or the like. I am sure a script can be made to perform the same operation as in Windows and add the script as a daemon.

as with any backup software/utility/script. it only knows 1's and 0's. it does not know what is and is not corrupted. so backing up corrupted data = restoring corrupted data. ROTATE THE BACKUPS! to not simple overwrite the last backup.

If you are paranoid and think that Google or Microsoft is going to be peering into your data.. encrypt the data then put it on their servers.

256 bit encryption (approximates)

bit combinations: 1157920892373161954235709850086900000000000000000000000000000000000000000000000000000000000000000000000000000

32 character key combinations: 144740111546645244279463731260860000000000000000000000000000000000000000000000000000000000000000000000000000

those are some really large numbers.