Skip to content

Eph ember support operation modes#15820

Merged
MartinHjelmare merged 6 commits intohome-assistant:devfrom
ttroy50:EphEmber-support-operation-modes
Aug 12, 2018
Merged

Eph ember support operation modes#15820
MartinHjelmare merged 6 commits intohome-assistant:devfrom
ttroy50:EphEmber-support-operation-modes

Conversation

@ttroy50
Copy link
Copy Markdown
Contributor

@ttroy50 ttroy50 commented Aug 4, 2018

Description:

Adds support for operation modes in the EphEmber climate device

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable ([example][ex-requir]).
  • New dependencies are only imported inside functions that use them ([example][ex-import]).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@ttroy50
Copy link
Copy Markdown
Contributor Author

ttroy50 commented Aug 6, 2018

@frenck Docs updated on PR home-assistant/home-assistant.io#5967

@property
def operation_list(self):
"""Return the supported operations."""
return [STATE_AUTO, STATE_ALL_DAY, STATE_HEAT, STATE_OFF]
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare Aug 12, 2018

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.

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:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 getattr on ZoneModehere to get the correct attribute.

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:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

def map_mode_hass_eph(operation_mode):
"""Map from home assistant mode to eph mode."""
from pyephember.pyephember import ZoneMode
return getattr(ZoneMode, HA_STATE_TO_EPH.get(operation_mode))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a safe default.

return getattr(ZoneMode, HA_STATE_TO_EPH.get(operation_mode), None)

@ttroy50
Copy link
Copy Markdown
Contributor Author

ttroy50 commented Aug 12, 2018

I'm not sure why the latest CI building is failing on pylint. I'm not getting any errors locally (using py3.6) and can't see any reference to errors in my module.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can be merged when build passes.

@MartinHjelmare
Copy link
Copy Markdown
Member

I've restarted that build job. Let's see what happens.

@MartinHjelmare MartinHjelmare merged commit d3fed52 into home-assistant:dev Aug 12, 2018
@ghost ghost removed the in progress label Aug 12, 2018
@balloob balloob mentioned this pull request Aug 29, 2018
girlpunk pushed a commit to girlpunk/home-assistant that referenced this pull request Sep 4, 2018
* add operation mode support for climate.EphEmber

* fix linting errors from py3.5

* remove STATE_ALL_DAY and cleanup some code based on review

* use explicit None return with get

* fix none return
vrih pushed a commit to vrih/home-assistant that referenced this pull request Sep 29, 2018
* add operation mode support for climate.EphEmber

* fix linting errors from py3.5

* remove STATE_ALL_DAY and cleanup some code based on review

* use explicit None return with get

* fix none return
@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants