* init setup of Anova Sous Vide * bump anova-wifi to 0.2.4 * Removed yaml support * Bump to anova-wifi 0.2.5 * Added support for adding sous vide while offline * Added basic test for sensor * added better tests for sensors and init * expanded code coverage * Decreased timedelta to lowest functioning value. * Updating my username * migrate to async_forward_entry_setups * applying pr recommended changes * bump anova-wifi to 0.2.7 * Improvements to hopefully get this review ready * formatting changes * clean ups for pr review * remove unneeded unique id check. * bump ao anova_wifi 0.3.0 * rename device_id to device_unique_id * renamed to 'anova' * added unique_id to MockConfigEntry * removed leftover anova sous vides * added device id to strings * added error for incorrect device id * add has_entity_name * added attr name for tests * added authentication functionality * bump to 0.4.3 * split entity into its own class/object * pulling firmware version out of async_setup Co-authored-by: J. Nick Koston <nick@koston.org> * addressed pr changes * fixed pytest * added anova data model * removed unneeded time change * add logging in package * rework step_user * Update homeassistant/components/anova/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Removed lower from attr unique id Co-authored-by: J. Nick Koston <nick@koston.org> * Removed unneeded member variables in sensor Co-authored-by: J. Nick Koston <nick@koston.org> * removed repeated subclass attr Co-authored-by: J. Nick Koston <nick@koston.org> * simplify update_failed test * created descriptionentity * bump to 0.6.1 limit ws connect * add translation for sensor entities * version bump - support pro model * add anova to strict typing * fixed sensor not getting datas type * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Check for new devices in init * style changes * return false instead of config entry not ready * move serialize_device_list to utils * move repeating device check into api * moved unneeded code out of try except * fixed tests to get 100% cov * Update homeassistant/components/anova/strings.json Co-authored-by: J. Nick Koston <nick@koston.org> --------- Co-authored-by: J. Nick Koston <nick@koston.org>
61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
"""Test the Anova sensors."""
|
|
|
|
from datetime import timedelta
|
|
import logging
|
|
from unittest.mock import patch
|
|
|
|
from anova_wifi import AnovaApi, AnovaOffline
|
|
|
|
from homeassistant.const import STATE_UNAVAILABLE
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.util import dt
|
|
|
|
from . import async_init_integration
|
|
|
|
from tests.common import async_fire_time_changed
|
|
|
|
LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
async def test_sensors(hass: HomeAssistant, anova_api: AnovaApi) -> None:
|
|
"""Test setting up creates the sensors."""
|
|
await async_init_integration(hass)
|
|
assert len(hass.states.async_all("sensor")) == 8
|
|
assert (
|
|
hass.states.get("sensor.anova_precision_cooker_cook_time_remaining").state
|
|
== "0"
|
|
)
|
|
assert hass.states.get("sensor.anova_precision_cooker_cook_time").state == "0"
|
|
assert (
|
|
hass.states.get("sensor.anova_precision_cooker_heater_temperature").state
|
|
== "20.87"
|
|
)
|
|
assert hass.states.get("sensor.anova_precision_cooker_mode").state == "Low water"
|
|
assert hass.states.get("sensor.anova_precision_cooker_state").state == "No state"
|
|
assert (
|
|
hass.states.get("sensor.anova_precision_cooker_target_temperature").state
|
|
== "23.33"
|
|
)
|
|
assert (
|
|
hass.states.get("sensor.anova_precision_cooker_water_temperature").state
|
|
== "21.33"
|
|
)
|
|
assert (
|
|
hass.states.get("sensor.anova_precision_cooker_triac_temperature").state
|
|
== "21.79"
|
|
)
|
|
|
|
|
|
async def test_update_failed(hass: HomeAssistant, anova_api: AnovaApi) -> None:
|
|
"""Test updating data after the coordinator has been set up, but anova is offline."""
|
|
await async_init_integration(hass)
|
|
await hass.async_block_till_done()
|
|
with patch(
|
|
"homeassistant.components.anova.AnovaPrecisionCooker.update",
|
|
side_effect=AnovaOffline(),
|
|
):
|
|
async_fire_time_changed(hass, dt.utcnow() + timedelta(seconds=61))
|
|
await hass.async_block_till_done()
|
|
|
|
state = hass.states.get("sensor.anova_precision_cooker_water_temperature")
|
|
assert state.state == STATE_UNAVAILABLE
|