Remove unneeded variable in Flo (#99322)
This commit is contained in:
parent
f9b2e10f72
commit
549399cca6
3 changed files with 4 additions and 19 deletions
|
@ -1,8 +1,6 @@
|
|||
"""Base entity class for Flo entities."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
|
@ -27,7 +25,6 @@ class FloEntity(Entity):
|
|||
self._attr_unique_id = f"{device.mac_address}_{entity_type}"
|
||||
|
||||
self._device: FloDeviceDataUpdateCoordinator = device
|
||||
self._state: Any = None
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
|
|
|
@ -68,7 +68,6 @@ class FloDailyUsageSensor(FloEntity, SensorEntity):
|
|||
def __init__(self, device):
|
||||
"""Initialize the daily water usage sensor."""
|
||||
super().__init__("daily_consumption", device)
|
||||
self._state: float = None
|
||||
|
||||
@property
|
||||
def native_value(self) -> float | None:
|
||||
|
@ -86,7 +85,6 @@ class FloSystemModeSensor(FloEntity, SensorEntity):
|
|||
def __init__(self, device):
|
||||
"""Initialize the system mode sensor."""
|
||||
super().__init__("current_system_mode", device)
|
||||
self._state: str = None
|
||||
|
||||
@property
|
||||
def native_value(self) -> str | None:
|
||||
|
@ -107,7 +105,6 @@ class FloCurrentFlowRateSensor(FloEntity, SensorEntity):
|
|||
def __init__(self, device):
|
||||
"""Initialize the flow rate sensor."""
|
||||
super().__init__("current_flow_rate", device)
|
||||
self._state: float = None
|
||||
|
||||
@property
|
||||
def native_value(self) -> float | None:
|
||||
|
@ -129,7 +126,6 @@ class FloTemperatureSensor(FloEntity, SensorEntity):
|
|||
super().__init__("temperature", device)
|
||||
if is_water:
|
||||
self._attr_translation_key = "water_temperature"
|
||||
self._state: float = None
|
||||
|
||||
@property
|
||||
def native_value(self) -> float | None:
|
||||
|
@ -149,7 +145,6 @@ class FloHumiditySensor(FloEntity, SensorEntity):
|
|||
def __init__(self, device):
|
||||
"""Initialize the humidity sensor."""
|
||||
super().__init__("humidity", device)
|
||||
self._state: float = None
|
||||
|
||||
@property
|
||||
def native_value(self) -> float | None:
|
||||
|
@ -170,7 +165,6 @@ class FloPressureSensor(FloEntity, SensorEntity):
|
|||
def __init__(self, device):
|
||||
"""Initialize the pressure sensor."""
|
||||
super().__init__("water_pressure", device)
|
||||
self._state: float = None
|
||||
|
||||
@property
|
||||
def native_value(self) -> float | None:
|
||||
|
@ -190,7 +184,6 @@ class FloBatterySensor(FloEntity, SensorEntity):
|
|||
def __init__(self, device):
|
||||
"""Initialize the battery sensor."""
|
||||
super().__init__("battery", device)
|
||||
self._state: float = None
|
||||
|
||||
@property
|
||||
def native_value(self) -> float | None:
|
||||
|
|
|
@ -73,12 +73,7 @@ class FloSwitch(FloEntity, SwitchEntity):
|
|||
def __init__(self, device: FloDeviceDataUpdateCoordinator) -> None:
|
||||
"""Initialize the Flo switch."""
|
||||
super().__init__("shutoff_valve", device)
|
||||
self._state = self._device.last_known_valve_state == "open"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return True if the valve is open."""
|
||||
return self._state
|
||||
self._attr_is_on = device.last_known_valve_state == "open"
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
@ -90,19 +85,19 @@ class FloSwitch(FloEntity, SwitchEntity):
|
|||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Open the valve."""
|
||||
await self._device.api_client.device.open_valve(self._device.id)
|
||||
self._state = True
|
||||
self._attr_is_on = True
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Close the valve."""
|
||||
await self._device.api_client.device.close_valve(self._device.id)
|
||||
self._state = False
|
||||
self._attr_is_on = False
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def async_update_state(self) -> None:
|
||||
"""Retrieve the latest valve state and update the state machine."""
|
||||
self._state = self._device.last_known_valve_state == "open"
|
||||
self._attr_is_on = self._device.last_known_valve_state == "open"
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue