Adding helper for get and set values#5743
Conversation
|
@turbokongen, thanks for your PR! By analyzing the history of the files in this pull request, we identified @devdelay, @armills and @leoc to be potential reviewers. |
|
I think this is better than what's there right now, but I'm going to use this as a discussion for a further refactoring I've been mulling over for a while. The root use-case for these loops are Entities that need to reference more than one ZWave Value. Currently, entities are tied to one value, which is passed in when the entity is created. Right now we're looping over all the node values every time a different value needs to be looked up. The way I'd ultimately like to implement this is to refactor the discovery code to search for all the values that an entity needs. Right now in This way the ZWave entities will get a reference to the extra values they need as soon as its discovered by the ZWave network, and they won't need to do the search each time they need it. |
There was a problem hiding this comment.
member should be dropped here, since it's expecting a reference to the Value object.
There was a problem hiding this comment.
So this is expecting the object, and not the value.data?
There was a problem hiding this comment.
There was a problem hiding this comment.
My preference would be to make this an internal method, and add wrapper functions get_value and set_value. I think it's quicker to read and understand self.get_value/self.set_value in the code instead of self.value_handler.
There was a problem hiding this comment.
That was my initial thought, but since the code is nearly the same for both, I found it better to have an argument.
There was a problem hiding this comment.
I just mean something small like this, just to make it easier to read, but still keeping all the code common. Up to you, though.
def get_value(**kwargs)
return self._value_handler(method='get', **kwargs)There was a problem hiding this comment.
I didn't think of it that way :)
I will do that. 👍
There was a problem hiding this comment.
continuation line over-indented for visual indent
There was a problem hiding this comment.
continuation line over-indented for visual indent
There was a problem hiding this comment.
continuation line over-indented for visual indent
There was a problem hiding this comment.
continuation line over-indented for visual indent
There was a problem hiding this comment.
continuation line over-indented for visual indent
There was a problem hiding this comment.
continuation line over-indented for visual indent
There was a problem hiding this comment.
This was releasing either the 'Open' or 'Down' button
There was a problem hiding this comment.
Since we now get the value_id of a valid entry for the node, we don't need both.
https://github.com/turbokongen/home-assistant/blob/f44c55d1012a7b5eb5058197b21c271d50e79e68/homeassistant/components/cover/zwave.py#L81
There was a problem hiding this comment.
I wasn't clear: Previously it was releasing both buttons: Open for open and Down for close (maybe should have released all 4 names).
But now you are only releasing _open, so I would expect stop_cover not to work while the cover is closing.
There was a problem hiding this comment.
The way the releasbutton command in OZW works is not like the naming would suggest.
releasebutton triggers a stop command, and pressbutton triggers a start command.
https://github.com/OpenZWave/open-zwave/blob/master/cpp/src/Manager.cpp#L3028
There was a problem hiding this comment.
Also, before I had Open or Down as stop alternatives, because it would work on either type of devices regardless if they had Open, Close or Up, Down label pairs.
There was a problem hiding this comment.
Are you saying the ID doesn't matter?
value->ReleaseButton is called on a specific ID.
I don't have a cover device to test this. Does this work for you for stopping both open & close movement?
There was a problem hiding this comment.
I don't have a cover device either, but yes. Calling the release button on either open,close or up,down labels will stop the level change. That is how the old code was made. 👍
There was a problem hiding this comment.
Why did you drop the rounding?
There was a problem hiding this comment.
Changes must have been made to OZW since I made the HVAC/climate component. Then it was not working without rounding. Now it responds perfectly to the set .5 intervals.
There was a problem hiding this comment.
Did you drop the temperature rounding on purpose?
There was a problem hiding this comment.
|
The last committ, I need somebody to test if that really works, as this is just based on how I read the code. |
|
@turbokongen I don't have a cover device :( |
a5458cd to
4bd32e8
Compare
13099a0 to
a8598ba
Compare
a8598ba to
8a7799e
Compare
balloob
left a comment
There was a problem hiding this comment.
🐬 ok to merge when you have resolved the conflicts.
|
@armills I like that idea, should we move that discussion to an issue? |
|
@balloob I'll probably just open a PR at some point with at least a proof of concept, and we can discuss it there. |
Description:
Ref: #5619 (review)
I'm not sure if this is any helpful at all, only gaining 6 less lines of code.
Discussion open :)