python-openzwave-mqtt icon indicating copy to clipboard operation
python-openzwave-mqtt copied to clipboard

Move all constants to the library

Open marcelveldt opened this issue 5 years ago • 9 comments

Constants are spread across the lib and the hass component. I want to move them into the library. At the same time the Command Classes are being mixed up between string's and int's. We need to fix that.

I will start working on this this weekend but we might need to discuss how we want to handle the Command Classes in a consequent way.

marcelveldt avatar Feb 14 '20 08:02 marcelveldt

In the value payloads the command class is listed as a string, which is typically what we're checking command classes against. However the parent commandclass topics use the command class ID and the payload has both a CommandClass string and a CommandClassId integer.

cgarwood avatar Feb 14 '20 12:02 cgarwood

Please use the integer to test in code. The specs has (and will probably continue) to change the names of command classes previously.

If there is a entity where it’s a name without a ID, let me know, I’ll add it.

The “string” representations could be used as GUI elements I guess... 😜

Fishwaldo avatar Feb 14 '20 17:02 Fishwaldo

OK, so we'll go with the int's, probably even an enum.

marcelveldt avatar Feb 15 '20 15:02 marcelveldt

@Fishwaldo do you have a list/enum of all available commandclasses available ?

So, we will just go ahead and only use the ID. Maybe it's a good thing to also rename the keys in the json returned by OZW ?

CommandClassId --> CommandClass (int of CC) CommandClass --> CommandClassLabel (str)

marcelveldt avatar Feb 17 '20 19:02 marcelveldt

You can get it from here: https://www.silabs.com/documents/login/miscellaneous/SDS13548-List-of-defined-Z-Wave-Command-Classes.xlsx

I'll look at the JSON soon and update

Fishwaldo avatar Feb 18 '20 05:02 Fishwaldo

all Z-wave specific constants are now moved to the library. Thing left to do is perhaps prettify the device specific/generic constants into some enums. This is now just one bulky list.

marcelveldt avatar May 01 '20 09:05 marcelveldt

One more TODO is the ValueIndex constants. Problem is that each CommandClass has it's own Values so the ValueIndexes are not unique. Would be great if we can figure out a generic approach to have the ValueIndex property correctly set to the correct CommandClass

https://github.com/cgarwood/python-openzwave-mqtt/blob/master/openzwavemqtt/models/value.py#L67

marcelveldt avatar Jul 10 '20 12:07 marcelveldt

Could we have a CC data class that maps the CC to the ValueIndex enum of the CC? We have the CC available in the OZWValue class so then it's easy to use that in the lookup in the method.

MartinHjelmare avatar Jul 10 '20 12:07 MartinHjelmare

Yeah, I was indeed thinking in that same direction.

marcelveldt avatar Jul 10 '20 12:07 marcelveldt