mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
UniFi - Use state to know if device is online (#25876)
This commit is contained in:
parent
b8460bb331
commit
ab7db5fbd0
@ -294,7 +294,7 @@ class UniFiDeviceTracker(ScannerEntity):
|
|||||||
CONF_DETECTION_TIME, DEFAULT_DETECTION_TIME
|
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))
|
dt_util.utcnow() - dt_util.utc_from_timestamp(float(self.device.last_seen))
|
||||||
< detection_time
|
< detection_time
|
||||||
):
|
):
|
||||||
@ -339,15 +339,18 @@ class UniFiDeviceTracker(ScannerEntity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the device state attributes."""
|
"""Return the device state attributes."""
|
||||||
if not self.device.last_seen:
|
if self.device.state == 0:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
attributes = {}
|
attributes = {}
|
||||||
|
|
||||||
attributes["upgradable"] = self.device.upgradable
|
|
||||||
attributes["overheating"] = self.device.overheating
|
|
||||||
|
|
||||||
if self.device.has_fan:
|
if self.device.has_fan:
|
||||||
attributes["fan_level"] = self.device.fan_level
|
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
|
return attributes
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/components/unifi",
|
"documentation": "https://www.home-assistant.io/components/unifi",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"aiounifi==10"
|
"aiounifi==11"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": [
|
"codeowners": [
|
||||||
|
@ -173,7 +173,7 @@ aiopvapi==1.6.14
|
|||||||
aioswitcher==2019.4.26
|
aioswitcher==2019.4.26
|
||||||
|
|
||||||
# homeassistant.components.unifi
|
# homeassistant.components.unifi
|
||||||
aiounifi==10
|
aiounifi==11
|
||||||
|
|
||||||
# homeassistant.components.wwlln
|
# homeassistant.components.wwlln
|
||||||
aiowwlln==1.0.0
|
aiowwlln==1.0.0
|
||||||
|
@ -71,7 +71,7 @@ aionotion==1.1.0
|
|||||||
aioswitcher==2019.4.26
|
aioswitcher==2019.4.26
|
||||||
|
|
||||||
# homeassistant.components.unifi
|
# homeassistant.components.unifi
|
||||||
aiounifi==10
|
aiounifi==11
|
||||||
|
|
||||||
# homeassistant.components.wwlln
|
# homeassistant.components.wwlln
|
||||||
aiowwlln==1.0.0
|
aiowwlln==1.0.0
|
||||||
|
@ -69,6 +69,7 @@ DEVICE_1 = {
|
|||||||
"model": "US16P150",
|
"model": "US16P150",
|
||||||
"name": "device_1",
|
"name": "device_1",
|
||||||
"overheating": False,
|
"overheating": False,
|
||||||
|
"state": 1,
|
||||||
"type": "usw",
|
"type": "usw",
|
||||||
"upgradable": False,
|
"upgradable": False,
|
||||||
"version": "4.0.42.10433",
|
"version": "4.0.42.10433",
|
||||||
@ -81,6 +82,7 @@ DEVICE_2 = {
|
|||||||
"mac": "00:00:00:00:01:01",
|
"mac": "00:00:00:00:01:01",
|
||||||
"model": "US16P150",
|
"model": "US16P150",
|
||||||
"name": "device_1",
|
"name": "device_1",
|
||||||
|
"state": 0,
|
||||||
"type": "usw",
|
"type": "usw",
|
||||||
"version": "4.0.42.10433",
|
"version": "4.0.42.10433",
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user