diff --git a/homeassistant/components/nasweb/manifest.json b/homeassistant/components/nasweb/manifest.json index 8a4ecdbee84..6c447376bfe 100644 --- a/homeassistant/components/nasweb/manifest.json +++ b/homeassistant/components/nasweb/manifest.json @@ -7,5 +7,5 @@ "documentation": "https://www.home-assistant.io/integrations/nasweb", "integration_type": "hub", "iot_class": "local_push", - "requirements": ["webio-api==0.1.11"] + "requirements": ["webio-api==0.1.12"] } diff --git a/homeassistant/components/nasweb/sensor.py b/homeassistant/components/nasweb/sensor.py index eb342d7ce92..e01e401b2ba 100644 --- a/homeassistant/components/nasweb/sensor.py +++ b/homeassistant/components/nasweb/sensor.py @@ -6,6 +6,13 @@ import logging import time from webio_api import Input as NASwebInput, TempSensor +from webio_api.const import ( + STATE_INPUT_ACTIVE, + STATE_INPUT_NORMAL, + STATE_INPUT_PROBLEM, + STATE_INPUT_TAMPER, + STATE_INPUT_UNDEFINED, +) from homeassistant.components.sensor import ( DOMAIN as DOMAIN_SENSOR, @@ -28,11 +35,6 @@ from . import NASwebConfigEntry from .const import DOMAIN, KEY_TEMP_SENSOR, STATUS_UPDATE_MAX_TIME_INTERVAL SENSOR_INPUT_TRANSLATION_KEY = "sensor_input" -STATE_UNDEFINED = "undefined" -STATE_TAMPER = "tamper" -STATE_ACTIVE = "active" -STATE_NORMAL = "normal" -STATE_PROBLEM = "problem" _LOGGER = logging.getLogger(__name__) @@ -122,11 +124,11 @@ class InputStateSensor(BaseSensorEntity): _attr_device_class = SensorDeviceClass.ENUM _attr_options: list[str] = [ - STATE_UNDEFINED, - STATE_TAMPER, - STATE_ACTIVE, - STATE_NORMAL, - STATE_PROBLEM, + STATE_INPUT_ACTIVE, + STATE_INPUT_NORMAL, + STATE_INPUT_PROBLEM, + STATE_INPUT_TAMPER, + STATE_INPUT_UNDEFINED, ] _attr_translation_key = SENSOR_INPUT_TRANSLATION_KEY diff --git a/homeassistant/components/nasweb/switch.py b/homeassistant/components/nasweb/switch.py index 740db1ed1a1..06d3f57121e 100644 --- a/homeassistant/components/nasweb/switch.py +++ b/homeassistant/components/nasweb/switch.py @@ -7,6 +7,7 @@ import time from typing import Any from webio_api import Output as NASwebOutput +from webio_api.const import STATE_ENTITY_UNAVAILABLE, STATE_OUTPUT_OFF, STATE_OUTPUT_ON from homeassistant.components.switch import DOMAIN as DOMAIN_SWITCH, SwitchEntity from homeassistant.core import HomeAssistant, callback @@ -25,6 +26,12 @@ from .coordinator import NASwebCoordinator OUTPUT_TRANSLATION_KEY = "switch_output" +NASWEB_STATE_TO_HA_STATE = { + STATE_ENTITY_UNAVAILABLE: None, + STATE_OUTPUT_ON: True, + STATE_OUTPUT_OFF: False, +} + _LOGGER = logging.getLogger(__name__) @@ -105,7 +112,7 @@ class RelaySwitch(SwitchEntity, BaseCoordinatorEntity): @callback def _handle_coordinator_update(self) -> None: """Handle updated data from the coordinator.""" - self._attr_is_on = self._output.state + self._attr_is_on = NASWEB_STATE_TO_HA_STATE[self._output.state] if ( self.coordinator.last_update is None or time.time() - self._output.last_update >= STATUS_UPDATE_MAX_TIME_INTERVAL diff --git a/requirements_all.txt b/requirements_all.txt index c4a4144fa14..8512f01af2f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -3147,7 +3147,7 @@ weatherflow4py==1.4.1 webexpythonsdk==2.0.1 # homeassistant.components.nasweb -webio-api==0.1.11 +webio-api==0.1.12 # homeassistant.components.webmin webmin-xmlrpc==0.0.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 62954cba8be..c19fe24fa7f 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2606,7 +2606,7 @@ watergate-local-api==2024.4.1 weatherflow4py==1.4.1 # homeassistant.components.nasweb -webio-api==0.1.11 +webio-api==0.1.12 # homeassistant.components.webmin webmin-xmlrpc==0.0.2