Add zwave_js.reset_meter service#53390
Conversation
|
Hey there @home-assistant/z-wave, mind taking a look at this pull request as its been labeled with an integration ( |
|
Is this something that users want to automate or is it enough with a manual form per device page? |
|
Can a node have multiple meters (via multi-channel endpoints), and if so want would you want to reset them individually? FYI, the legacy zwave implementation of this includes an instance (endpoint) attribute in the service call, and the zwave-js code also seems to be endpoint aware. I assume this is the case, but I don't have any devices with meters. Assuming multiple meters, then this change actually only finds one meter reset instance, meaning it wouldn't be possible to reset the others. The endpoint could be derived if the actual sensor entity for the meter value was passed into the service call instead, so the user doesn't need to be aware of endpoints. |
I don't use this CC so I can't say for sure, but I can imagine a scenario where a user wants the meter to be reset on a regular basis, like at the beginning of every month (or some other period). There may be some other use cases I am not aware of. The reason I went for a service call is because it's listed as one in the roadmap issue. With that being said, this would be easy enough to flip into a WS API call if that's what we think is best |
Hmm good points. There are two options here:
The fallback, if an endpoint isn't provided, is to use the existing logic. The fixtures that are available in the project do not have meters on multiple endpoints, but that doesn't mean it's not possible |
|
If HA had an entity for a momentary switch, e.g. "button", this would be the perfect application. All the meter reset capabilities, whether it's per-endpoint or per-meter-type, are already implemented with zwave-js values. You would just need a button per reset value, and some custom service to set the initial meter reset value (for those values with CC version >= 6). What about Device Actions, could those be an alternative? I'm imagining you could create an action corresponding to each zwave-js meter reset value. That would support all possible reset scenarios. It would also be completely obvious when the device supports only resetting all meter types, or allows resetting individual meter types. The only twist would be allowing the setting of that initial meter reset value for that specific case. |
|
I think |
Yes we can add these as device actions, and then to your point we can explicitly discover what's supported for each device and show a relevant action. Is there a proposal for a button platform anywhere or are you just brainstorming? If there's any legs on that idea, I would then vote to close this and wait until that's been created. |
|
@kpine requested this dump with multiple endpoint meters. |
There's no proposal AFAIK, that was just an idea. I'm sure there are other use cases out there for momentary switches besides z-wave, and I don't know what the usual solution is. Of course you could make these things switch entities too, they just don't have any real state, and can only be turned on. Not sure that would be acceptable. |
Got it. I think a service call is effectively our "button" at the moment. Can anyone confirm whether or not this is useful as a service call (pro: automatable, con: only feedback is through logging) vs something that can be manually triggered in the UI (pro: better feedback, con: not automatable)? |
|
Can we do both? |
|
when you say both, do you mean service and device action? or service and UI in config panel? I was planning to do the first one, not sure if the second pair makes all that much sense since the developer tools will already give you a service UI |
|
I think service makes the most sense. People will likely want to reset meters on a schedule (monthly/weekly/etc) |
|
Ya a service is perfect really. |
|
I'm wondering if we should make this an entity service that's registered off an entity with the Meter CC. That would reduce the instances of the service to those that actually may need it. |
|
Turns out we can't selectively enable it. If I attempt to register the service in the callback that creates the entities, the code can't get the current platform. So we'll just have to register it if the sensor platform gets created |
* Add zwave_js.meter_reset service * fix log statement * Add endpoint attribute to service call and rename service * Make service an entity service * remove endpoint from service description
Proposed change
It's been discussed in the past to add a meter reset service. With the introduction of the
invoke_cc_apicommand, we can now add support for this.Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: