-
-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: multicast/broadcast apis #25
Conversation
Pull Request Test Coverage Report for Build 653435850
💛 - Coveralls |
lib/Gateway.js
Outdated
for (let i = 0; i < values.length; i++) { | ||
const valueId = this.topicValues[values[i]] | ||
if (nodes.indexOf(valueId.nodeId) >= 0) { | ||
this.zwave.writeValue(valueId, payload.value) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm never a fan of this syntax.
personally find
values
.filter(value => nodes.includes(this.topicValues[value].nodeId))
.forEach(value => this.zwave.writeValue(this.topicValues[value], payload.value))
easier to read, but may just personal choice
README.md
Outdated
@@ -728,6 +729,30 @@ I will set the Heating setpoint of the node with id `4` located in the `office` | |||
|
|||
`zwave/office/nodeID_4/thermostat_setpoint/heating` | |||
|
|||
### Multicast | |||
|
|||
You can send Multicast requests to _all values with a specific suffix_ of a _group_ of nodes in the network. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really clear on this, maybe provide a use case from the outset such as adjusting all your thermostats/lights?
be clearer that this is just a shorthand, it's not an actual multicast, behind the scenes zj2m is doing the heavy lifting and iterating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zwave-js
does support actual multicast (if you use the same command and target the same endpoint of all nodes).
But it doesn't go through the commandClasses
API that is being used here. Might be a good idea for a new feature , so you can grab a group of nodes and send a single multicast command to all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've raised zwave-js/node-zwave-js#1150 to track that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, what you can do already is this:
const cmd = new BinarySwitchCCSet(driver, {
nodeId: [2,3,4,5],
targetValue: true,
});
await driver.sendCommand(cmd);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with that i really would like to send a group of nodes the command at the same time using a real multicast if that is possible.
Why, because i found it nice that all nodes respond at the same time, now it takes upto 5 seconds to respond.
Which is also generating errors like #26
My feeling about this is that since all these nodes are generating data (e.g. power reports, closing / dimming duration reports) that it become quite busy on the network, therefore i would like to send it using a real multicast to the nodes so that they all do receive the command before it is getting busy on the network.
If i see it now it looks like this is the same as what i can do within openhab
Shutters_Goup_All.members.forEach[ shutter | shutter.sendCommand(100) ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should wait for: zwave-js/node-zwave-js#1150 Before going on with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, what you can do already is this:
@AlCalzone How could I get the correct command class constructor based on the command class id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't see this...
https://github.com/zwave-js/node-zwave-js/blob/daf0feb9bfe14ae5b9a24c0d0d53206d5bdd41e9/packages/zwave-js/src/lib/commandclass/CommandClass.ts#L1057-L1059
But I'm not sure if that is exported through the main entry point.
README.md
Outdated
@@ -728,6 +729,30 @@ I will set the Heating setpoint of the node with id `4` located in the `office` | |||
|
|||
`zwave/office/nodeID_4/thermostat_setpoint/heating` | |||
|
|||
### Multicast | |||
|
|||
You can send Multicast requests to _all values with a specific suffix_ of a _group_ of nodes in the network. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with that i really would like to send a group of nodes the command at the same time using a real multicast if that is possible.
Why, because i found it nice that all nodes respond at the same time, now it takes upto 5 seconds to respond.
Which is also generating errors like #26
My feeling about this is that since all these nodes are generating data (e.g. power reports, closing / dimming duration reports) that it become quite busy on the network, therefore i would like to send it using a real multicast to the nodes so that they all do receive the command before it is getting busy on the network.
If i see it now it looks like this is the same as what i can do within openhab
Shutters_Goup_All.members.forEach[ shutter | shutter.sendCommand(100) ]
@ODINServ Could you give this a try? |
@ODINServ @AlCalzone I'm still not 100% sure about using this way as it just works for not secure devices. I think the old way was 'dirty' and slow but at least it works |
What about this approach you could extend later when we have S2 support to create and use S2 Multicast groups.
The tricky part about real multicast is that you can only use it for set-type commands, not ones that expect a response. |
try { | ||
const multicastGroup = this.driver.controller.getMulticastGroup(nodes) | ||
|
||
await multicastGroup.setValue(valueId, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I wrote in my comment, I would check for ZWaveErrorCodes.CC_NotSupported
and fall back to iterating singlecast requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlCalzone Could this cause multiple writes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the checks happen before anything is sent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
🚧 It seems like this PR has lint errors 🚧 |
Multicast SETs don't poll (because that would require one GET for each node, defeating the purpose of a multicast). But we should assume that the command was accepted by all nodes if it succeeds like we already do for singlecasts. |
I was very busy lately and did not have any time to work on my home automation stuff. So to summarize what i did:
From: @blhoward2
Agreed maby this feature requests will solve this: #70 I'd switched to this branch (without linking the node-zwave-js module) and tested it. For me with my FGR223 modules this is working as expected with the same results and question that @blhoward2 has.
From @AlCalzone
So when using the (new) broadcast API, the values are updated when (in my case) the shutters reach there targetValue, not sure if this info helps. |
🚧 It seems like this PR has lint errors 🚧
I should be able to fix them for you. If you want me to, just comment |
3 similar comments
🚧 It seems like this PR has lint errors 🚧
I should be able to fix them for you. If you want me to, just comment |
🚧 It seems like this PR has lint errors 🚧
I should be able to fix them for you. If you want me to, just comment |
🚧 It seems like this PR has lint errors 🚧
I should be able to fix them for you. If you want me to, just comment |
@blhoward2 Could you give this a try? |
🚧 It seems like this PR has lint errors 🚧
I should be able to fix them for you. If you want me to, just comment |
🚧 It seems like this PR has lint errors 🚧
I should be able to fix them for you. If you want me to, just comment |
@robertsLando So I've tested this around a dozen times on a variety of devices and it seems to work pretty flawlessly. The weirdness I had before with one switch that didn't go off the full way has resolved itself. Some of my switches do in fact call back in their new state, so they update in HA. For others, they do not change as we're still waiting on @AlCalzone for zwave-js/node-zwave-js#1550. I think this is ready to go. Topic: homeassistant/_CLIENTS/ZWAVE_GATEWAY-MQTT/multicast/set { |
Thanks for your feedback @blhoward2, based on this seems that it should be good on my side, can I merge this? |
Fixes #24