Skip to content

Commit

Permalink
Reapply "ruff remove else"
Browse files Browse the repository at this point in the history
This reverts commit 3c2fae3.
  • Loading branch information
jontofront committed Oct 14, 2024
1 parent 3c2fae3 commit 4dc6377
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
9 changes: 4 additions & 5 deletions custom_components/econet300/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ def create_controller_sensors(coordinator: EconetDataCoordinator, api: Econet300
data_key,
)
continue
else:
_LOGGER.warning(
"Key: %s is not mapped, sensor entity will not be added",
data_key,
)
_LOGGER.warning(
"Key: %s is not mapped, sensor entity will not be added",
data_key,
)

return entities

Expand Down
35 changes: 35 additions & 0 deletions custom_components/econet300/switch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Platform econet300 switch integration."""

from homeassistant.components.switch import SwitchEntity


class BoilerSwitch(SwitchEntity):
"""Representation of a switch to control the boiler."""

def __init__(self, hass, name, api):
"""Initialize the boiler switch."""
self._name = name
self._api = api
self._is_on = False

@property
def name(self):
"""Return the name of the switch."""
return self._name

@property
def is_on(self):
"""Return true if the switch is on."""
return self._is_on

async def async_turn_on(self, **kwargs):
"""Turn the boiler on."""
response = await self._api.set_param("BOILER_CONTROL", "1")
if response and response["result"] == "OK":
self._is_on = True

async def async_turn_off(self, **kwargs):
"""Turn the boiler off."""
response = await self._api.set_param("BOILER_CONTROL", "0")
if response and response["result"] == "OK":
self._is_on = False

0 comments on commit 4dc6377

Please sign in to comment.