diff --git a/homeassistant/components/flipr/binary_sensor.py b/homeassistant/components/flipr/binary_sensor.py index 64ccaf7553f..646e260bd60 100644 --- a/homeassistant/components/flipr/binary_sensor.py +++ b/homeassistant/components/flipr/binary_sensor.py @@ -45,7 +45,7 @@ class FliprBinarySensor(FliprEntity, BinarySensorEntity): """Representation of Flipr binary sensors.""" @property - def is_on(self): + def is_on(self) -> bool: """Return true if the binary sensor is on in case of a Problem is detected.""" return ( self.coordinator.data[self.entity_description.key] == "TooLow" diff --git a/homeassistant/components/flipr/config_flow.py b/homeassistant/components/flipr/config_flow.py index b1e4f31d044..5c8cc6f76fb 100644 --- a/homeassistant/components/flipr/config_flow.py +++ b/homeassistant/components/flipr/config_flow.py @@ -9,6 +9,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_EMAIL, CONF_PASSWORD +from homeassistant.data_entry_flow import FlowResult from .const import CONF_FLIPR_ID, DOMAIN @@ -20,12 +21,14 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): VERSION = 1 - _username: str | None = None - _password: str | None = None - _flipr_id: str | None = None - _possible_flipr_ids: list[str] | None = None + _username: str + _password: str + _flipr_id: str = "" + _possible_flipr_ids: list[str] - async def async_step_user(self, user_input=None): + async def async_step_user( + self, user_input: dict[str, str] | None = None + ) -> FlowResult: """Handle the initial step.""" if user_input is None: return self._show_setup_form() @@ -92,7 +95,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return flipr_ids - async def async_step_flipr_id(self, user_input=None): + async def async_step_flipr_id( + self, user_input: dict[str, str] | None = None + ) -> FlowResult: """Handle the initial step.""" if not user_input: # Creation of a select with the proposal of flipr ids values found by API. diff --git a/homeassistant/components/flipr/manifest.json b/homeassistant/components/flipr/manifest.json index 35fbe8259a2..f88ea64dc3a 100644 --- a/homeassistant/components/flipr/manifest.json +++ b/homeassistant/components/flipr/manifest.json @@ -3,7 +3,7 @@ "name": "Flipr", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/flipr", - "requirements": ["flipr-api==1.4.2"], + "requirements": ["flipr-api==1.4.4"], "codeowners": ["@cnico"], "iot_class": "cloud_polling", "loggers": ["flipr_api"] diff --git a/homeassistant/components/flipr/sensor.py b/homeassistant/components/flipr/sensor.py index 9cf788d7170..99b44cc95a0 100644 --- a/homeassistant/components/flipr/sensor.py +++ b/homeassistant/components/flipr/sensor.py @@ -8,7 +8,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ELECTRIC_POTENTIAL_MILLIVOLT, TEMP_CELSIUS +from homeassistant.const import ELECTRIC_POTENTIAL_MILLIVOLT, PERCENTAGE, TEMP_CELSIUS from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -48,6 +48,13 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( icon="mdi:pool", state_class=SensorStateClass.MEASUREMENT, ), + SensorEntityDescription( + key="battery", + name="Battery Level", + native_unit_of_measurement=PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.BATTERY, + ), ) @@ -67,6 +74,6 @@ class FliprSensor(FliprEntity, SensorEntity): """Sensor representing FliprSensor data.""" @property - def native_value(self): + def native_value(self) -> str: """State of the sensor.""" return self.coordinator.data[self.entity_description.key] diff --git a/requirements_all.txt b/requirements_all.txt index 9252d244a53..2b0c55828a9 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -705,7 +705,7 @@ fixerio==1.0.0a0 fjaraskupan==2.2.0 # homeassistant.components.flipr -flipr-api==1.4.2 +flipr-api==1.4.4 # homeassistant.components.flux_led flux_led==0.28.32 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3a8681f3d9a..99f7cdfd899 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -527,7 +527,7 @@ fivem-api==0.1.2 fjaraskupan==2.2.0 # homeassistant.components.flipr -flipr-api==1.4.2 +flipr-api==1.4.4 # homeassistant.components.flux_led flux_led==0.28.32 diff --git a/tests/components/flipr/test_sensor.py b/tests/components/flipr/test_sensor.py index 1b8a1928b1f..51fbf2941f8 100644 --- a/tests/components/flipr/test_sensor.py +++ b/tests/components/flipr/test_sensor.py @@ -11,6 +11,7 @@ from homeassistant.const import ( ATTR_UNIT_OF_MEASUREMENT, CONF_EMAIL, CONF_PASSWORD, + PERCENTAGE, TEMP_CELSIUS, ) from homeassistant.core import HomeAssistant @@ -29,6 +30,7 @@ MOCK_FLIPR_MEASURE = { "date_time": MOCK_DATE_TIME, "ph_status": "TooLow", "chlorine_status": "Medium", + "battery": 95.0, } @@ -94,6 +96,13 @@ async def test_sensors(hass: HomeAssistant) -> None: assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT assert state.state == "0.23654886" + state = hass.states.get("sensor.flipr_myfliprid_battery_level") + assert state + assert state.attributes.get(ATTR_ICON) is None + assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE + assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT + assert state.state == "95.0" + async def test_error_flipr_api_sensors(hass: HomeAssistant) -> None: """Test the Flipr sensors error."""