core
core copied to clipboard
Add broadlink climate
Proposed change
This is an attempt to revive https://github.com/home-assistant/core/pull/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!)
- [x] 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
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request: https://github.com/home-assistant/home-assistant.io/pull/26949
Checklist
- [x] The code change is tested and works locally.
- [ ] Local tests pass. Your PR cannot be merged unless tests pass
- [x] There is no commented out code in this PR.
- [x] I have followed the development checklist
- [ ] I have followed the perfect PR recommendations
- [x] 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:
- [ ] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [x] 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 runningpython3 -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.
- [x] Untested files have been added to
.coveragerc.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other open pull requests in this repository.
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 closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign broadlinkRemoves the current integration label and assignees on the pull request, add the integration domain after the command.
Thank you for your feedback @fustom. I implemented the suggested changes.
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.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
@eifinger is there anything that could be done to have this merged?
@eifinger is there anything that could be done to have this merged?
You are sadly asking the wrong person. There is nothing I can do but wait
Looks good. If the code is working, I think it's ready to be merged.