-
-
Notifications
You must be signed in to change notification settings - Fork 38k
Eph ember support operation modes #15820
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
MartinHjelmare
merged 6 commits into
home-assistant:dev
from
ttroy50:EphEmber-support-operation-modes
Aug 12, 2018
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7d7ff0c
add operation mode support for climate.EphEmber
ttroy50 2dc61b7
Merge branch 'dev' into EphEmber-support-operation-modes
ttroy50 8a814ca
fix linting errors from py3.5
ttroy50 e6135d7
remove STATE_ALL_DAY and cleanup some code based on review
ttroy50 e21d418
use explicit None return with get
ttroy50 b48ebbf
fix none return
ttroy50 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,13 +9,14 @@ | |
| import voluptuous as vol | ||
|
|
||
| from homeassistant.components.climate import ( | ||
| ClimateDevice, PLATFORM_SCHEMA, STATE_HEAT, STATE_IDLE, SUPPORT_AUX_HEAT, | ||
| ClimateDevice, PLATFORM_SCHEMA, STATE_HEAT, STATE_OFF, | ||
| STATE_AUTO, SUPPORT_AUX_HEAT, SUPPORT_OPERATION_MODE, | ||
| SUPPORT_TARGET_TEMPERATURE) | ||
| from homeassistant.const import ( | ||
| TEMP_CELSIUS, CONF_USERNAME, CONF_PASSWORD, ATTR_TEMPERATURE) | ||
| import homeassistant.helpers.config_validation as cv | ||
|
|
||
| REQUIREMENTS = ['pyephember==0.1.1'] | ||
| REQUIREMENTS = ['pyephember==0.2.0'] | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -27,6 +28,8 @@ | |
| vol.Required(CONF_PASSWORD): cv.string | ||
| }) | ||
|
|
||
| STATE_ALL_DAY = "all_day" | ||
|
|
||
|
|
||
| def setup_platform(hass, config, add_devices, discovery_info=None): | ||
| """Set up the ephember thermostat.""" | ||
|
|
@@ -61,9 +64,11 @@ def __init__(self, ember, zone): | |
| def supported_features(self): | ||
| """Return the list of supported features.""" | ||
| if self._hot_water: | ||
| return SUPPORT_AUX_HEAT | ||
| return SUPPORT_AUX_HEAT | SUPPORT_OPERATION_MODE | ||
|
|
||
| return SUPPORT_TARGET_TEMPERATURE | SUPPORT_AUX_HEAT | ||
| return (SUPPORT_TARGET_TEMPERATURE | | ||
| SUPPORT_AUX_HEAT | | ||
| SUPPORT_OPERATION_MODE) | ||
|
|
||
| @property | ||
| def name(self): | ||
|
|
@@ -93,12 +98,40 @@ def target_temperature_step(self): | |
|
|
||
| return 1 | ||
|
|
||
| @property | ||
| def device_state_attributes(self): | ||
| """Show Device Attributes.""" | ||
| attributes = { | ||
| 'currently_active': self._zone['isCurrentlyActive'] | ||
| } | ||
| return attributes | ||
|
|
||
| @property | ||
| def current_operation(self): | ||
| """Return current operation ie. heat, cool, idle.""" | ||
| mode = self._ember.get_zone_mode(self._zone_name) | ||
| return self.map_mode_eph_hass(mode) | ||
|
|
||
| @property | ||
| def operation_list(self): | ||
| """Return the supported operations.""" | ||
| return [STATE_AUTO, STATE_ALL_DAY, STATE_HEAT, STATE_OFF] | ||
|
|
||
| def set_operation_mode(self, operation_mode): | ||
| """Set the operation mode.""" | ||
| mode = self.map_mode_hass_eph(operation_mode) | ||
| if mode is not None: | ||
| self._ember.set_mode_by_name(self._zone_name, mode) | ||
| else: | ||
| _LOGGER.error("Invalid operation mode provided %s", operation_mode) | ||
|
|
||
| @property | ||
| def is_on(self): | ||
| """Return current state.""" | ||
| if self._zone['isCurrentlyActive']: | ||
| return STATE_HEAT | ||
| return STATE_IDLE | ||
| return True | ||
|
|
||
| return None | ||
|
|
||
| @property | ||
| def is_aux_heat_on(self): | ||
|
|
@@ -152,3 +185,33 @@ def max_temp(self): | |
| def update(self): | ||
| """Get the latest data.""" | ||
| self._zone = self._ember.get_zone(self._zone_name) | ||
|
|
||
| @staticmethod | ||
| def map_mode_hass_eph(operation_mode): | ||
| """Map from home assistant mode to eph mode.""" | ||
| from pyephember.pyephember import ZoneMode | ||
| if operation_mode == STATE_AUTO: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can instead make a dictionary that holds the map, put at the module level, and use |
||
| return ZoneMode.AUTO | ||
| if operation_mode == STATE_ALL_DAY: | ||
| return ZoneMode.ALL_DAY | ||
| if operation_mode == STATE_HEAT: | ||
| return ZoneMode.ON | ||
| if operation_mode == STATE_OFF: | ||
| return ZoneMode.OFF | ||
|
|
||
| return None | ||
|
|
||
| @staticmethod | ||
| def map_mode_eph_hass(operation_mode): | ||
| """Map from eph mode to home assistant mode.""" | ||
| from pyephember.pyephember import ZoneMode | ||
| if operation_mode == ZoneMode.AUTO: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
| return STATE_AUTO | ||
| if operation_mode == ZoneMode.ALL_DAY: | ||
| return STATE_ALL_DAY | ||
| if operation_mode == ZoneMode.ON: | ||
| return STATE_HEAT | ||
| if operation_mode == ZoneMode.OFF: | ||
| return STATE_OFF | ||
|
|
||
| return None | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to a module level constant and return that here.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No operation modes that are not defined in the climate base component are allowed. Please remove
STATE_ALL_DAY. New modes must be proposed and accepted via an issue in our architecture repo.We're currently reviewing the climate component in our architecture repo.