Bump sense_api to 0.11.0 and add refresh token support (#83030)

fixes undefined
This commit is contained in:
Keilin Bickar 2022-12-01 04:53:48 -05:00 committed by GitHub
parent 8e357faa4d
commit f4a58c7dc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 5 deletions

View File

@ -2,7 +2,7 @@
"domain": "emulated_kasa",
"name": "Emulated Kasa",
"documentation": "https://www.home-assistant.io/integrations/emulated_kasa",
"requirements": ["sense_energy==0.10.4"],
"requirements": ["sense_energy==0.11.0"],
"codeowners": ["@kbickar"],
"quality_scale": "internal",
"iot_class": "local_push",

View File

@ -66,6 +66,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
access_token = entry_data.get("access_token", "")
user_id = entry_data.get("user_id", "")
device_id = entry_data.get("device_id", "")
refresh_token = entry_data.get("refresh_token", "")
monitor_id = entry_data.get("monitor_id", "")
client_session = async_get_clientsession(hass)
@ -76,7 +78,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
gateway.rate_limit = ACTIVE_UPDATE_RATE
try:
gateway.load_auth(access_token, user_id, monitor_id)
gateway.load_auth(access_token, user_id, device_id, refresh_token)
gateway.set_monitor_id(monitor_id)
await gateway.get_monitor_data()
except (SenseAuthenticationException, SenseMFARequiredException) as err:
_LOGGER.warning("Sense authentication expired")

View File

@ -60,6 +60,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Create the entry from the config data."""
self._auth_data["access_token"] = self._gateway.sense_access_token
self._auth_data["user_id"] = self._gateway.sense_user_id
self._auth_data["device_id"] = self._gateway.device_id
self._auth_data["refresh_token"] = self._gateway.refresh_token
self._auth_data["monitor_id"] = self._gateway.sense_monitor_id
existing_entry = await self.async_set_unique_id(self._auth_data[CONF_EMAIL])
if not existing_entry:

View File

@ -2,7 +2,7 @@
"domain": "sense",
"name": "Sense",
"documentation": "https://www.home-assistant.io/integrations/sense",
"requirements": ["sense_energy==0.10.4"],
"requirements": ["sense_energy==0.11.0"],
"codeowners": ["@kbickar"],
"config_flow": true,
"dhcp": [

View File

@ -2258,7 +2258,7 @@ sendgrid==6.8.2
# homeassistant.components.emulated_kasa
# homeassistant.components.sense
sense_energy==0.10.4
sense_energy==0.11.0
# homeassistant.components.sensirion_ble
sensirion-ble==0.0.1

View File

@ -1561,7 +1561,7 @@ securetar==2022.2.0
# homeassistant.components.emulated_kasa
# homeassistant.components.sense
sense_energy==0.10.4
sense_energy==0.11.0
# homeassistant.components.sensirion_ble
sensirion-ble==0.0.1

View File

@ -22,6 +22,8 @@ MOCK_CONFIG = {
"access_token": "ABC",
"user_id": "123",
"monitor_id": "456",
"device_id": "789",
"refresh_token": "XYZ",
}
@ -36,6 +38,8 @@ def mock_sense():
mock_sense.return_value.sense_access_token = "ABC"
mock_sense.return_value.sense_user_id = "123"
mock_sense.return_value.sense_monitor_id = "456"
mock_sense.return_value.device_id = "789"
mock_sense.return_value.refresh_token = "XYZ"
yield mock_sense