Replies: 3 comments 7 replies
-
The root of these issues is a "round peg, square hole" problem. A library/controller simply can't provide the same level of functionality for devices that report state changes on their lifeline, devices that Hail a controller (hinting that something changed, but forcing the controller to poll everything and figure out what changed), and devices that don't report state changes. If it were possible to do this, there never would've been a need for the band-aid solution the Hail Command Class provided, or Z-Wave Plus Certification going as far as mandating a Lifeline association group. In my opinion, giving users the impression that even the oldest devices can have feature-parity with newer ones is misleading. I propose doing a little test, for giggles. Do this on a "real" Z-Wave network, i.e., not with a bunch of devices lying on your desk in direct range of each other - build something that tries to resemble reality, or use the network in your home if you have one. Send a few As the library author, you understand this limitation. A user with a 3-node Z-Wave network making a feature request for polling likely doesn't. Maybe there's lots of these kinds of users. Maybe you do want the library to support their use case. At least now you know there's a very low feasibility ceiling and you can prepare yourself for the issues related to network traffic and latency this will generate. I alluded to this in one of the other discussions, but really ask yourself: how much time do you spend looking at a screen with the "status" of your lights? Sure, a lot during development and when giving demos, but in real use cases? Device and System manufacturers figured this out a long time ago. When's the last time you saw a wireless switch, that's not directly wired to the load it controls, having an LED indicating what the state of the load it controls is?
The problem is when you're polling you're not seeing the current state of your devices, are you? You're seeing the states the devices had the last time you polled them - the state that's in the cache. You'll buy into the illusion that what you're seeing is their current state if that cached information is right the majority of the time, and that depends on how often the devices' states change and what the poll interval is. Look around at the commercially-available wireless control systems that are based on polling - the one thing they have in common is that there is a single controller in the network through which all state changes happen. When you can't guarantee this, the experience falls apart.
We can discuss that, but I agree it's not the preferred approach for most. On the flip side, the question of having the network state cached locally, correctly, isn't about whether it's practical, it's about whether it's possible. You'll inevitably have the scenario where the cache is wrong. However, there's lots of successful applications and UIs that do this and live with these issues - I'm not trying to sell you on the idea that you shouldn't have a cache - I'm just pointing out that it can't be trusted, no matter how much work is thrown into it, and in my opinion shouldn't be an area of focus in the beginning.
I guess you mean toggle a switch from the UI. This must happen, or the UI feels unresponsive. When you're the one sending the command, you know exactly when and how to verify it worked, so this is entirely doable.
I would argue that because this management operation is done very rarely, it's preferable to have this operation take "a long time" and always show fresh, valid data over constantly polling this information for changes in the background, only to sit in a cache and not be able to guarantee the information is still valid when presenting it. Note that Non-Listening (NL) nodes are an interesting exception. You can't request fresh data from them when they're sleeping, but because they're required to send their Wake-Up Notification to one, and only one, controller, you can guarantee that whatever cache you maintain for these devices is valid if you're the recipient of the Wake-Up Notification. Again, I'm not trying to say that caches are evil and shouldn't be used - just that they should be used "responsibly."
What would the library use the information in these two bullets for, that is so critical to have at startup?
NIFs are required by Z-Wave to be static throughout the lifetime of a device in a network, so the supported Command Classes can't change from what was collected during the first interview. Their versions could, if a firmware update was performed, but seeing as how (with very few exceptions) Commands Classes are backwards compatible and OTA updates a rare event, refreshing the information at every boot cycle doesn't really seem to be worth it. While we're on this topic, it's worthwhile pulling up the Z-Wave Plus v2 spec. and reading up on their initial device interview recommendations. Pulling all of this information down in one go is not a good idea. I know of cases with devices based off of CR2032 batteries that can't supply constant current for too long that brown-out during these long interview processes. It's important to remember that Z-Wave is meant to be a Command & Control protocol, and that care must be taken when using it to transfer data.
As with above, static endpoints are static. Dynamic endpoints can change after the restart of the library, so that cached information can't be trusted to be valid.
I can see why this would be useful, but this doesn't sound like the library's responsibility. The library isn't going to clean-up automations defined in any of the clients, so why should it take over responsibility of cleaning up Associations? Even if the library does this, it would be irresponsible to blindly trust that what's in the cache is valid and start removing associations - it'd have to verify them anyway. The same applies to scenes, etc. |
Beta Was this translation helpful? Give feedback.
-
Have you been looking at the control specification which also outlines the minimum interview following an inclusion: https://www.silabs.com/documents/login/miscellaneous/SDS14223-Z-Wave-Command-Class-Control-Specification.pdf |
Beta Was this translation helpful? Give feedback.
-
With #2030, we no longer query everything on restart if it was queried before. |
Beta Was this translation helpful? Give feedback.
-
@hanskroner, @LordMike: A bit of followup to #1355 - I also had it on my list of questions. This is kinda two (or three) topics in one, but they are tightly coupled IMO.
We're facing some expectations (which also touches on #1417) from users regarding what this library should do. I guess a lot comes from resistance to change...
OZW did it all a certain way (update values on startup, give feedback, etc.). This is what users are used to, this is how it has worked for the last 10 years. Some people even consider their devices broken if they don't see updates. A few examples:
I can understand these expectations - in fact I started to build zwave-js with a very similar use case in mind. ioBroker.zwave2 (what I originally wrote this for) mirrors the Z-Wave values into so-called states. Automations and visualizations use these states to display info and control devices. The entire concept builds on having the status of some system mirrored. In visualizations I want to always see the current state of my devices. For example, here are some switches displaying if a light is on or off:
I don't think it is practical for visualizations to refresh the displayed values on demand due to the inherent delay. Similarly, if I toggle a switch, I expect feedback that it worked.
The same can be said for management interfaces. I could build a UI for managing associations in a way that queries them on demand. If that UI would display all associations for all nodes, that list could take a long time to generate. If querying is done beforehand, the chance is very high that the cached info is good enough.
Now you could argue that this isn't anything that a driver should do. Basically it shouldn't care about all of this and just abstract away the heavy lifting: message serialization and parsing, managing queues and transactions, encryption, etc...
I tend to agree. But in any case we would need to continue doing the application layer work we already do - albeit in another module that you can opt-in to use. If we were to throw it all out, home automation systems would have to rework a lot and I fear many users would drop
zwave-js
like a hot potato.This leaves the question what we actually need to query on startup, a) to make the driver work and b) to keep the application layer up to date.
A few things that come to mind for a):
Beta Was this translation helpful? Give feedback.
All reactions