Skip to content

have climate fallback to state if no ATTR_OPERATION_MODE (#12272)#12279

Merged
balloob merged 1 commit intohome-assistant:devfrom
ttroy50:issue-#12271-ephember-with-google-assistant
Feb 10, 2018
Merged

have climate fallback to state if no ATTR_OPERATION_MODE (#12272)#12279
balloob merged 1 commit intohome-assistant:devfrom
ttroy50:issue-#12271-ephember-with-google-assistant

Conversation

@ttroy50
Copy link
Copy Markdown
Contributor

@ttroy50 ttroy50 commented Feb 10, 2018

Description:

As described in #12272 if a cliate device doesn't support setting operation mode, the google assistant component will not return the state of the device.

This updates google assistant to fallback to using the state if the operation_mode attribute is not available.

Related issue (if applicable): fixes #12272

Checklist:

  • The code change is tested and works locally.

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New 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:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@balloob
Copy link
Copy Markdown
Member

balloob commented Feb 10, 2018

State is almost always equal to operation mode (source). Better to just point Google Assistant at the state instead of doing an if…else.

@ttroy50
Copy link
Copy Markdown
Contributor Author

ttroy50 commented Feb 10, 2018

@balloob I considered just returning state but thought that the check of is_on might change some existing components so didn't want to risk that.

You could avoid the if .. else if I rewrote it as mode = entity.attributes.get(climate.ATTR_OPERATION_MODE, entity.state).lower() but I personally prefer the more explicit if .. else

@balloob balloob merged commit fe1a850 into home-assistant:dev Feb 10, 2018
@ttroy50 ttroy50 deleted the issue-#12271-ephember-with-google-assistant branch February 10, 2018 23:12
@balloob balloob mentioned this pull request Feb 22, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 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.

Google assistant error with ephember

3 participants