Skip to content

Commit

Permalink
Fix unavailable
Browse files Browse the repository at this point in the history
    * custom_components/daikin_onecta/binary_sensor.py:
    * custom_components/daikin_onecta/climate.py:
    * custom_components/daikin_onecta/device.py:
    * custom_components/daikin_onecta/select.py:
    * custom_components/daikin_onecta/sensor.py:
    * custom_components/daikin_onecta/switch.py:
    * custom_components/daikin_onecta/water_heater.py:
    * tests/snapshots/test_init.ambr:
  • Loading branch information
jwillemsen committed May 14, 2024
1 parent bfd2e48 commit e0f058c
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 55 deletions.
10 changes: 5 additions & 5 deletions custom_components/daikin_onecta/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ def __init__(
)

def update_state(self) -> None:
if self._device.available:
self._attr_is_on = self.sensor_value()
else:
self._attr_is_on = None
self._attr_available = self._device.available
self._attr_is_on = self.sensor_value()
self._attr_device_info = self._device.device_info()

@property
def available(self) -> bool:
return self._device.available

@callback
def _handle_coordinator_update(self) -> None:
self.update_state()
Expand Down
10 changes: 4 additions & 6 deletions custom_components/daikin_onecta/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,17 @@ def update_state(self) -> None:
self._attr_swing_mode = self.get_swing_mode()
self._attr_preset_mode = self.get_preset_mode()
self._attr_fan_mode = self.get_fan_mode()
self._attr_available = self._device.available
self._attr_device_info = self._device.device_info()

@callback
def _handle_coordinator_update(self) -> None:
self.update_state()
self.async_write_ha_state()

@property
def available(self) -> bool:
return self._device.available

def climate_control(self):
cc = None
supported_management_point_types = {"climateControl"}
Expand Down Expand Up @@ -205,11 +208,6 @@ def sensory_data(self, setpoint):
def translation_key(self) -> str:
return "daikin_onecta"

@property
def available(self):
"""Return the availability of the underlying device."""
return self._device.available

def get_supported_features(self):
supported_features = 0
if hasattr(ClimateEntityFeature, "TURN_OFF"):
Expand Down
1 change: 0 additions & 1 deletion custom_components/daikin_onecta/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def __init__(self, jsonData, apiInstance):
"""Initialize a new Daikin Onecta Device."""
self.api = apiInstance
# get name from climateControl
self._available = True
self.daikin_data = jsonData
self.id = self.daikin_data["id"]
self.name = self.daikin_data["deviceModel"]
Expand Down
5 changes: 4 additions & 1 deletion custom_components/daikin_onecta/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ def __init__(self, device: DaikinOnectaDevice, coordinator, embedded_id, managem
def update_state(self) -> None:
self._attr_options = self.get_options()
self._attr_current_option = self.get_current_option()
self._attr_available = self._device.available
self._attr_device_info = self._device.device_info()

@property
def available(self) -> bool:
return self._device.available

@callback
def _handle_coordinator_update(self) -> None:
self.update_state()
Expand Down
20 changes: 10 additions & 10 deletions custom_components/daikin_onecta/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ def __init__(
)

def update_state(self) -> None:
if self._device.available:
self._attr_native_value = self.sensor_value()
else:
self._attr_native_value = None
self._attr_available = self._device.available
self._attr_native_value = self.sensor_value()
self._attr_device_info = self._device.device_info()

@property
def available(self) -> bool:
return self._device.available

@callback
def _handle_coordinator_update(self) -> None:
self.update_state()
Expand Down Expand Up @@ -276,13 +276,13 @@ def __init__(
)

def update_state(self) -> None:
if self._device.available:
self._attr_native_value = self.sensor_value()
else:
self._attr_native_value = None
self._attr_available = self._device.available
self._attr_native_value = self.sensor_value()
self._attr_device_info = self._device.device_info()

@property
def available(self) -> bool:
return self._device.available

@callback
def _handle_coordinator_update(self) -> None:
self.update_state()
Expand Down
5 changes: 4 additions & 1 deletion custom_components/daikin_onecta/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ def __init__(self, device: DaikinOnectaDevice, coordinator, embedded_id, managem

def update_state(self) -> None:
self._switch_state = self.sensor_value()
self._attr_available = self._device.available
self._attr_device_info = self._device.device_info()

@property
def available(self) -> bool:
return self._device.available

@callback
def _handle_coordinator_update(self) -> None:
self.update_state()
Expand Down
7 changes: 6 additions & 1 deletion custom_components/daikin_onecta/water_heater.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
e8:4f:25:c7:fe:da

"""Support for the Daikin BRP069A62."""
import logging

Expand Down Expand Up @@ -65,9 +67,12 @@ def update_state(self) -> None:
self._attr_max_temp = self.get_max_temp()
self._attr_operation_list = self.get_operation_list()
self._attr_current_operation = self.get_current_operation()
self._attr_available = self._device.available
self._attr_device_info = self._device.device_info()

@property
def available(self) -> bool:
return self._device.available

@callback
def _handle_coordinator_update(self) -> None:
self.update_state()
Expand Down

0 comments on commit e0f058c

Please sign in to comment.