Check status field for UPS online binary sensor (#30144)
Avoids issue where status was previously reported as offline when battery was low or UPS was over voltagepull/30456/head
parent
6b519499a7
commit
8a1fc8b8f0
|
@ -18,11 +18,11 @@ DEFAULT_HOST = "localhost"
|
||||||
DEFAULT_PORT = 3551
|
DEFAULT_PORT = 3551
|
||||||
DOMAIN = "apcupsd"
|
DOMAIN = "apcupsd"
|
||||||
|
|
||||||
KEY_STATUS = "STATUS"
|
KEY_STATUS = "STATFLAG"
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
||||||
|
|
||||||
VALUE_ONLINE = "ONLINE"
|
VALUE_ONLINE = 8
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,8 +34,8 @@ class OnlineStatus(BinarySensorDevice):
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if the UPS is online, else false."""
|
"""Return true if the UPS is online, else false."""
|
||||||
return self._state == apcupsd.VALUE_ONLINE
|
return self._state & apcupsd.VALUE_ONLINE > 0
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the status report from APCUPSd and set this entity's state."""
|
"""Get the status report from APCUPSd and set this entity's state."""
|
||||||
self._state = self._data.status[apcupsd.KEY_STATUS]
|
self._state = int(self._data.status[apcupsd.KEY_STATUS], 16)
|
||||||
|
|
Loading…
Reference in New Issue