Fix unknown data in google wifi (#85616)
This commit is contained in:
parent
105b34bd77
commit
4d660f926d
2 changed files with 10 additions and 12 deletions
|
@ -17,7 +17,6 @@ from homeassistant.const import (
|
|||
CONF_HOST,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
STATE_UNKNOWN,
|
||||
UnitOfTime,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -172,12 +171,12 @@ class GoogleWifiAPI:
|
|||
self.raw_data = None
|
||||
self.conditions = conditions
|
||||
self.data = {
|
||||
ATTR_CURRENT_VERSION: STATE_UNKNOWN,
|
||||
ATTR_NEW_VERSION: STATE_UNKNOWN,
|
||||
ATTR_UPTIME: STATE_UNKNOWN,
|
||||
ATTR_LAST_RESTART: STATE_UNKNOWN,
|
||||
ATTR_LOCAL_IP: STATE_UNKNOWN,
|
||||
ATTR_STATUS: STATE_UNKNOWN,
|
||||
ATTR_CURRENT_VERSION: None,
|
||||
ATTR_NEW_VERSION: None,
|
||||
ATTR_UPTIME: None,
|
||||
ATTR_LAST_RESTART: None,
|
||||
ATTR_LOCAL_IP: None,
|
||||
ATTR_STATUS: None,
|
||||
}
|
||||
self.available = True
|
||||
self.update()
|
||||
|
@ -223,7 +222,7 @@ class GoogleWifiAPI:
|
|||
elif (
|
||||
attr_key == ATTR_LOCAL_IP and not self.raw_data["wan"]["online"]
|
||||
):
|
||||
sensor_value = STATE_UNKNOWN
|
||||
sensor_value = None
|
||||
|
||||
self.data[attr_key] = sensor_value
|
||||
except KeyError:
|
||||
|
@ -235,4 +234,4 @@ class GoogleWifiAPI:
|
|||
description.sensor_key,
|
||||
attr_key,
|
||||
)
|
||||
self.data[attr_key] = STATE_UNKNOWN
|
||||
self.data[attr_key] = None
|
||||
|
|
|
@ -4,7 +4,6 @@ from http import HTTPStatus
|
|||
from unittest.mock import Mock, patch
|
||||
|
||||
import homeassistant.components.google_wifi.sensor as google_wifi
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
|
@ -171,7 +170,7 @@ def test_update_when_value_changed(hass, requests_mock):
|
|||
elif name == google_wifi.ATTR_NEW_VERSION:
|
||||
assert sensor.state == "Latest"
|
||||
elif name == google_wifi.ATTR_LOCAL_IP:
|
||||
assert sensor.state == STATE_UNKNOWN
|
||||
assert sensor.state is None
|
||||
else:
|
||||
assert sensor.state == "next"
|
||||
|
||||
|
@ -185,7 +184,7 @@ def test_when_api_data_missing(hass, requests_mock):
|
|||
sensor = sensor_dict[name]["sensor"]
|
||||
fake_delay(hass, 2)
|
||||
sensor.update()
|
||||
assert sensor.state == STATE_UNKNOWN
|
||||
assert sensor.state is None
|
||||
|
||||
|
||||
def test_update_when_unavailable(hass, requests_mock):
|
||||
|
|
Loading…
Add table
Reference in a new issue