mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Bump anova version (#92206)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
ede1f08c51
commit
7b5d26d3fa
@ -3,13 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from anova_wifi import (
|
from anova_wifi import AnovaApi, AnovaPrecisionCooker, InvalidLogin, NoDevicesFound
|
||||||
AnovaApi,
|
|
||||||
AnovaPrecisionCooker,
|
|
||||||
AnovaPrecisionCookerSensor,
|
|
||||||
InvalidLogin,
|
|
||||||
NoDevicesFound,
|
|
||||||
)
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
|
||||||
@ -67,9 +61,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
coordinators = [AnovaCoordinator(hass, device) for device in devices]
|
coordinators = [AnovaCoordinator(hass, device) for device in devices]
|
||||||
for coordinator in coordinators:
|
for coordinator in coordinators:
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
firmware_version = coordinator.data["sensors"][
|
firmware_version = coordinator.data.sensor.firmware_version
|
||||||
AnovaPrecisionCookerSensor.FIRMWARE_VERSION
|
|
||||||
]
|
|
||||||
coordinator.async_setup(str(firmware_version))
|
coordinator.async_setup(str(firmware_version))
|
||||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = AnovaData(
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = AnovaData(
|
||||||
api_jwt=api.jwt, precision_cookers=devices, coordinators=coordinators
|
api_jwt=api.jwt, precision_cookers=devices, coordinators=coordinators
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from anova_wifi import AnovaOffline, AnovaPrecisionCooker
|
from anova_wifi import AnovaOffline, AnovaPrecisionCooker, APCUpdate
|
||||||
import async_timeout
|
import async_timeout
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
@ -14,11 +14,9 @@ from .const import DOMAIN
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AnovaCoordinator(DataUpdateCoordinator):
|
class AnovaCoordinator(DataUpdateCoordinator[APCUpdate]):
|
||||||
"""Anova custom coordinator."""
|
"""Anova custom coordinator."""
|
||||||
|
|
||||||
data: dict[str, dict[str, str | int | float]]
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -47,7 +45,7 @@ class AnovaCoordinator(DataUpdateCoordinator):
|
|||||||
sw_version=firmware_version,
|
sw_version=firmware_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _async_update_data(self) -> dict[str, dict[str, str | int | float]]:
|
async def _async_update_data(self) -> APCUpdate:
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(5):
|
async with async_timeout.timeout(5):
|
||||||
return await self.anova_device.update()
|
return await self.anova_device.update()
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/anova",
|
"documentation": "https://www.home-assistant.io/integrations/anova",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["anova_wifi"],
|
"loggers": ["anova_wifi"],
|
||||||
"requirements": ["anova-wifi==0.8.0"]
|
"requirements": ["anova-wifi==0.9.0"]
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
"""Support for Anova Sensors."""
|
"""Support for Anova Sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from anova_wifi import AnovaPrecisionCookerSensor
|
from collections.abc import Callable
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from anova_wifi import APCUpdateSensor
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
@ -19,57 +22,80 @@ from .const import DOMAIN
|
|||||||
from .entity import AnovaDescriptionEntity
|
from .entity import AnovaDescriptionEntity
|
||||||
from .models import AnovaData
|
from .models import AnovaData
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class AnovaSensorEntityDescriptionMixin:
|
||||||
|
"""Describes the mixin variables for anova sensors."""
|
||||||
|
|
||||||
|
value_fn: Callable[[APCUpdateSensor], float | int | str]
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class AnovaSensorEntityDescription(
|
||||||
|
SensorEntityDescription, AnovaSensorEntityDescriptionMixin
|
||||||
|
):
|
||||||
|
"""Describes a Anova sensor."""
|
||||||
|
|
||||||
|
|
||||||
SENSOR_DESCRIPTIONS: list[SensorEntityDescription] = [
|
SENSOR_DESCRIPTIONS: list[SensorEntityDescription] = [
|
||||||
SensorEntityDescription(
|
AnovaSensorEntityDescription(
|
||||||
key=AnovaPrecisionCookerSensor.COOK_TIME,
|
key="cook_time",
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||||
icon="mdi:clock-outline",
|
icon="mdi:clock-outline",
|
||||||
translation_key="cook_time",
|
translation_key="cook_time",
|
||||||
|
device_class=SensorDeviceClass.DURATION,
|
||||||
|
value_fn=lambda data: data.cook_time,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
AnovaSensorEntityDescription(
|
||||||
key=AnovaPrecisionCookerSensor.STATE, translation_key="state"
|
key="state", translation_key="state", value_fn=lambda data: data.state
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
AnovaSensorEntityDescription(
|
||||||
key=AnovaPrecisionCookerSensor.MODE, translation_key="mode"
|
key="mode", translation_key="mode", value_fn=lambda data: data.mode
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
AnovaSensorEntityDescription(
|
||||||
key=AnovaPrecisionCookerSensor.TARGET_TEMPERATURE,
|
key="target_temperature",
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
translation_key="target_temperature",
|
translation_key="target_temperature",
|
||||||
|
value_fn=lambda data: data.target_temperature,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
AnovaSensorEntityDescription(
|
||||||
key=AnovaPrecisionCookerSensor.COOK_TIME_REMAINING,
|
key="cook_time_remaining",
|
||||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||||
icon="mdi:clock-outline",
|
icon="mdi:clock-outline",
|
||||||
translation_key="cook_time_remaining",
|
translation_key="cook_time_remaining",
|
||||||
|
device_class=SensorDeviceClass.DURATION,
|
||||||
|
value_fn=lambda data: data.cook_time_remaining,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
AnovaSensorEntityDescription(
|
||||||
key=AnovaPrecisionCookerSensor.HEATER_TEMPERATURE,
|
key="heater_temperature",
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
translation_key="heater_temperature",
|
translation_key="heater_temperature",
|
||||||
|
value_fn=lambda data: data.heater_temperature,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
AnovaSensorEntityDescription(
|
||||||
key=AnovaPrecisionCookerSensor.TRIAC_TEMPERATURE,
|
key="triac_temperature",
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
translation_key="triac_temperature",
|
translation_key="triac_temperature",
|
||||||
|
value_fn=lambda data: data.triac_temperature,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
AnovaSensorEntityDescription(
|
||||||
key=AnovaPrecisionCookerSensor.WATER_TEMPERATURE,
|
key="water_temperature",
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
translation_key="water_temperature",
|
translation_key="water_temperature",
|
||||||
|
value_fn=lambda data: data.water_temperature,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -91,7 +117,9 @@ async def async_setup_entry(
|
|||||||
class AnovaSensor(AnovaDescriptionEntity, SensorEntity):
|
class AnovaSensor(AnovaDescriptionEntity, SensorEntity):
|
||||||
"""A sensor using Anova coordinator."""
|
"""A sensor using Anova coordinator."""
|
||||||
|
|
||||||
|
entity_description: AnovaSensorEntityDescription
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> StateType:
|
def native_value(self) -> StateType:
|
||||||
"""Return the state."""
|
"""Return the state."""
|
||||||
return self.coordinator.data["sensors"][self.entity_description.key]
|
return self.entity_description.value_fn(self.coordinator.data.sensor)
|
||||||
|
@ -339,7 +339,7 @@ androidtvremote2==0.0.7
|
|||||||
anel_pwrctrl-homeassistant==0.0.1.dev2
|
anel_pwrctrl-homeassistant==0.0.1.dev2
|
||||||
|
|
||||||
# homeassistant.components.anova
|
# homeassistant.components.anova
|
||||||
anova-wifi==0.8.0
|
anova-wifi==0.9.0
|
||||||
|
|
||||||
# homeassistant.components.anthemav
|
# homeassistant.components.anthemav
|
||||||
anthemav==1.4.1
|
anthemav==1.4.1
|
||||||
|
@ -311,7 +311,7 @@ androidtv[async]==0.0.70
|
|||||||
androidtvremote2==0.0.7
|
androidtvremote2==0.0.7
|
||||||
|
|
||||||
# homeassistant.components.anova
|
# homeassistant.components.anova
|
||||||
anova-wifi==0.8.0
|
anova-wifi==0.9.0
|
||||||
|
|
||||||
# homeassistant.components.anthemav
|
# homeassistant.components.anthemav
|
||||||
anthemav==1.4.1
|
anthemav==1.4.1
|
||||||
|
@ -3,11 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from anova_wifi import (
|
from anova_wifi import AnovaPrecisionCooker, APCUpdate, APCUpdateBinary, APCUpdateSensor
|
||||||
AnovaPrecisionCooker,
|
|
||||||
AnovaPrecisionCookerBinarySensor,
|
|
||||||
AnovaPrecisionCookerSensor,
|
|
||||||
)
|
|
||||||
|
|
||||||
from homeassistant.components.anova.const import DOMAIN
|
from homeassistant.components.anova.const import DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -20,26 +16,12 @@ DEVICE_UNIQUE_ID = "abc123def"
|
|||||||
|
|
||||||
CONF_INPUT = {CONF_USERNAME: "sample@gmail.com", CONF_PASSWORD: "sample"}
|
CONF_INPUT = {CONF_USERNAME: "sample@gmail.com", CONF_PASSWORD: "sample"}
|
||||||
|
|
||||||
ONLINE_UPDATE = {
|
ONLINE_UPDATE = APCUpdate(
|
||||||
"sensors": {
|
sensor=APCUpdateSensor(
|
||||||
AnovaPrecisionCookerSensor.COOK_TIME: 0,
|
0, "Low water", "No state", 23.33, 0, "2.2.0", 20.87, 21.79, 21.33
|
||||||
AnovaPrecisionCookerSensor.MODE: "Low water",
|
),
|
||||||
AnovaPrecisionCookerSensor.STATE: "No state",
|
binary_sensor=APCUpdateBinary(False, False, False, True, False, True, False),
|
||||||
AnovaPrecisionCookerSensor.TARGET_TEMPERATURE: 23.33,
|
)
|
||||||
AnovaPrecisionCookerSensor.COOK_TIME_REMAINING: 0,
|
|
||||||
AnovaPrecisionCookerSensor.FIRMWARE_VERSION: "2.2.0",
|
|
||||||
AnovaPrecisionCookerSensor.HEATER_TEMPERATURE: 20.87,
|
|
||||||
AnovaPrecisionCookerSensor.TRIAC_TEMPERATURE: 21.79,
|
|
||||||
AnovaPrecisionCookerSensor.WATER_TEMPERATURE: 21.33,
|
|
||||||
},
|
|
||||||
"binary_sensors": {
|
|
||||||
AnovaPrecisionCookerBinarySensor.COOKING: False,
|
|
||||||
AnovaPrecisionCookerBinarySensor.DEVICE_SAFE: True,
|
|
||||||
AnovaPrecisionCookerBinarySensor.WATER_LEAK: False,
|
|
||||||
AnovaPrecisionCookerBinarySensor.WATER_LEVEL_CRITICAL: True,
|
|
||||||
AnovaPrecisionCookerBinarySensor.WATER_TEMP_TOO_HIGH: False,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def create_entry(hass: HomeAssistant, device_id: str = DEVICE_UNIQUE_ID) -> ConfigEntry:
|
def create_entry(hass: HomeAssistant, device_id: str = DEVICE_UNIQUE_ID) -> ConfigEntry:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user