OpenZWave / node-openzwave-shared

OpenZWave addon for Node.js (all versions) including management and security functions
Other
199 stars 113 forks source link

Multi-instance devices not getting mapped properly #361

Closed ekarak closed 4 years ago

ekarak commented 4 years ago

I upgraded my base OZW library to 1.6.1004 and I found out my multi-instance device only has one single ValueID mapped for the 2nd switch, I have no control over the 1st switch:

> nodes[5]['classes']['37']
{ '0':
   { value_id: '5-37-2-0',
     node_id: 5,
     class_id: 37,
     type: 'bool',
     genre: 'user',
     instance: 2,
     index: 0,
     label: 'Instance 2: Switch',
     units: '',
     help: 'Turn On/Off Device',
     read_only: false,
     write_only: false,
     min: 0,
     max: 0,
     is_polled: false,
     value: false } }
> 

This really should be at least two ValueIDs here, one for each instance. Investigating...

ekarak commented 4 years ago

the value.index is always '0' for all three instances, hence the following code now overwrites the values...:

zwave.on('value added', function(nodeid, comclass, value) {
  if (!nodes[nodeid]['classes'][comclass])
    nodes[nodeid]['classes'][comclass] = {};
  console.log(value);
  nodes[nodeid]['classes'][comclass][value.index] = value;
});
ekarak commented 4 years ago

uint16 OpenZWave::ValueID::GetIndex ( ) const | uint16 Get the value index. The index is used to identify one of multiple values created and managed by a command class. In the case of configurable parameters (handled by the configuration command class), the index is the same as the parameter ID. Knowledge of command classes is not required to use OpenZWave, but this information is exposed in case it is of interest. Returns the value index within the command class.

Did the wrapper break when this transitioned to 16-bit integer?

Fishwaldo commented 4 years ago

To uniquely identify a value - a combination of Node/Instance/CommandClass and Index is required.

Or just use the ValueID key if your looking for a unique identifier.

(If you support multiple sticks (networks) then include HomeID above).

ekarak commented 4 years ago

Thanks @Fishwaldo ! The index used to be unique amongst ValueIDs under a command class. If I understand correctly that has changed and it is the instance+index combination that must be unique?

Fishwaldo commented 4 years ago

Nope. It was never unique. 2 instances with same command class would always have same index.

robertsLando commented 4 years ago

@ekarak In my case for node values I use an object and I use the valueid as key