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

Fix deprecation warnings on initialization #24

Merged
merged 3 commits into from
Mar 18, 2024

Conversation

danelphick
Copy link
Contributor

This fixes a couple of different warnings that show up in the logs.

This adds ClimateEntityFeature.TURN_ON and ClimateEntityFeature.TURN_OFF
to supported features and disables the backwards compatibility flag
related to those. This prevents a warning at initialization.

Specific warning is:
Entity None (<class 'custom_components.wundasmart.climate.Device'>)
implements HVACMode(s): off, auto, heat and therefore implicitly
supports the turn_on/turn_off methods without setting the proper
ClimateEntityFeature. Please create a bug report at
https://github.com/tonyroberts/hawundasmart/issues
Copy link
Owner

@tonyroberts tonyroberts left a comment

Choose a reason for hiding this comment

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

For the TURN_ON/TURN_OFF flags, don't the "turn_on" and "turn_off" methods need to be implemented if those flags are set?

The way I read https://developers.home-assistant.io/blog/2024/01/24/climate-climateentityfeatures-expanded/ is that _enable_turn_on_off_backwards_compatibility should be set to False to stop those feature flags from being inferred automatically, but if the turn_on/turn_off methods are not implemented those feature flags should not be set.

Unless I'm missing something, either the turn_on/off methods need to be implemented, or the TURN_ON/TURN_OFF feature flags should not be set.

@danelphick danelphick changed the title FIx deprecation warnings on initialization Fix deprecation warnings on initialization Mar 17, 2024
@danelphick
Copy link
Contributor Author

From https://github.com/home-assistant/core/blob/0643ff1cfe1057617cb6fda410084022f99d9252/homeassistant/components/climate/__init__.py#L746, it looks like the service calls always exist and if turn_off/turn_off aren't overidden, it would emulate turn_off/turn_on via HVACMode if possible (which it would be for hawundasmart).

I thought the blog post was saying that the flag was necessary so that in the future these service calls would not be hidden. That said I find the documentation/blog posts quite terse and hard to decipher.

Just to test things out, I created a button with this config for my kitchen sensor:

show_name: true
show_icon: true
type: entity-button
entity: climate.kitchen
tap_action:
  service: climate.turn_on
  action: call-service
  target:
    entity_id:
      - climate.kitchen
icon: mdi:weather-night

I clicked the button and confirmed the result with the wunda app. The kitchen thermostat was now set to on. I changed it turn_off and clicked it again and the thermostat was set to off.

@danelphick
Copy link
Contributor Author

All that said, I removed the flags for now. Can always add them back later if the service calls are required.

@tonyroberts tonyroberts merged commit e6b1165 into tonyroberts:dev Mar 18, 2024
2 checks passed
@tonyroberts
Copy link
Owner

Thanks for the PR @danelphick! :)

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants