Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions homeassistant/components/geniushub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:

async_track_time_interval(hass, broker.async_update, SCAN_INTERVAL)

for platform in ["climate", "water_heater", "sensor", "binary_sensor"]:
for platform in ["climate", "water_heater", "sensor", "binary_sensor", "switch"]:
hass.async_create_task(async_load_platform(hass, platform, DOMAIN, {}, config))

return True
Expand Down Expand Up @@ -215,8 +215,6 @@ def __init__(self, broker, zone) -> None:
self._zone = zone
self._unique_id = f"{broker.hub_uid}_zone_{zone.id}"

self._max_temp = self._min_temp = self._supported_features = None

@property
def name(self) -> str:
"""Return the name of the climate device."""
Expand All @@ -228,6 +226,16 @@ def device_state_attributes(self) -> Dict[str, Any]:
status = {k: v for k, v in self._zone.data.items() if k in GH_ZONE_ATTRS}
return {"status": status}


class GeniusHeatingZone(GeniusZone):
"""Base for Genius Heating Zones."""

def __init__(self, broker, zone) -> None:
"""Initialize the Zone."""
super().__init__(broker, zone)

self._max_temp = self._min_temp = self._supported_features = None

@property
def current_temperature(self) -> Optional[float]:
"""Return the current temperature."""
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/geniushub/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from homeassistant.helpers.typing import ConfigType, HomeAssistantType

from . import DOMAIN, GeniusZone
from . import DOMAIN, GeniusHeatingZone

# GeniusHub Zones support: Off, Timer, Override/Boost, Footprint & Linked modes
HA_HVAC_TO_GH = {HVAC_MODE_OFF: "off", HVAC_MODE_HEAT: "timer"}
Expand Down Expand Up @@ -45,7 +45,7 @@ async def async_setup_platform(
)


class GeniusClimateZone(GeniusZone, ClimateDevice):
class GeniusClimateZone(GeniusHeatingZone, ClimateDevice):
"""Representation of a Genius Hub climate device."""

def __init__(self, broker, zone) -> None:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/geniushub/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Genius Hub",
"documentation": "https://www.home-assistant.io/integrations/geniushub",
"requirements": [
"geniushub-client==0.6.28"
"geniushub-client==0.6.30"
],
"dependencies": [],
"codeowners": ["@zxdavb"]
Expand Down
55 changes: 55 additions & 0 deletions homeassistant/components/geniushub/switch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""Support for Genius Hub switch/outlet devices."""
from homeassistant.components.switch import SwitchDevice, DEVICE_CLASS_OUTLET
from homeassistant.helpers.typing import ConfigType, HomeAssistantType

from . import DOMAIN, GeniusZone

ATTR_DURATION = "duration"

GH_ON_OFF_ZONE = "on / off"


async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) -> None:
"""Set up the Genius Hub switch entities."""
if discovery_info is None:
return

broker = hass.data[DOMAIN]["broker"]

async_add_entities(
[
GeniusSwitch(broker, z)
for z in broker.client.zone_objs
if z.data["type"] == GH_ON_OFF_ZONE
]
)


class GeniusSwitch(GeniusZone, SwitchDevice):
Comment thread
zxdavb marked this conversation as resolved.
"""Representation of a Genius Hub switch."""

@property
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_OUTLET

@property
def is_on(self) -> bool:
"""Return the current state of the on/off zone.

The zone is considered 'on' if & only if it is override/on (e.g. timer/on is 'off').
"""
return self._zone.data["mode"] == "override" and self._zone.data["setpoint"]

async def async_turn_off(self, **kwargs) -> None:
"""Send the zone to Timer mode.

The zone is deemed 'off' in this mode, although the plugs may actually be on.
"""
await self._zone.set_mode("timer")

async def async_turn_on(self, **kwargs) -> None:
"""Set the zone to override/on ({'setpoint': true}) for x seconds."""
await self._zone.set_override(1, kwargs.get(ATTR_DURATION, 3600))
4 changes: 2 additions & 2 deletions homeassistant/components/geniushub/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant.const import STATE_OFF
from homeassistant.helpers.typing import ConfigType, HomeAssistantType

from . import DOMAIN, GeniusZone
from . import DOMAIN, GeniusHeatingZone

STATE_AUTO = "auto"
STATE_MANUAL = "manual"
Expand Down Expand Up @@ -49,7 +49,7 @@ async def async_setup_platform(
)


class GeniusWaterHeater(GeniusZone, WaterHeaterDevice):
class GeniusWaterHeater(GeniusHeatingZone, WaterHeaterDevice):
"""Representation of a Genius Hub water_heater device."""

def __init__(self, broker, zone) -> None:
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ gearbest_parser==1.0.7
geizhals==0.0.9

# homeassistant.components.geniushub
geniushub-client==0.6.28
geniushub-client==0.6.30

# homeassistant.components.geo_json_events
# homeassistant.components.nsw_rural_fire_service_feed
Expand Down