mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 02:03:27 +01:00
Bump pydexcom to 0.5.1 (#161549)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""The Dexcom integration."""
|
||||
|
||||
from pydexcom import AccountError, Dexcom, SessionError
|
||||
from pydexcom import Dexcom, Region
|
||||
from pydexcom.errors import AccountError, SessionError
|
||||
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -14,10 +15,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: DexcomConfigEntry) -> bo
|
||||
"""Set up Dexcom from a config entry."""
|
||||
try:
|
||||
dexcom = await hass.async_add_executor_job(
|
||||
Dexcom,
|
||||
entry.data[CONF_USERNAME],
|
||||
entry.data[CONF_PASSWORD],
|
||||
entry.data[CONF_SERVER] == SERVER_OUS,
|
||||
lambda: Dexcom(
|
||||
username=entry.data[CONF_USERNAME],
|
||||
password=entry.data[CONF_PASSWORD],
|
||||
region=Region.OUS
|
||||
if entry.data[CONF_SERVER] == SERVER_OUS
|
||||
else Region.US,
|
||||
)
|
||||
)
|
||||
except AccountError:
|
||||
return False
|
||||
|
||||
@@ -5,7 +5,8 @@ from __future__ import annotations
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pydexcom import AccountError, Dexcom, SessionError
|
||||
from pydexcom import Dexcom, Region
|
||||
from pydexcom.errors import AccountError, SessionError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
@@ -37,10 +38,13 @@ class DexcomConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
if user_input is not None:
|
||||
try:
|
||||
await self.hass.async_add_executor_job(
|
||||
Dexcom,
|
||||
user_input[CONF_USERNAME],
|
||||
user_input[CONF_PASSWORD],
|
||||
user_input[CONF_SERVER] == SERVER_OUS,
|
||||
lambda: Dexcom(
|
||||
username=user_input[CONF_USERNAME],
|
||||
password=user_input[CONF_PASSWORD],
|
||||
region=Region.OUS
|
||||
if user_input[CONF_SERVER] == SERVER_OUS
|
||||
else Region.US,
|
||||
)
|
||||
)
|
||||
except SessionError:
|
||||
errors["base"] = "cannot_connect"
|
||||
|
||||
@@ -18,7 +18,7 @@ _SCAN_INTERVAL = timedelta(seconds=180)
|
||||
type DexcomConfigEntry = ConfigEntry[DexcomCoordinator]
|
||||
|
||||
|
||||
class DexcomCoordinator(DataUpdateCoordinator[GlucoseReading]):
|
||||
class DexcomCoordinator(DataUpdateCoordinator[GlucoseReading | None]):
|
||||
"""Dexcom Coordinator."""
|
||||
|
||||
def __init__(
|
||||
@@ -37,7 +37,7 @@ class DexcomCoordinator(DataUpdateCoordinator[GlucoseReading]):
|
||||
)
|
||||
self.dexcom = dexcom
|
||||
|
||||
async def _async_update_data(self) -> GlucoseReading:
|
||||
async def _async_update_data(self) -> GlucoseReading | None:
|
||||
"""Fetch data from API endpoint."""
|
||||
return await self.hass.async_add_executor_job(
|
||||
self.dexcom.get_current_glucose_reading
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
"integration_type": "service",
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["pydexcom"],
|
||||
"requirements": ["pydexcom==0.2.3"]
|
||||
"requirements": ["pydexcom==0.5.1"]
|
||||
}
|
||||
|
||||
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@@ -1989,7 +1989,7 @@ pydeconz==120
|
||||
pydelijn==1.1.0
|
||||
|
||||
# homeassistant.components.dexcom
|
||||
pydexcom==0.2.3
|
||||
pydexcom==0.5.1
|
||||
|
||||
# homeassistant.components.discovergy
|
||||
pydiscovergy==3.0.2
|
||||
|
||||
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@@ -1696,7 +1696,7 @@ pydeako==0.6.0
|
||||
pydeconz==120
|
||||
|
||||
# homeassistant.components.dexcom
|
||||
pydexcom==0.2.3
|
||||
pydexcom==0.5.1
|
||||
|
||||
# homeassistant.components.discovergy
|
||||
pydiscovergy==3.0.2
|
||||
|
||||
@@ -19,6 +19,8 @@ CONFIG = {
|
||||
}
|
||||
|
||||
GLUCOSE_READING = GlucoseReading(json.loads(load_fixture("data.json", "dexcom")))
|
||||
TEST_ACCOUNT_ID = "99999999-9999-9999-9999-999999999999"
|
||||
TEST_SESSION_ID = "55555555-5555-5555-5555-555555555555"
|
||||
|
||||
|
||||
async def init_integration(
|
||||
@@ -38,8 +40,12 @@ async def init_integration(
|
||||
return_value=GLUCOSE_READING,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.dexcom.Dexcom.create_session",
|
||||
return_value="test_session_id",
|
||||
"homeassistant.components.dexcom.Dexcom._get_account_id",
|
||||
return_value=TEST_ACCOUNT_ID,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.dexcom.Dexcom._get_session_id",
|
||||
return_value=TEST_SESSION_ID,
|
||||
),
|
||||
):
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"DT": "/Date(1587165223000+0000)/",
|
||||
"ST": "/Date(1587179623000)/",
|
||||
"Trend": 4,
|
||||
"Value": 110,
|
||||
"WT": "/Date(1587179623000)/"
|
||||
"WT": "Date(1745081913085)",
|
||||
"ST": "Date(1745081913085)",
|
||||
"DT": "Date(1745081913085-0400)",
|
||||
"Value": 100,
|
||||
"Trend": "Flat"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from pydexcom import AccountError, SessionError
|
||||
from pydexcom.errors import AccountError, SessionError
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dexcom.const import DOMAIN
|
||||
@@ -23,10 +23,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.dexcom.config_flow.Dexcom.create_session",
|
||||
return_value="test_session_id",
|
||||
),
|
||||
patch("homeassistant.components.dexcom.config_flow.Dexcom"),
|
||||
patch(
|
||||
"homeassistant.components.dexcom.async_setup_entry",
|
||||
return_value=True,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from pydexcom import AccountError, SessionError
|
||||
from pydexcom.errors import AccountError, SessionError
|
||||
|
||||
from homeassistant.components.dexcom.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from pydexcom import SessionError
|
||||
from pydexcom.errors import SessionError
|
||||
|
||||
from homeassistant.const import STATE_UNAVAILABLE, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
Reference in New Issue
Block a user