Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
10000 commits
Select commit Hold shift + click to select a range
7652064
Update neato to support new StateVacuumDevice (#16035)
dshokouhi Aug 18, 2018
55b7fdb
vacuum/xiaomi_miio: Expose "sensor_dirty_left" attribute (#16003)
klada Aug 19, 2018
2dcfde6
Add forgiving add column (#16057)
balloob Aug 19, 2018
2fc0afc
Tuya fix login problem and add login platform param (#16058)
huangyupeng Aug 19, 2018
75fca41
Add notify platforms to loaded components (#16063)
balloob Aug 19, 2018
618cf6b
Column syntax fix + Add a file if migration in progress (#16061)
balloob Aug 19, 2018
f25430e
Add forgiving add column (#16057)
balloob Aug 19, 2018
6f4306f
Tuya fix login problem and add login platform param (#16058)
huangyupeng Aug 19, 2018
86a4e35
Add notify platforms to loaded components (#16063)
balloob Aug 19, 2018
cc70f95
Bumped version to 0.76.1
balloob Aug 19, 2018
f2d756f
Column syntax fix + Add a file if migration in progress (#16061)
balloob Aug 19, 2018
723d53f
Merge pull request #16064 from home-assistant/rc
balloob Aug 19, 2018
a739b0f
Grammar and spelling fixes (#16065)
scop Aug 19, 2018
fb775b6
Update frontend to 20180820.0
balloob Aug 20, 2018
b52beaa
Update frontend to 20180820.0
balloob Aug 20, 2018
38b2a5c
Use aiohttp web.AppRunner (#16020)
balloob Aug 20, 2018
9a42276
Update pushsafer.py (#16060)
appzer Aug 20, 2018
71ff499
Alexa: context + log events (#16023)
balloob Aug 20, 2018
30ce29a
openuv: Add Current UV Level to list of conditions (#16042)
leppa Aug 20, 2018
4122fb7
TpLink Device Tracker Error (#15918)
TimBailey-pnk Aug 20, 2018
a7ee41f
Deprecated stuff (#16019)
balloob Aug 20, 2018
e0337cc
Add recent context (#15989)
balloob Aug 20, 2018
422fab6
Add ecovacs component (#15520)
OverloadUT Aug 20, 2018
8151e85
Bumped NDMS2 client library to 0.0.4 to get compatible with python 3.…
foxel Aug 20, 2018
6841a36
fritzdect change to current_power_w (#16079)
Danielhiversen Aug 20, 2018
9bbd656
Update pyhomematic to 0.1.47 (#16083)
danielperna84 Aug 20, 2018
fb867c9
Get user after login flow finished (#16047)
awarecan Aug 21, 2018
d66d24f
Upgrade pytest to 3.7.2 (#16091)
scop Aug 21, 2018
c5432f4
Forgiving add index in migration (#16092)
balloob Aug 21, 2018
eb56c2b
Forgiving add index in migration (#16092)
balloob Aug 21, 2018
d93b04b
Bumped version to 0.76.2
balloob Aug 21, 2018
a1d8050
Merge pull request #16094 from home-assistant/rc
balloob Aug 21, 2018
3229a98
Add verify ssl to generic camera (#15949)
fliphess Aug 21, 2018
146d14c
Upgrade afsapi to 0.0.4, prevents aiohttp session close message, Fixe…
zhelev Aug 21, 2018
f4d0454
Remove homeassistant.remote (#16099)
balloob Aug 21, 2018
f681c14
Use new session when fetching remote urls (#16093)
balloob Aug 21, 2018
44a3257
Allow finish_flow callback to change data entry result type (#16100)
awarecan Aug 21, 2018
09bfe99
Add support for revoking refresh tokens (#16095)
balloob Aug 21, 2018
1f9a133
Refactoring login flow (#16104)
awarecan Aug 21, 2018
5a9e070
Minor updates (#16106)
fabaff Aug 21, 2018
3b4d783
Bump python-miio version (#16110)
syssi Aug 21, 2018
9feb51f
homematic: Add homematic.put_paramset service (#16024)
klada Aug 21, 2018
e30fb6f
Upgrade shodan to 1.9.1 (#16113)
fabaff Aug 22, 2018
2c47ec1
Upgrade sendgrid to 5.6.0 (#16111)
fabaff Aug 22, 2018
349457d
Merge insteon_plm and insteon_local to insteon component (#16102)
teharris1 Aug 22, 2018
5062641
Remove unit_of_measurement from climate entities (#16012)
jeradM Aug 22, 2018
eb930d3
Add multi-factor authentication modules (#15489)
awarecan Aug 22, 2018
678025e
Device Registry (#15980)
Kane610 Aug 22, 2018
0115a11
Check correctly if package is loadable (#16121)
balloob Aug 22, 2018
bfe8a9a
Upgrade numpy to 1.15.1 (#16126)
fabaff Aug 22, 2018
2fd09a2
Upgrade youtube_dl to 2018.08.22 (#16125)
fabaff Aug 22, 2018
800db0c
Fix the protocol v2 data_key of several aqara devices (#16112)
syssi Aug 22, 2018
358562d
Upgrade brunt package (#16130)
eavanvalkenburg Aug 22, 2018
7e27ded
Add support for NOAA tide information (new PR) (#15947)
jcconnell Aug 22, 2018
c14b3a7
Adds support for routers implementing IGDv2 (#16108)
dgomes Aug 23, 2018
054fe9b
Add support for JS modules in custom panels (#16096)
villanyibalint Aug 23, 2018
ea4fce1
Prevent legacy api password with empty password (#16127)
balloob Aug 23, 2018
ba0cc5f
Enable auth by default 🙈 (#16107)
balloob Aug 23, 2018
51d179e
Remove commented out API password from default config (#16147)
balloob Aug 23, 2018
96d6fc9
Spelling fixes (#16150)
scop Aug 23, 2018
5bec8b9
Update pydocstyle to 2.1.1 and flake8-docstrings to 1.3.0 (#14557)
scop Aug 24, 2018
163fd26
Hangouts (#16049)
hobbypunk90 Aug 24, 2018
045ff3f
Bump frontend to 20180824.0
balloob Aug 24, 2018
631c02d
Update translations
balloob Aug 24, 2018
9b51c84
Hangouts localization typo fix (#16174)
emlove Aug 24, 2018
f187172
deCONZ - Allow sub second light transitions (#16170)
Kane610 Aug 24, 2018
73f205f
add_devices -> add_entities (#16171)
balloob Aug 24, 2018
1a496a8
Merge remote-tracking branch 'origin/master' into dev
balloob Aug 24, 2018
d272bc3
Bumped version to 0.77.0b0
balloob Aug 24, 2018
7675624
Add multi-factor auth module setup flow (#16141)
awarecan Aug 24, 2018
a6bf5f4
deCONZ - Support device registry (#16115)
Kane610 Aug 24, 2018
296dfdb
fix error message for cv.matches_regex (#16175)
heythisisnate Aug 24, 2018
06f6791
Decouple Konnected entity setup from discovery (#16146)
heythisisnate Aug 24, 2018
1915dcf
Add 'moon_phase' to Dark Sky sensor (#16179)
fabaff Aug 24, 2018
4129a77
Tweak log level for bearer token warning (#16182)
awarecan Aug 25, 2018
5ff7e6e
Device registry store config entry (#16152)
Kane610 Aug 25, 2018
7e6647d
Fix hangouts (#16180)
balloob Aug 25, 2018
921a265
Default load trusted_network auth provider if configured trusted netw…
awarecan Aug 25, 2018
35d501e
Bump frontend to 20180825.0
balloob Aug 25, 2018
cf2bb43
Bump frontend to 20180825.0
balloob Aug 25, 2018
8c59130
deCONZ - Support device registry (#16115)
Kane610 Aug 24, 2018
ac613a0
Add multi-factor auth module setup flow (#16141)
awarecan Aug 24, 2018
d47825f
Decouple Konnected entity setup from discovery (#16146)
heythisisnate Aug 24, 2018
d682fba
Device registry store config entry (#16152)
Kane610 Aug 25, 2018
1eb5ee7
fix error message for cv.matches_regex (#16175)
heythisisnate Aug 24, 2018
b0eaa65
Fix hangouts (#16180)
balloob Aug 25, 2018
7783e03
Tweak log level for bearer token warning (#16182)
awarecan Aug 25, 2018
28416ca
Default load trusted_network auth provider if configured trusted netw…
awarecan Aug 25, 2018
1164d3f
Bumped version to 0.77.0b1
balloob Aug 25, 2018
162ec80
Zoneminder SSL fix (#16157)
djm300 Aug 25, 2018
1ec363d
update python-velbus library version (#16194)
thomasdelaet Aug 25, 2018
5675aef
MQTT: Log transmitted as well as received messages (#16195)
smurfix Aug 26, 2018
d929608
homematic: Make device avilable again when UNREACH becomes False (#16…
klada Aug 26, 2018
db6895f
Upgrade sqlalchemy to 1.2.11 (#16192)
fabaff Aug 26, 2018
f099521
Add battery warning, rssi level and check for availability (#16193)
fucm Aug 26, 2018
cf9aabd
Revert changes to platforms using self.device (#16209)
Kane610 Aug 26, 2018
eba2e8d
Inconsistent entity_id when multiple sensors (#16205)
grea09 Aug 26, 2018
7ffbdae
remove hangouts.users state, simplifies hangouts.conversations (#16191)
hobbypunk90 Aug 26, 2018
2fc1e68
Handle exception from pillow (#16190)
PhracturedBlue Aug 26, 2018
28f1708
Update frontend to 20180826.0
balloob Aug 26, 2018
e8398ac
Update frontend to 20180826.0
balloob Aug 26, 2018
3ffcbf2
Update aiohttp to version 3.4.0. (#16198)
Swamp-Ig Aug 26, 2018
eb490ac
Add Time-based Onetime Password Multi-factor Authentication Module (#…
awarecan Aug 26, 2018
23ea342
Replace pbkdf2 with bcrypt (#16071)
Eriner Aug 26, 2018
287a4ea
Replace pbkdf2 with bcrypt (#16071)
Eriner Aug 26, 2018
917fdde
Add Time-based Onetime Password Multi-factor Authentication Module (#…
awarecan Aug 26, 2018
fa0fda1
Handle exception from pillow (#16190)
PhracturedBlue Aug 26, 2018
7db240d
remove hangouts.users state, simplifies hangouts.conversations (#16191)
hobbypunk90 Aug 26, 2018
d77b106
Update aiohttp to version 3.4.0. (#16198)
Swamp-Ig Aug 26, 2018
069e210
Revert changes to platforms using self.device (#16209)
Kane610 Aug 26, 2018
577a134
Update translations
balloob Aug 26, 2018
6e7c323
Update translations
balloob Aug 26, 2018
a42b3ba
Add new translations
balloob Aug 26, 2018
babed8f
Bumped version to 0.77.0b2
balloob Aug 26, 2018
a5e8a16
Add temperature sensors to the velbus component (#16203)
cereal2nd Aug 27, 2018
36be758
Rewrite of Trafikverket weather - Multiple sensor types supported (#1…
endor-force Aug 27, 2018
08b6ce7
Add device_tracker.bluetooth_update service (#15252)
kariudo Aug 27, 2018
2b71824
Fix geizhals price parsing (#15990)
JulianKahnert Aug 27, 2018
271d53e
Add new translations
balloob Aug 26, 2018
31cb215
Update translations
balloob Aug 27, 2018
9f34d60
Update translations
balloob Aug 27, 2018
510a751
Change auth warning (#16216)
balloob Aug 27, 2018
f0aa18f
Add Volkszaehler sensor (#16188)
fabaff Aug 27, 2018
d74840f
openalpr flag `WITH_TEST` should be `WITH_TESTS` (#16218)
vrih Aug 27, 2018
8ad5050
Fix device telldus (#16224)
balloob Aug 27, 2018
3db4716
Upgrade alpha_vantage to 2.1.0 (#16217)
fabaff Aug 27, 2018
a9d6ab3
Bump frontend to 20180827.0
balloob Aug 27, 2018
5198d6f
Bump frontend to 20180827.0
balloob Aug 27, 2018
80f1082
rewrite hangouts to use intents instead of commands (#16220)
hobbypunk90 Aug 27, 2018
9c7abcc
Store devices as dict instead of list (#16229)
Kane610 Aug 27, 2018
495b437
Update trusted networks flow (#16227)
balloob Aug 27, 2018
0855606
homematic: Make device avilable again when UNREACH becomes False (#16…
klada Aug 26, 2018
0bae5ba
Change auth warning (#16216)
balloob Aug 27, 2018
e31cf92
rewrite hangouts to use intents instead of commands (#16220)
hobbypunk90 Aug 27, 2018
07dee35
Fix device telldus (#16224)
balloob Aug 27, 2018
0c63736
Update trusted networks flow (#16227)
balloob Aug 27, 2018
fcf901b
Bumped version to 0.77.0b3
balloob Aug 27, 2018
7f41a13
Warning missed a space (#16233)
balloob Aug 28, 2018
00e5d47
Package loadable: compare case insensitive (#16234)
balloob Aug 28, 2018
4ae9bc1
Change log level to error when auth provider failed loading (#16235)
awarecan Aug 28, 2018
ea9a50e
Avoid insecure pycryptodome (#16238)
balloob Aug 28, 2018
5f24893
Improve package loadable (#16237)
balloob Aug 28, 2018
50e31d3
Fix hangouts (#16232)
balloob Aug 28, 2018
dee4a8a
Blow up startup if init auth providers or modules failed (#16240)
awarecan Aug 28, 2018
2b2c162
Update translations
balloob Aug 28, 2018
f9feab9
Update translations
balloob Aug 28, 2018
05ab3e5
Fix hangouts (#16232)
balloob Aug 28, 2018
54654ca
Warning missed a space (#16233)
balloob Aug 28, 2018
fae25da
Package loadable: compare case insensitive (#16234)
balloob Aug 28, 2018
e4821c0
Avoid insecure pycryptodome (#16238)
balloob Aug 28, 2018
de86f32
Change log level to error when auth provider failed loading (#16235)
awarecan Aug 28, 2018
fc7d81b
Blow up startup if init auth providers or modules failed (#16240)
awarecan Aug 28, 2018
a6c44c0
Bumped version to 0.77.0b4
balloob Aug 28, 2018
3af1dcd
def device shouldnt call it self but self._device (#16255)
Kane610 Aug 29, 2018
3dd2a03
Tweak MFA login flow (#16254)
awarecan Aug 29, 2018
c35e587
Bump frontend to 20180829.0
balloob Aug 29, 2018
1136cff
Bump frontend to 20180829.0
balloob Aug 29, 2018
ffe92b1
Update translations
balloob Aug 29, 2018
b398c72
Update translations
balloob Aug 29, 2018
bfa3bfe
Tweak MFA login flow (#16254)
awarecan Aug 29, 2018
ce08fe7
def device shouldnt call it self but self._device (#16255)
Kane610 Aug 29, 2018
811eb9a
Version bump to 0.77.0
balloob Aug 29, 2018
dd8c05f
Merge pull request #16256 from home-assistant/rc
balloob Aug 29, 2018
3cea8fb
Merge branch 'master' into dev
balloob Aug 29, 2018
833eb21
Version bump to 0.78.0.dev0
balloob Aug 29, 2018
7f75ac2
Switchmate (#15535)
Danielhiversen Aug 29, 2018
67630e5
Add support for discrete states to MyQ cover (#16251)
schmittx Aug 29, 2018
7cd9538
bump version (#16262)
dgomes Aug 29, 2018
f4e2ab6
Replace Authorization by Authentication (#16259)
cgtobi Aug 29, 2018
0b10426
Add device info to Chromecast (#16261)
balloob Aug 29, 2018
343ea05
Add device info for sonos (#16263)
balloob Aug 29, 2018
710c5a3
Add device info Nest (#16265)
balloob Aug 29, 2018
4fae425
Add Hue device info (#16267)
balloob Aug 29, 2018
2a807ef
Nest Thermostat has software version (#16275)
awarecan Aug 29, 2018
d227efc
Add support for Habitica (#15744)
asmfreak Aug 29, 2018
3cbb413
Fix data_key override by parent class (#16278)
syssi Aug 29, 2018
d7432a8
Bump frontend to 20180829.1
balloob Aug 29, 2018
0f30b30
Fix error when vacuum is idling (#16282)
cnrd Aug 29, 2018
2172245
Fix so that entities are properly unloaded with config entry (#16281)
Kane610 Aug 29, 2018
2d55606
Bump frontend to 20180829.1
balloob Aug 29, 2018
21c6c2e
Fix data_key override by parent class (#16278)
syssi Aug 29, 2018
b305dc6
Fix error when vacuum is idling (#16282)
cnrd Aug 29, 2018
bfe0454
Bumped version to 0.77.1
balloob Aug 29, 2018
a49d616
Merge pull request #16284 from home-assistant/rc
balloob Aug 29, 2018
5f57b94
Merge branch 'master' into dev
balloob Aug 29, 2018
b4f3279
Fix spelling mistake in recorder migration [ci skip]
robbiet480 Aug 29, 2018
4ab79cb
Geo Location component (#15953)
exxamalte Aug 30, 2018
84ae51d
Bump songpal dependency (#16297)
rytilahti Aug 30, 2018
245c93c
Use asterisk_mbox 0.5.0 client (#16296)
PhracturedBlue Aug 30, 2018
4067f32
Fix LIFX effects (#16309)
amelchio Aug 31, 2018
7832739
avoid error in debug log mode and rss entry without title (#16316)
exxamalte Aug 31, 2018
e153571
Correct wemo static device discovery issue. (#16292)
lamiskin Aug 31, 2018
3b705d6
Update frontend to 20180831.0
balloob Aug 31, 2018
232076b
Update frontend to 20180831.0
balloob Aug 31, 2018
e2dc443
Update frontend to 20180831.0
balloob Aug 31, 2018
8be7a0a
Correct wemo static device discovery issue. (#16292)
lamiskin Aug 31, 2018
b506526
Correct wemo static device discovery issue. (#16292)
lamiskin Aug 31, 2018
16a58bd
Fix LIFX effects (#16309)
amelchio Aug 31, 2018
df26b23
Fix LIFX effects (#16309)
amelchio Aug 31, 2018
0e076fb
avoid error in debug log mode and rss entry without title (#16316)
exxamalte Aug 31, 2018
e7d0cd1
avoid error in debug log mode and rss entry without title (#16316)
exxamalte Aug 31, 2018
bc618af
Bumped version to 0.77.2
balloob Aug 31, 2018
5efd968
Bumped version to 0.77.2
balloob Aug 31, 2018
ec2766a
Update translations
balloob Aug 31, 2018
d705375
Update translations
balloob Aug 31, 2018
fd1b35c
Update translations
balloob Aug 31, 2018
976626d
Merge pull request #16324 from home-assistant/rc
balloob Aug 31, 2018
5169209
Merge pull request #16324 from home-assistant/rc
balloob Aug 31, 2018
5eebf3f
Upgrade Adafruit-DHT to 1.3.4 (#16327)
thomaslian Aug 31, 2018
4cd5e7a
Add unique ID (#16323)
schmittx Aug 31, 2018
339c7f2
Add Cover to the Insteon component (#16215)
teharris1 Aug 31, 2018
0a5a636
Fix missing humidity sensor (#16337)
danielperna84 Sep 1, 2018
cb33c19
Support Sonos Beam HDMI input (#16340)
Sep 1, 2018
bd06e7b
Make last_seen attribute a timezone aware datetime in UTC (#16348)
pnbruckner Sep 1, 2018
ff31a8e
Handle netatmo exception (#16344)
Danielhiversen Sep 1, 2018
697711f
Add support for sound_mode for Yamaha rxv media_player (#16352)
Joshi425 Sep 1, 2018
a9ad78a
Add unique_id to MQTT Light (#16303)
bieniu Sep 1, 2018
4811e8b
Update to EnvoyReader 0.2, support for more hardware (#16212)
jesserizzo Sep 1, 2018
1b24892
Snips: Added special slot values, session_id and slotname_raw (#16185)
todschmidt Sep 1, 2018
55033ac
Upgrade hbmqtt to 0.9.4 (#16356)
awarecan Sep 2, 2018
5842f05
Upgrade Sphinx to 1.7.7 (#16359)
fabaff Sep 2, 2018
bf966b9
Upgrade qnapstats to 0.2.7 (#16360)
fabaff Sep 2, 2018
4cb8446
Upgrade mutagen to 1.41.1 (#16361)
fabaff Sep 2, 2018
403f70b
Upgrade shodan to 1.10.0 (#16363)
fabaff Sep 2, 2018
64dcfc7
Upgrade to youtube_dl to 2018.09.01 (#16365)
fabaff Sep 2, 2018
03029c3
Added 'nomapnt', 'outcurnt', 'loadapnt' fields (#16176)
MarcSN311 Sep 2, 2018
95f5ba8
Generic Thermostat: add support for climate.turn_on/climate.turn_off …
aronsky Sep 2, 2018
54ecf1a
Add support for Tahoma Lighting Receiver on/off io (#15925)
fucm Sep 2, 2018
99c51b3
Update discord.py (#16248)
htotoo Sep 2, 2018
45bfb77
Upgrade python-telegram-bot to 11.0.0 (#16373)
fabaff Sep 2, 2018
695875c
Upgrade attrs to 18.2.0 (#16372)
fabaff Sep 2, 2018
b9087c4
Update server.py (#16375)
awarecan Sep 2, 2018
3ea9a83
add_entities for switchmate (#16368)
Danielhiversen Sep 2, 2018
02013ab
Merge remote-tracking branch 'upstream/master' into dev
ryanwinter Sep 3, 2018
cfbe696
Merge remote-tracking branch 'upstream/master' into dev
ryanwinter Sep 3, 2018
08351dc
remove await
ryanwinter Sep 3, 2018
e0a6263
remove await
ryanwinter Sep 3, 2018
e6a4ec0
add battery support to zha
ryanwinter Sep 3, 2018
633f920
add battery support to zha
ryanwinter Sep 3, 2018
82214ad
add battery sensor
ryanwinter Sep 3, 2018
4cf5351
add battery sensor
ryanwinter Sep 3, 2018
93cdc83
Merge remote-tracking branch 'upstream/dev' into zha_battery
ryanwinter Sep 3, 2018
90cb961
Merge remote-tracking branch 'upstream/dev' into zha_battery
ryanwinter Sep 3, 2018
192241e
remove debugging
ryanwinter Sep 3, 2018
06fe2a7
remove debugging
ryanwinter Sep 3, 2018
67fb82d
removed old changes
ryanwinter Sep 3, 2018
cef33a9
removed old changes
ryanwinter Sep 3, 2018
7766c4c
fixed whitespace
ryanwinter Sep 3, 2018
b70d729
fixed whitespace
ryanwinter Sep 3, 2018
3092100
Merge branch 'zha_battery' of https://github.com/ryanwinter/home-assi…
ryanwinter Sep 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions homeassistant/components/sensor/zha.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def make_sensor(discovery_info):
RelativeHumidity, TemperatureMeasurement, PressureMeasurement,
IlluminanceMeasurement
)
from zigpy.zcl.clusters.general import PowerConfiguration
from zigpy.zcl.clusters.smartenergy import Metering
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
in_clusters = discovery_info['in_clusters']
Expand All @@ -52,6 +53,8 @@ def make_sensor(discovery_info):
elif ElectricalMeasurement.cluster_id in in_clusters:
sensor = ElectricalMeasurementSensor(**discovery_info)
return sensor
elif PowerConfiguration.cluster_id in in_clusters:
sensor = BatterySensor(**discovery_info)
else:
sensor = Sensor(**discovery_info)

Expand Down Expand Up @@ -100,6 +103,35 @@ async def async_update(self):
self._state = result.get(self.value_attribute, self._state)


class BatterySensor(Sensor):
"""ZHA generic battery sensor."""

value_attribute = 32

@property
def unit_of_measurement(self):
"""Return the unit of measurement of this entity."""
return '%'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Battery voltage is != "battery_percentage_remaining"

I'd use attrid = 33 as the value attributes which translates into "battery_percentage_remaining". You also would need to configure attribute reporting for attr_id=33. The problem is: Centralite sensors unlike SmartThings sensors do not report "battery_percentage_remaining" but this could be addressed through zigpy quirks, which I was actually working on. For now I have linear translation of 'battery_voltate' to 'battery_percentage_remaining', but was working on a reverse exponential translation like in #12515 just want to have a function with defined max/min battery voltage translating into % remaining

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I realised that this wasnt battery percentage, I was thinking that a quirk could be used to convert this to percentage later on. Maybe I will check out the battery_percentage_remaining function and see how that goes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what I have for WIP https://github.com/Adminiuga/zigpy/commits/bat-percent-remain the only thing stopping me from submitting this is the linear battery_voltage --> battery_percentage_remaining conversion as I'd like it to be inverse exponential. Xiaomi battery voltage parsing is based on/inspired by Yoda-X code https://github.com/Yoda-x/ha-zha-new/blob/master/custom_components/device/lumi_sensor_wleak_aq1.py

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking in the zigbee.db file, I don't see a battery_percentage_remaining attribute for cluster one on my Smartthings sensors, but you mention that smarthing sensors do report this. Does this mean a change needs to happen in zigby?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that depends on the sensor. The one I've got https://www.amazon.com/Samsung-SmartThings-Multipurpose-Sensor-GP-U999SJVLAAA or https://www.amazon.com/Samsung-SmartThings-Water-Sensor-GP-U999SJVLCAA/dp/B07F951JDP do report "battery_percentage_remaining" see https://community.home-assistant.io/t/zha-zigbee-tested-devices-please-add-your-device-results/17718/431?u=quatuor and some probably not.

Centralite Motion "Iris" sensors do not report "battery_percentage_remaining". The problem I see with reporting the battery % remaining based on battery voltage means that we either need to assume that all sensors have 3v batteries, which might not be always the case, like in https://www.sinopetech.com/en/boutique/all-products/smart-water-valve-3-4-in/ or create battery sensor based on model&manufacturer but in this case you maybe better going with "battery % remaining" attribute if the device supports it or implement it using zigpy quirks. Implementing it through zigpy quirks is pretty much equivalent to implementing battery sensor based on manufacturer/model, just moves abstraction layer to zigpy.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have the new smartthings sensors? I have the older variety of both the multipurpose and the water sensor.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it makes sense to use battery percentage if each sensor varies with the voltage, and use a quirk to implement it if its missing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I'm going to try and create a smartthings quirk based on your example to write the percentage battery attribute.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented the quirk from your example above, but haven't had any luck getting a battery level reported, just get "Unknown".


async def async_update(self):
"""Retrieve latest state."""
_LOGGER.debug("%s async_update", self.entity_id)

result = await zha.safe_read(
self._endpoint.power,
['battery_voltage']
)
self._state = result.get('battery_voltage', self._state)

@property
def state(self):
"""Return the state of the entity."""
if self._state == 'unknown':
return 'unknown'

return self._state


class TemperatureSensor(Sensor):
"""ZHA temperature sensor."""

Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/zha/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def populate_data():
zcl.clusters.measurement.IlluminanceMeasurement: 'sensor',
zcl.clusters.smartenergy.Metering: 'sensor',
zcl.clusters.homeautomation.ElectricalMeasurement: 'sensor',
zcl.clusters.general.PowerConfiguration: 'sensor',
zcl.clusters.security.IasZone: 'binary_sensor',
zcl.clusters.hvac.Fan: 'fan',
})
Expand Down