-
-
Notifications
You must be signed in to change notification settings - Fork 38.3k
Add switches (on/off zones) to geniushub #28182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zxdavb
merged 22 commits into
home-assistant:dev
from
castaway:feature/geniushub_switches
Nov 4, 2019
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c9932d4
New switch for geniushub outlets
castaway ef75d00
Load new geniushub switch component
castaway 4eb877e
Remove useless "__init__" function
castaway f512089
Tidy up based on some requests from @zxdavb
castaway 6a4d09b
Fix syntax typo
castaway aa4aee4
Inherit from GeniusEntity, so we don't drag zone heating stuff into S…
castaway f98fd32
Remove calls, suggestion from @zxdavb
castaway 47f980f
Re-organise to GeniusZone, GeniusHeatingZone, etc
castaway 1ba2339
Fixed issue with incorrect import
castaway 878d498
de-lint
zxdavb 518d71d
Fix small bug
zxdavb d75ffe6
Update switch.py
zxdavb 05f77d5
Update switch.py
zxdavb 0a3f116
de-lint
zxdavb b3d0c1b
Update to new gh client with switch on/off support
castaway 78e94e3
Update requirements for ghclient updated version
castaway fae6258
bump geniushub-client to 0.6.30
zxdavb ab3d798
bump geniushub-client to 0.6.30
zxdavb 7bf3518
Tidy up based on some requests from @zxdavb
castaway d5563df
Inherit from GeniusEntity, so we don't drag zone heating stuff into S…
castaway 45fbf10
Re-organise to GeniusZone, GeniusHeatingZone, etc
castaway 71026ed
Fixed issue with incorrect import
castaway File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): | ||
| """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)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.