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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a base class for Intellifire entities #65077

Merged
merged 9 commits into from Feb 12, 2022

Conversation

jeeftor
Copy link
Contributor

@jeeftor jeeftor commented Jan 27, 2022

Breaking change

Proposed change

@epenet suggested I make a shared common entity.py class. This is a PR attempting to do this :) I'm not sure I 100% did this the cleanest way possible but hopefully we can fix that during the review process.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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:

@project-bot project-bot bot added this to Needs review in Dev Jan 27, 2022
@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Jan 27, 2022
Copy link
Contributor

@epenet epenet left a comment

Choose a reason for hiding this comment

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

Here are a few comments and suggestions to help you get started.

homeassistant/components/intellifire/binary_sensor.py Outdated Show resolved Hide resolved
homeassistant/components/intellifire/entity.py Outdated Show resolved Hide resolved
homeassistant/components/intellifire/entity.py Outdated Show resolved Hide resolved
homeassistant/components/intellifire/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/intellifire/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/intellifire/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/intellifire/sensor.py Outdated Show resolved Hide resolved
@epenet epenet changed the title Intellifire entity Add a base class for Intellifire entities Jan 27, 2022
jeeftor and others added 2 commits January 27, 2022 13:56
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
@jeeftor
Copy link
Contributor Author

jeeftor commented Jan 27, 2022

Testing the new changes locally now..

They work!

Copy link
Contributor

@epenet epenet left a comment

Choose a reason for hiding this comment

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

A few extra tweaks.

And since you are reordering things already in sensor.py I would reorder them instead to have this order:

  1. dataclasses (IntellifireSensorRequiredKeysMixin/IntellifireSensorEntityDescription)
  2. descriptions (INTELLIFIRE_SENSORS)
  3. private functions (_time_remaining_to_timestamp)
  4. main setup (async_setup_entry)
  5. entity classes (IntellifireSensor)

homeassistant/components/intellifire/entity.py Outdated Show resolved Hide resolved
homeassistant/components/intellifire/entity.py Outdated Show resolved Hide resolved
homeassistant/components/intellifire/binary_sensor.py Outdated Show resolved Hide resolved
Copy link
Contributor

@epenet epenet left a comment

Choose a reason for hiding this comment

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

I forgot to tick "request changes" in the review - please look above for the requested changes.

Dev automation moved this from By Code Owner to Review in progress Jan 28, 2022
jeeftor and others added 3 commits January 31, 2022 20:35
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
@jeeftor
Copy link
Contributor Author

jeeftor commented Feb 1, 2022

A few extra tweaks.

And since you are reordering things already in sensor.py I would reorder them instead to have this order:

  1. dataclasses (IntellifireSensorRequiredKeysMixin/IntellifireSensorEntityDescription)
  2. descriptions (INTELLIFIRE_SENSORS)
  3. private functions (_time_remaining_to_timestamp)
  4. main setup (async_setup_entry)
  5. entity classes (IntellifireSensor)

So I tried to do this BUT!!!!:

image

When I have the _time_remaining_to_timestamp after the INTELLIFIRE_SENSORS I get the warning as seen here...

image

And then when I try to run this code I get the following:

image

As I understand (unlike say C) there is no way to do forward declarations in python ... so I'm sure you can suggest a cool "clean" pythonic way of obtaining this order :)

@epenet
Copy link
Contributor

epenet commented Feb 1, 2022

A few extra tweaks.
And since you are reordering things already in sensor.py I would reorder them instead to have this order:

  1. dataclasses (IntellifireSensorRequiredKeysMixin/IntellifireSensorEntityDescription)
  2. descriptions (INTELLIFIRE_SENSORS)
  3. private functions (_time_remaining_to_timestamp)
  4. main setup (async_setup_entry)
  5. entity classes (IntellifireSensor)

So I tried to do this BUT!!!!:

image

When I have the _time_remaining_to_timestamp after the INTELLIFIRE_SENSORS I get the warning as seen here...

image

And then when I try to run this code I get the following:

image

As I understand (unlike say C) there is no way to do forward declarations in python ... so I'm sure you can suggest a cool "clean" pythonic way of obtaining this order :)

Ah yes you have to invert 2 and 3

@jeeftor
Copy link
Contributor Author

jeeftor commented Feb 1, 2022

Everything should be ordered accordingly.... :)

Dev automation moved this from Review in progress to Reviewer approved Feb 1, 2022
@jeeftor
Copy link
Contributor Author

jeeftor commented Feb 9, 2022

@epenet / @frenck -> I want to make an additional PR based on this codebase. It's not yet merged into dev branch - what approach should I take?

  • Branch off this codebase?
  • Wait for it to be merged back into Dev?
  • Make mods to this branch?

I'm assuming that the best approach is to wait until this code is merged into dev

@bdraco bdraco merged commit d479949 into home-assistant:dev Feb 12, 2022
Dev automation moved this from Reviewer approved to Done Feb 12, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants