Skip to content

Move power and energy attributes to sensors for SmartThings Air conditioner#72594

Merged
emontnemery merged 1 commit into
home-assistant:devfrom
mbo18:move-power-and-energy-attributes-to-sensors
Jun 29, 2022
Merged

Move power and energy attributes to sensors for SmartThings Air conditioner#72594
emontnemery merged 1 commit into
home-assistant:devfrom
mbo18:move-power-and-energy-attributes-to-sensors

Conversation

@mbo18
Copy link
Copy Markdown
Contributor

@mbo18 mbo18 commented May 27, 2022

Breaking change

The following power attributes:

power_consumption_start
power_consumption_end
power_consumption_power
power_consumption_energy

from the climate entity for Smartthings Air Conditioner have been removed and added as separate sensors. Please update your templates, automation and any other configuration accordingly.

Proposed change

Move power and energy attributes from the climate entity for Smarttings Air Conditioner to separate sensors like it is done for other Smartthings devices (refrigerator for example)
These sensors can now be used directly in the Energy dashboard without the need for templates sensors.

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)
  • 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.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link
Copy Markdown

Hey there @andrewsayre, mind taking a look at this pull request as it has been labeled with an integration (smartthings) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@frenck frenck changed the title Move power and energy attributes to sensors for Air conditioner Move power and energy attributes to sensors for SmartThings Air conditioner May 30, 2022
@mbo18
Copy link
Copy Markdown
Contributor Author

mbo18 commented Jun 20, 2022

Anyone to review my PR :)
It seems that andrewsayre is not currently active.

Note: this PR needs the breaking change label

@frenck frenck added breaking-change smash Indicator this PR is close to finish for merging or closing labels Jun 22, 2022
@balloob
Copy link
Copy Markdown
Member

balloob commented Jun 29, 2022

I see them being removed as attributes but I don't see the code to add them as sensors?

@mbo18
Copy link
Copy Markdown
Contributor Author

mbo18 commented Jun 29, 2022

I see them being removed as attributes but I don't see the code to add them as sensors?

Hi @balloob! Thanks for reviewing.
I will try to be as clear as possible regarding the way this integration works:

First, devices are polled to get their capabilities and to match a HA domain. The code doing this is here:

def _assign_capabilities(self, devices: Iterable):

This code gets capabilities based on a fixed platform order:
# Ordered 'specific to least-specific platform' in order for capabilities

The first platform to be tested is CLIMATE. And in the current code, the power_consumption_report capability is available so it's matched and will never be matched by another platform:

Capability.power_consumption_report,

By removing this line and so the capability from the CLIMATE platform, it will then be matched by the SENSOR platform:

Capability.power_consumption_report: [],

elif capability == Capability.power_consumption_report:

and these power sensors will be then added to HA here:

elif capability == Capability.power_consumption_report:

class SmartThingsPowerConsumptionSensor(SmartThingsEntity, SensorEntity):

like any other smartthings device that has the power consumption report capability.

I hope that my explanation is clear :)

@mbo18
Copy link
Copy Markdown
Contributor Author

mbo18 commented Jun 29, 2022

In the Device UI, it looks like this (my AC is currently off so power = 0):
Capture d’écran 2022-06-29 à 10 46 17

All these sensors are now available (code is already there) : in addition to Power and Energy (that are currently available as attributes), users will now also have Delta Energy, Energy Saved and Power Energy like other Smartthings devices that support Power consumption report capability.

Copy link
Copy Markdown
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @mbo18 👍

@emontnemery emontnemery merged commit 9d73f9a into home-assistant:dev Jun 29, 2022
@mbo18 mbo18 deleted the move-power-and-energy-attributes-to-sensors branch June 29, 2022 11:17
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

breaking-change cla-signed has-tests integration: smartthings new-feature 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.

7 participants