diff --git a/custom_components/candy/sensor.py b/custom_components/candy/sensor.py index fcacf60..eb679d9 100644 --- a/custom_components/candy/sensor.py +++ b/custom_components/candy/sensor.py @@ -3,7 +3,10 @@ from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import TEMP_CELSIUS, TIME_MINUTES +from homeassistant.const import ( + UnitOfTime, + UnitOfTemperature, +) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.typing import StateType @@ -171,7 +174,7 @@ def state(self) -> StateType: @property def unit_of_measurement(self) -> str: - return TIME_MINUTES + return UnitOfTime.MINUTES @property def icon(self) -> str: @@ -277,7 +280,7 @@ def state(self) -> StateType: @property def unit_of_measurement(self) -> str: - return TIME_MINUTES + return UnitOfTime.MINUTES @property def icon(self) -> str: @@ -350,7 +353,7 @@ def state(self) -> StateType: @property def unit_of_measurement(self) -> str: - return TEMP_CELSIUS + return UnitOfTemperature.CELSIUS @property def icon(self) -> str: @@ -432,7 +435,7 @@ def state(self) -> StateType: @property def unit_of_measurement(self) -> str: - return TIME_MINUTES + return UnitOfTime.MINUTES @property def icon(self) -> str: diff --git a/requirements_test.txt b/requirements_test.txt index d227461..b8bc986 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,4 @@ -pytest-homeassistant-custom-component==0.13.114 +pytest-homeassistant-custom-component~=0.13.114 # Component dependencies backoff~=2.0 diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 391cbb4..9169d6e 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -66,7 +66,7 @@ async def test_no_encryption_detected(hass, detect_no_encryption): # pylint: dis ) # Check that the config flow shows the user form as the first step - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( @@ -75,7 +75,7 @@ async def test_no_encryption_detected(hass, detect_no_encryption): # pylint: dis # Check that the config flow is complete and a new entry is created with # the input data - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["title"] == "Candy" assert result["data"] == { CONF_IP_ADDRESS: "192.168.0.66", @@ -93,7 +93,7 @@ async def test_detected_encryption_and_key_found(hass, detect_encryption_find_ke ) # Check that the config flow shows the user form as the first step - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( @@ -102,7 +102,7 @@ async def test_detected_encryption_and_key_found(hass, detect_encryption_find_ke # Check that the config flow is complete and a new entry is created with # the input data - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["title"] == "Candy" assert result["data"] == { CONF_IP_ADDRESS: "192.168.0.66", @@ -120,14 +120,14 @@ async def test_detected_encryption_and_key_not_found(hass, detect_encryption_key ) # Check that the config flow shows the user form as the first step - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={CONF_IP_ADDRESS: "192.168.0.66"} ) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["errors"] == {"base": "detect_encryption"} @@ -140,7 +140,7 @@ async def test_detected_encryption_without_key(hass, detect_encryption_without_k ) # Check that the config flow shows the user form as the first step - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( @@ -149,7 +149,7 @@ async def test_detected_encryption_without_key(hass, detect_encryption_without_k # Check that the config flow is complete and a new entry is created with # the input data - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["title"] == "Candy" assert result["data"] == { CONF_IP_ADDRESS: "192.168.0.66",