Skip to content
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

Add broadlink climate #91183

Merged
merged 14 commits into from Nov 14, 2023
Merged

Add broadlink climate #91183

merged 14 commits into from Nov 14, 2023

Conversation

eifinger
Copy link
Contributor

@eifinger eifinger commented Apr 10, 2023

Proposed change

This is an attempt to revive #61681

This PR adds the capability to control thermostats with the broadlink integration.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

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

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @Danielhiversen, @felipediel, @L-I-Am, mind taking a look at this pull request as it has been labeled with an integration (broadlink) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of broadlink can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign broadlink Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@eifinger
Copy link
Contributor Author

eifinger commented Apr 27, 2023

Thank you for your feedback @fustom. I implemented the suggested changes.

Copy link

@fustom fustom left a comment

Choose a reason for hiding this comment

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

LGTM

@fustom
Copy link

fustom commented Apr 27, 2023

I tested a little bit and unfortunately there is an error:

Logger: homeassistant.components.climate
Source: components/climate/__init__.py:245
Integration: Climate (documentation, issues)
First occurred: 19:05:25 (8 occurrences)
Last logged: 19:57:20

Error adding entities for domain climate with platform broadlink
Error while setting up broadlink platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 823, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 568, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 632, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 574, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 245, in state
    return HVACMode(self.hvac_mode).value
  File "/usr/local/lib/python3.10/enum.py", line 385, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.10/enum.py", line 710, in __new__
    raise ve_exc
ValueError: 'unavailable' is not a valid HVACMode

We need to check the state is in a HVACMode. I think the following change should solve the problem.

UPDATE: Doesn't work with HA StrEnum!

if old_state.state in HVACMode:
self._attr_hvac_mode = old_state.state

This should work:

if old_state.state in [mode.value for mode in HVACMode]:
    self._attr_hvac_mode = old_state.state

Maybe we need to do the same with HVACAction.

homeassistant/components/broadlink/climate.py Show resolved Hide resolved
homeassistant/components/broadlink/climate.py Outdated Show resolved Hide resolved
homeassistant/components/broadlink/climate.py Outdated Show resolved Hide resolved
homeassistant/components/broadlink/climate.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft September 13, 2023 13:04
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@felipediel
Copy link
Contributor

Looks good. If the code is working, I think it's ready to be merged.

@home-assistant home-assistant bot marked this pull request as draft November 14, 2023 13:07
@eifinger eifinger marked this pull request as ready for review November 14, 2023 14:10
Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Thanks @eifinger 👍

@edenhaus edenhaus merged commit 4465c74 into home-assistant:dev Nov 14, 2023
23 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2023
@home-assistant home-assistant unlocked this conversation Feb 18, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 20, 2024
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.

None yet

7 participants