Skip to content

Commit

Permalink
Merge pull request #127 from peribeir/peribeir/issue91
Browse files Browse the repository at this point in the history
Fixes issue #91
  • Loading branch information
peribeir authored Sep 22, 2024
2 parents 6bb1435 + 70a22f7 commit d42861f
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 52 deletions.
5 changes: 2 additions & 3 deletions custom_components/rademacher/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,5 @@ def available(self):
async def async_press(self) -> None:
device: HomePilotDevice = self.coordinator.data[self.did]
await device.async_ping()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()

async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()
22 changes: 14 additions & 8 deletions custom_components/rademacher/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,24 @@ def __init__(
self._attr_hvac_modes = (
[HVACMode.HEAT, HVACMode.OFF]
)
self._attr_preset_modes = ([PRESET_ECO, PRESET_BOOST, PRESET_NONE])
self._attr_preset_modes = ([PRESET_ECO, PRESET_BOOST])

async def async_set_hvac_mode(self, hvac_mode: str) -> None:
device: HomePilotThermostat = self.coordinator.data[self.did]

async def async_set_preset_mode(self, preset_mode: str) -> None:
device: HomePilotThermostat = self.coordinator.data[self.did]
if device.has_auto_mode:
await device.async_set_auto_mode(hvac_mode == HVACMode.AUTO)
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
await device.async_set_auto_mode(preset_mode == PRESET_ECO)
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_set_temperature(self, **kwargs) -> None:
device: HomePilotThermostat = self.coordinator.data[self.did]
if device.can_set_target_temperature:
await device.async_set_target_temperature(kwargs["temperature"])
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

@property
def current_temperature(self) -> float:
Expand Down Expand Up @@ -120,7 +123,10 @@ def hvac_mode(self) -> str:
def supported_features(self) -> int:
device: HomePilotThermostat = self.coordinator.data[self.did]
return (
ClimateEntityFeature.TARGET_TEMPERATURE
(ClimateEntityFeature.TARGET_TEMPERATURE
if device.can_set_target_temperature
else 0
else 0) |
(ClimateEntityFeature.PRESET_MODE
if device.has_auto_mode
else 0)
)
32 changes: 16 additions & 16 deletions custom_components/rademacher/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,47 +102,47 @@ def is_closed(self):
async def async_open_cover(self, **kwargs: Any) -> None:
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_open_cover()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_close_cover(self, **kwargs: Any) -> None:
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_close_cover()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_set_cover_position(self, **kwargs: Any) -> None:
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_set_cover_position(kwargs[ATTR_POSITION])
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_stop_cover(self, **kwargs: Any) -> None:
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_stop_cover()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_open_cover_tilt(self, **kwargs: Any) -> None:
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_open_cover_tilt()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_close_cover_tilt(self, **kwargs: Any) -> None:
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_close_cover_tilt()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_set_cover_tilt_position(kwargs[ATTR_TILT_POSITION])
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_stop_cover_tilt()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()
8 changes: 4 additions & 4 deletions custom_components/rademacher/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ async def async_turn_on(self, **kwargs: Any) -> None:
await device.async_set_brightness(round(kwargs[ATTR_BRIGHTNESS]*100/255))
else:
await device.async_turn_on()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_turn_off(self, **kwargs: Any) -> None:
device: HomePilotActuator = self.coordinator.data[self.did]
await device.async_turn_off()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()
2 changes: 1 addition & 1 deletion custom_components/rademacher/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/peribeir/homeassistant-rademacher/issues",
"requirements": ["pyrademacher==0.13.4", "asyncio>=3.4.3"],
"version": "2.1.2"
"version": "2.1.3"
}
8 changes: 4 additions & 4 deletions custom_components/rademacher/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ async def async_set_native_value(self, value):
"""Turn the entity on."""
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_set_ventilation_position(value)
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

class HomePilotTemperatureThresholdEntity(HomePilotEntity, NumberEntity):
"""This class represents Cover Ventilation Position."""
Expand Down Expand Up @@ -120,5 +120,5 @@ async def async_set_native_value(self, value):
"""Turn the entity on."""
device: HomePilotThermostat = self.coordinator.data[self.did]
await device.async_set_temperature_thresh_cfg(self._thresh_number, value)
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()
32 changes: 16 additions & 16 deletions custom_components/rademacher/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
device: HomePilotSwitch = self.coordinator.data[self.did]
await device.async_turn_on()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
device: HomePilotSwitch = self.coordinator.data[self.did]
await device.async_turn_off()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_toggle(self, **kwargs):
"""Toggle the entity."""
Expand Down Expand Up @@ -110,15 +110,15 @@ async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
device: HomePilotHub = self.coordinator.data[self.did]
await device.async_turn_led_on()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
device: HomePilotHub = self.coordinator.data[self.did]
await device.async_turn_led_off()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_toggle(self, **kwargs):
"""Toggle the entity."""
Expand Down Expand Up @@ -151,15 +151,15 @@ async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
device: HomePilotHub = self.coordinator.data[self.did]
await device.async_set_auto_update_on()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
device: HomePilotHub = self.coordinator.data[self.did]
await device.async_set_auto_update_off()
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_toggle(self, **kwargs):
"""Toggle the entity."""
Expand Down Expand Up @@ -192,15 +192,15 @@ async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_set_ventilation_position_mode(True)
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
device: HomePilotCover = self.coordinator.data[self.did]
await device.async_set_ventilation_position_mode(False)
await asyncio.sleep(5)
await self.coordinator.async_request_refresh()
async with asyncio.timeout(5):
await self.coordinator.async_request_refresh()

async def async_toggle(self, **kwargs):
"""Toggle the entity."""
Expand Down

0 comments on commit d42861f

Please sign in to comment.