cgarwood / python-openzwave-mqtt

Python wrapper for OpenZWave's MQTT daemon
Apache License 2.0
49 stars 7 forks source link

Move all constants to the library #49

Open marcelveldt opened 4 years ago

marcelveldt commented 4 years ago

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.

cgarwood commented 4 years ago

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.

Fishwaldo commented 4 years ago

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... 😜

marcelveldt commented 4 years ago

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

marcelveldt commented 4 years ago

@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)

Fishwaldo commented 4 years ago

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

marcelveldt commented 4 years ago

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 commented 4 years ago

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

MartinHjelmare commented 4 years ago

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.

marcelveldt commented 4 years ago

Yeah, I was indeed thinking in that same direction.