Skip to content

Add MQTT climate setting for current humidity#84592

Merged
jbouwh merged 20 commits into
home-assistant:devfrom
Stonos:mqtt_climate_humidity
Jan 3, 2023
Merged

Add MQTT climate setting for current humidity#84592
jbouwh merged 20 commits into
home-assistant:devfrom
Stonos:mqtt_climate_humidity

Conversation

@Stonos
Copy link
Copy Markdown
Contributor

@Stonos Stonos commented Dec 27, 2022

Proposed change

This change introduces two new variables to the MQTT Climate: current_humidity_template and current_humidity_topic. These allow you to set the current humidity of the MQTT Climate, and work in a similar way to current_temperature_template and current_temperature_topic respectively.

One benefit of this is that it allows other integrations to use this value. For example, it's possible to see the current humidity in Google Home with this change:

image

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
  • 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
Copy Markdown
Contributor

Hi Stonos

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @emontnemery, @jbouwh, mind taking a look at this pull request as it has been labeled with an integration (mqtt) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of mqtt can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign mqtt Removes the current integration label and assignees on the issue, add the integration domain after the command.

Copy link
Copy Markdown
Contributor

@jbouwh jbouwh left a comment

Choose a reason for hiding this comment

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

Nice idea to add this missing functionality to MQTT climate. It only misses support to be able to set a humidity yet.

Comment thread homeassistant/components/mqtt/climate.py
Comment thread homeassistant/components/mqtt/climate.py Outdated
@jbouwh
Copy link
Copy Markdown
Contributor

jbouwh commented Dec 31, 2022

Let me know if you can follow up on the request to do some changes. I think the start is okay. If you like , I could help getting some progress to this Idea. Let me know, what you if you would like that.

@Stonos
Copy link
Copy Markdown
Contributor Author

Stonos commented Dec 31, 2022

Sorry, I didn't have much time to work on it in the past few days. I'll try to make the requested changes either today or tomorrow. Thanks, I'll let you know if I have any questions/need help!

@Stonos Stonos force-pushed the mqtt_climate_humidity branch from 2f90657 to 38f7bd4 Compare January 1, 2023 12:20
@Stonos Stonos marked this pull request as draft January 1, 2023 12:20
Comment thread homeassistant/components/mqtt/climate.py Outdated
Comment thread homeassistant/components/mqtt/climate.py Outdated
Comment thread homeassistant/components/mqtt/climate.py Outdated
@MartinHjelmare MartinHjelmare changed the title MQTT Climate: Add support for setting the current humidity via MQTT Add MQTT climate setting for current humidity Jan 1, 2023
Copy link
Copy Markdown
Contributor

@jbouwh jbouwh left a comment

Choose a reason for hiding this comment

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

Nice progress, added some more comments.

Comment thread homeassistant/components/mqtt/climate.py Outdated
Comment thread homeassistant/components/mqtt/abbreviations.py Outdated
Comment thread homeassistant/components/mqtt/climate.py Outdated
Comment thread homeassistant/components/mqtt/climate.py Outdated
Comment thread homeassistant/components/mqtt/climate.py Outdated
@log_messages(self.hass, self.entity_id)
def handle_current_humidity_received(msg: ReceiveMessage) -> None:
"""Handle current humidity coming via MQTT."""
handle_climate_attribute_received(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just for the record
It is okay to enable to setting the current humidity attribute, even if ClimateEntityFeature.TARGET_HUMIDITY is not set.

Comment thread homeassistant/components/mqtt/climate.py
Comment thread homeassistant/components/mqtt/climate.py
Comment thread homeassistant/components/mqtt/climate.py
@jbouwh
Copy link
Copy Markdown
Contributor

jbouwh commented Jan 2, 2023

I had #84777 merged. This PR adds optimistic mode support to MQTT climate. You will have to rebase your PR.

Comment thread homeassistant/components/mqtt/climate.py
@Stonos Stonos force-pushed the mqtt_climate_humidity branch from f86c32d to c56806a Compare January 2, 2023 20:16
@Stonos Stonos marked this pull request as ready for review January 2, 2023 20:36
Copy link
Copy Markdown
Contributor

@jbouwh jbouwh left a comment

Choose a reason for hiding this comment

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

Almost there, nice work! Left a few comments.

Comment thread homeassistant/components/mqtt/climate.py
Comment thread homeassistant/components/mqtt/climate.py
Comment thread homeassistant/components/mqtt/climate.py Outdated
Copy link
Copy Markdown
Contributor

@jbouwh jbouwh left a comment

Choose a reason for hiding this comment

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

Looks nice, I left a suggestion for you to remove the validation on receiving the state target humidity as it is not needed.
I'll ask @emontnemery to have a look as well.

Comment thread homeassistant/components/mqtt/climate.py Outdated
Comment thread homeassistant/components/mqtt/climate.py Outdated
…y_received


It's not needed because this is covered by the `valid_humidity_state_configuration` validation.

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
Comment thread homeassistant/components/mqtt/climate.py Outdated
Comment thread homeassistant/components/mqtt/climate.py Outdated
It is covered by the base Climate entity.

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
@jbouwh jbouwh added the smash Indicator this PR is close to finish for merging or closing label Jan 3, 2023
Copy link
Copy Markdown
Contributor

@jbouwh jbouwh left a comment

Choose a reason for hiding this comment

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

Nice first contribution,
Thnx @Stonos!

@jbouwh jbouwh merged commit 799d527 into home-assistant:dev Jan 3, 2023
@Stonos
Copy link
Copy Markdown
Contributor Author

Stonos commented Jan 3, 2023

Thank you! And thanks for the review & the guidance you've provided! 🙂

I will update the documentation next.

@github-actions github-actions Bot locked and limited conversation to collaborators Jan 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed core has-tests integration: mqtt new-feature Quality Scale: gold small-pr PRs with less than 30 lines. smash Indicator this PR is close to finish for merging or closing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants