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 sensors for myStrom plugs #97024

Merged
merged 17 commits into from Oct 18, 2023

Conversation

MadMonkey87
Copy link
Contributor

@MadMonkey87 MadMonkey87 commented Jul 21, 2023

Proposed change

The myStrom power plugs do measure power consumption and temperature too, but the current HA is only representing them as a switch. This PR provides two more sensor entities to bring consumption & temperature into HA too.

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

Hi @MadMonkey87

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

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

Code owner commands

Code owners of mystrom 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 mystrom Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@home-assistant
Copy link

Hi @MadMonkey87

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!

Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

Some initial feedback

homeassistant/components/mystrom/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/mystrom/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/mystrom/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/mystrom/switch.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft July 21, 2023 18:35
@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.

@joostlek
Copy link
Member

joostlek commented Jul 21, 2023

Oh and fixes #53319 fixes #95979

Edit: Oh apparently "fixes" doesnt work in comments.

@joostlek
Copy link
Member

I worked on some bugs in this release and I noticed that not every device is consistent with the rest, which ones do you have?

It might be a good idea to add tests so we don't break this in a regression again, but I can get that it's a big step for a first PR. If you want I can help you with that!

@MartinHjelmare MartinHjelmare changed the title support sensors for myStrom plugs Add sensors for myStrom plugs Jul 21, 2023
@MadMonkey87
Copy link
Contributor Author

MadMonkey87 commented Jul 21, 2023

I worked on some bugs in this release and I noticed that not every device is consistent with the rest, which ones do you have?

It might be a good idea to add tests so we don't break this in a regression again, but I can get that it's a big step for a first PR. If you want I can help you with that!

That would be very helpful, thx! Jep this is the very first time I am working on HA ;P

PS: I have some legacy plugs (the ones with power measurement, but no temperature sensor and limited reporting) as well as a newer plug and some of the buttons

@joostlek
Copy link
Member

So if you don't have a temperature sensor, we should look if it works, and if it doesn't, how we work with it :). But that's something for tomorrow

@MadMonkey87
Copy link
Contributor Author

have some legacy plugs (the ones with power measurement, but no temperature sensor and limited reporting) as well as a newer plug and s

I have just one of the newer ones with temperature sensor, so it works;P

@joostlek
Copy link
Member

joostlek commented Aug 31, 2023

Looks like I need to provide a documentation PR? Is this really needed for this changes?

It would be nice to have some documentation for people to read about this nifty feature you added ;).

Doesn't have to be huge, it can be just a sentence like, yea and the plugs have two sensors for temperature and humidity.

MadMonkey87 added a commit to MadMonkey87/home-assistant.io that referenced this pull request Aug 31, 2023
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.

Please fix the CI and make sure it is passing.
Please also implement the requested changes of @gjohansson-ST

@@ -16,7 +16,7 @@
from .const import DOMAIN
from .models import MyStromData

PLATFORMS_SWITCH = [Platform.SWITCH]
PLATFORMS_SWITCH = [Platform.SWITCH, Platform.SENSOR]
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do the renaming in this PR, as it will improve the readability of the code. This constant is only used in two places in this file.

@home-assistant home-assistant bot marked this pull request as draft September 1, 2023 07:56
@Siggy101
Copy link

Happy Monday everyone.
Is there any chance that this new feature will go live in the near future? I am not familiar with the process, so please forgive my ignorance, but it appears that the hard work has been done and there are some documentation and validation remaining.

@edenhaus
Copy link
Contributor

Is there any chance that this new feature will go live in the near future?

This depends on @MadMonkey87, which is required to implement the requested changes. For this reason, the PR is in draft. We can merge the PR only if all is done, including creating a PR for the documentation.

@Siggy101
Copy link

Is there any chance that this new feature will go live in the near future?

This depends on @MadMonkey87, which is required to implement the requested changes. For this reason, the PR is in draft. We can merge the PR only if all is done, including creating a PR for the documentation.

Thanks for the clarification.

@MadMonkey87 Do you have a timeline to do these last bits so we can all benefit from your hard work? I would really love to be able to update my HA install without killing all of my automations. Thank you!

@Siggy101
Copy link

Is there any chance that this new feature will go live in the near future?

This depends on @MadMonkey87, which is required to implement the requested changes. For this reason, the PR is in draft. We can merge the PR only if all is done, including creating a PR for the documentation.

Thanks for the clarification.

@MadMonkey87 Do you have a timeline to do these last bits so we can all benefit from your hard work? I would really love to be able to update my HA install without killing all of my automations. Thank you!

@MadMonkey87 Ciao! Is there any way you can find the time to complete the docs etc to get these really valuable sensors pushed to be merged?
I can imagine that you are very busy but some of us will be extremely grateful to be able to use your hard work.
Thanks!

@jdebetaz
Copy link

jdebetaz commented Oct 4, 2023

Hello,
As it takes time, I made the suggested changes in the code. The only question is whether I should open a new PR on his repo or on this one?

PR documentation will follow in the next few days.

Kind regards 😄

@gjohansson-ST
Copy link
Member

Hello, As it takes time, I made the suggested changes in the code. The only question is whether I should open a new PR on his repo or on this one?

We don't want a new PR on this as we already have it here. You can always open a PR on @MadMonkey87 's branch to contribute from the back and see if he's still active.

@jdebetaz
Copy link

jdebetaz commented Oct 4, 2023

A PR has been made to update the documentation. You'll find it here

@frenck
Copy link
Member

frenck commented Oct 8, 2023

There is still a mypy error that needs to be addressed. Please don't forget to mark this PR ready for review, once you are done 👍

../Frenck

@jdebetaz
Copy link

jdebetaz commented Oct 8, 2023

@frenck As explained above, I opened the PR on @MadMonkey87's repo so as not to have duplicate PRs

@joostlek joostlek marked this pull request as ready for review October 18, 2023 13:53
@joostlek joostlek dismissed stale reviews from edenhaus and gjohansson-ST October 18, 2023 14:01

Changes addressed

@joostlek joostlek merged commit 5f35eec into home-assistant:dev Oct 18, 2023
23 checks passed
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Please address the comments in a new PR. Thanks!

"""Representation of the consumption or temperature of a myStrom switch/plug."""

entity_description: MyStromSwitchSensorEntityDescription
device: MyStromSwitch
Copy link
Member

Choose a reason for hiding this comment

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

We don't need a type annotation and class attribute for device here as there's already a type annotation of the entity device parameter.

@@ -16,7 +16,7 @@
from .const import DOMAIN
from .models import MyStromData

PLATFORMS_SWITCH = [Platform.SWITCH]
PLATFORMS_PLUGS = [Platform.SWITCH, Platform.SENSOR]
Copy link
Member

Choose a reason for hiding this comment

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

Please sort 🔡.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2023
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.

New myStrom integration lacking entities for plugs Extract mystrom switch energy attributes into sensors
9 participants