zha: additional sensors#12515
Conversation
There was a problem hiding this comment.
blank line at end of file
blank line contains whitespace
There was a problem hiding this comment.
blank line at end of file
blank line contains whitespace
There was a problem hiding this comment.
continuation line under-indented for visual indent
There was a problem hiding this comment.
line too long (80 > 79 characters)
There was a problem hiding this comment.
block comment should start with '# '
There was a problem hiding this comment.
block comment should start with '# '
There was a problem hiding this comment.
continuation line under-indented for visual indent
rcloran
left a comment
There was a problem hiding this comment.
This mostly looks good to me.
I'd prefer to handle the device quirks (Centralite-specific battery sensor) in zigpy, where we can expose a consistent interface to hass. I'd be OKish with this going in and changing to use the normal BatterySensor when zigpy quirks handling is ready, though.
Please send in PR to zigpy for the battery size enum, happy to add that in and bump the release for you.
There was a problem hiding this comment.
I assume this kind of device is normally wired, and so polling it is OK? Have you tried configuring reporting on your device? That'd be a better option.
There was a problem hiding this comment.
Yep, they're wired devices and the electrical measurement cluster attributes don't support reporting according to the ZCL docs.
There was a problem hiding this comment.
This should go into zigpy as an enum, as it is part of the standard.
There was a problem hiding this comment.
I'll submit a PR to zigpy for this
There was a problem hiding this comment.
I don't think this should live in Home Assistant.
There was a problem hiding this comment.
"I'd be OKish with this going in and changing to use the normal BatterySensor when zigpy quirks handling is ready, though."
Will leave here until quirks mode is ready.
|
Is there still plans to push this out? |
|
I agree this PR has some very critical functionality. Battery reporting for a contact sensor is really important. Not knowing when your device battery is going to run out poses a security risk for any alarm. |
|
I've just force pushed to https://github.com/dmulcahey/home-assistant/tree/dfm/zha-sensors to get travis to re-run. |
|
should @asyncio.coroutine/yeiled from" be updated to use "async def/await" syntax? |
|
Any chance we can at least split out the Battery aspect of this PR and merge it in? Many users are waiting for this functionality so we can know when a |
|
@dmulcahey and @rcloran I wanted to provide some feedback on this PR as yesterday I had time to pull in this PR into my own environment to test things out. I can confirm the energy reporting is working as expected. I am not so certain about the battery reporting. As of this morning some of my Iris Contact Sensors had checked in but the battery level reported is 100% which can't be right. On top of that it seems I got duplicate battery entity ID's as well. Looking at the code in |
|
I might give this a whirl if I have time this week. I only have smart thing devices though and @dshokouhi looks like he already confirmed this. |
|
This PR is a great example why one should limit PRs to a single feature. We could have merged the working parts already. |
|
What needs to be done to get this finished and who is going to do this? Would someone want to open smaller PRs containing a single feature from this PR ? |
|
@balloob from my perspective it all works. It is my understanding that others are expecting the battery reporting to work for the rebranded smart things centralite sensors. That's where the concerns seem to be on battery reporting not working. I am assuming that they modified the manufacturer check to reference smartthings instead of centralite. I could be completely wrong but that is my guess. This is tested and it is currently working for stock centralite sensors and I have been running it locally since I opened the PR. I will gladly break this up into multiple PR's if it makes things easier. Sorry for causing a stir with my first PR! |
|
@dmulcahey the device I used this PR on is a Iris Contact Sensor second generation. I believe that is the same one you used correct? For Energy Reporting I am using a Iris Smart Plug second generation. I do agree that I have seen others mention the SmartThings rebranded ones but personally I did not modify your PR at all in that regard so to me it is working. The only real issue I saw was that duplicate battery sensors got added as you can see in my screenshot above. |
|
Whats the path for supported other sensor (such as Smartthings) once this is merged. Is it just keep extending the zha.py and add additional derived GenericBatterySensor classes? Or do we want to wait to add this functionality into zigpy once the quirks handling is complete? |
|
@ryanwinter Quirks handling should help this... but I think we’ll still have a bunch of custom sensor classes just in a different format. @rcloran, any thoughts on this? |
| def state(self): | ||
| """Return the state of the entity.""" | ||
| if self._state == 'unknown': | ||
| return 'unknown' |
There was a problem hiding this comment.
Return None to represent unknown state.
There was a problem hiding this comment.
Why are multiple input values mapped to the same output percentage?
28, 27 and 26 are 100%
Why not 28=100, 27=97, 26=93? (or something like that)
There was a problem hiding this comment.
@ryanwinter please move your comment to a general PR comment. I don't see that it's related to my comment or this code line.
| elif self._state > self.maxVolts: | ||
| self._state = self.maxVolts | ||
|
|
||
| return self.values.get(self._state, 'unknown') |
| def state(self): | ||
| """Return the state of the entity.""" | ||
| if self._state == 'unknown': | ||
| return 'unknown' |
| def state(self): | ||
| """Return the state of the entity.""" | ||
| if self._state == 'unknown': | ||
| return 'unknown' |
| def state(self): | ||
| """Return the state of the entity.""" | ||
| if self._state == 'unknown': | ||
| return 'unknown' |
|
@ryanwinter I pulled that map directly from a smartthings device handler. The code can be found here: https://github.com/varzac/SmartThingsPublic/blob/97bfe61baa464cdac8894a566f19bcd6cc3c68c7/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy |
|
Hey all I think this PR needs to be rebased or updated now as it has conflicts and parts of it is no longer working for me. After updating to 0.69 energy reporting is no longer working. I made sure to place back the files that got overwritten. Battery reporting is still working so parts of it seems to be ok. |
|
@dshokouhi I’m going to close this. I’ll open smaller independent ones. |
|
Happy to help test anything if you need it! |
|
@dshokouhi #14563 #14562 #14561 have been opened. @MartinHjelmare I addressed the relevant comments in those PR's. @balloob sorry again for all of the churn that this caused! |
|
thanks @dmulcahey !! Will check out the PR's soon :) The battery reporting has actually been working pretty well so far too, my centralite devices are definitely reporting. Thanks for much for submitting the PR's :) |

Description:
Updates ZHA with the following changes: