UniFi - Use state to know if device is online (#25876)
This commit is contained in:
parent
b8460bb331
commit
ab7db5fbd0
5 changed files with 13 additions and 8 deletions
|
@ -294,7 +294,7 @@ class UniFiDeviceTracker(ScannerEntity):
|
|||
CONF_DETECTION_TIME, DEFAULT_DETECTION_TIME
|
||||
)
|
||||
|
||||
if self.device.last_seen and (
|
||||
if self.device.state == 1 and (
|
||||
dt_util.utcnow() - dt_util.utc_from_timestamp(float(self.device.last_seen))
|
||||
< detection_time
|
||||
):
|
||||
|
@ -339,15 +339,18 @@ class UniFiDeviceTracker(ScannerEntity):
|
|||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the device state attributes."""
|
||||
if not self.device.last_seen:
|
||||
if self.device.state == 0:
|
||||
return {}
|
||||
|
||||
attributes = {}
|
||||
|
||||
attributes["upgradable"] = self.device.upgradable
|
||||
attributes["overheating"] = self.device.overheating
|
||||
|
||||
if self.device.has_fan:
|
||||
attributes["fan_level"] = self.device.fan_level
|
||||
|
||||
if self.device.overheating:
|
||||
attributes["overheating"] = self.device.overheating
|
||||
|
||||
if self.device.upgradable:
|
||||
attributes["upgradable"] = self.device.upgradable
|
||||
|
||||
return attributes
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/components/unifi",
|
||||
"requirements": [
|
||||
"aiounifi==10"
|
||||
"aiounifi==11"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": [
|
||||
|
|
|
@ -173,7 +173,7 @@ aiopvapi==1.6.14
|
|||
aioswitcher==2019.4.26
|
||||
|
||||
# homeassistant.components.unifi
|
||||
aiounifi==10
|
||||
aiounifi==11
|
||||
|
||||
# homeassistant.components.wwlln
|
||||
aiowwlln==1.0.0
|
||||
|
|
|
@ -71,7 +71,7 @@ aionotion==1.1.0
|
|||
aioswitcher==2019.4.26
|
||||
|
||||
# homeassistant.components.unifi
|
||||
aiounifi==10
|
||||
aiounifi==11
|
||||
|
||||
# homeassistant.components.wwlln
|
||||
aiowwlln==1.0.0
|
||||
|
|
|
@ -69,6 +69,7 @@ DEVICE_1 = {
|
|||
"model": "US16P150",
|
||||
"name": "device_1",
|
||||
"overheating": False,
|
||||
"state": 1,
|
||||
"type": "usw",
|
||||
"upgradable": False,
|
||||
"version": "4.0.42.10433",
|
||||
|
@ -81,6 +82,7 @@ DEVICE_2 = {
|
|||
"mac": "00:00:00:00:01:01",
|
||||
"model": "US16P150",
|
||||
"name": "device_1",
|
||||
"state": 0,
|
||||
"type": "usw",
|
||||
"version": "4.0.42.10433",
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue