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 TypeError #21734

Merged
merged 5 commits into from Mar 9, 2019

Conversation

Projects
None yet
6 participants
@wburgers
Copy link
Contributor

wburgers commented Mar 7, 2019

  • convert a timedelta to int
  • make sure the test inputs real timestamps

Description:

Apparently it is not possible to divide by a timedelta.
Convert the timedelta to an int.

Related issue (if applicable): fixes #21730

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.
timediff is of type timedelta. Divide by timedelta does not work.
- convert a timedelta to int
- make sure the test inputs real timestamps
@amelchio
Copy link
Member

amelchio left a comment

So I was right to find that timestamp fishy 😃

This change looks good but I wonder how it worked for you before?

@wburgers

This comment has been minimized.

Copy link
Contributor Author

wburgers commented Mar 7, 2019

Yeah, you were right indeed.
I didn't include the change as a custom component in my own home assistant.
I thought that the test would be adequate.
Unfortunately it wasn't.
Glad it was not in 0.89.0...

@amelchio

This comment has been minimized.

Copy link
Member

amelchio commented Mar 7, 2019

Okay. "The code change is tested and works locally." means that you have actually used it so please don't mark that if you didn't.

@amelchio

This comment has been minimized.

Copy link
Member

amelchio commented Mar 7, 2019

Again, this looks good but please confirm that you have now actually used the updated code IRL?

@wburgers

This comment has been minimized.

Copy link
Contributor Author

wburgers commented Mar 7, 2019

Sorry I thought tested locally meant tested with tox.
I'm not at home now. Will test it later.

@amelchio

This comment has been minimized.

Copy link
Member

amelchio commented Mar 7, 2019

No problem, I see how that can be confusing. Let's test first and merge later so we don't make another mistake :-)

Convert the total_seconds to decimal and round the result
readings are of type Decimal, so fix test to reflect that
@wburgers

This comment has been minimized.

Copy link
Contributor Author

wburgers commented Mar 8, 2019

I have tested this locally now by using dsmr.py as a custom_component.
I also fixed the test to reflect the actual input (decimal instead of float for the reading values).

Graph from the day before yesterday
image
Graph of this morning
image

As you can see, the values are much higher now (which corresponds with my previous finding #20097)

@dgomes

This comment has been minimized.

Copy link
Member

dgomes commented Mar 9, 2019

Can we get a better description in the PR title before merging ? (it helps end-users going through the changes list)

@dgomes

dgomes approved these changes Mar 9, 2019

@amelchio amelchio changed the title timediff is of type timedelta. Divide by timedelta does not work. Fix TypeError Mar 9, 2019

@amelchio amelchio merged commit 458548d into home-assistant:dev Mar 9, 2019

4 checks passed

Hound No violations found. Woof!
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.03%) to 92.725%
Details

@wafflebot wafflebot bot removed the in progress label Mar 9, 2019

mxworm added a commit to mxworm/home-assistant that referenced this pull request Mar 9, 2019

Merge branch 'dev' into current
* dev: (82 commits)
  Add ClearPass Policy Manger device tracker (home-assistant#21673)
  Better cloud check (home-assistant#21875)
  Bump quirks for ZHA and handle resulting battery % change (home-assistant#21869)
  Only commit if need. (home-assistant#21848)
  Fix authorization header in cors (home-assistant#21662)
  Introduce Entity.async_write_ha_state() to not miss state transition (home-assistant#21590)
  Fix TypeError (home-assistant#21734)
  Update honeywell.py to read current humidity for US Thermostats (home-assistant#21728)
  Override http.trusted_networks by auth_provider.trusted_networks (home-assistant#21844)
  mobile_app improvements (home-assistant#21607)
  Fixed a misspelling in a docstring (home-assistant#21846)
  Update dependencies to receive data on webhook callbacks (home-assistant#21838)
  Fix config entry exception in Ambient PWS (home-assistant#21836)
  Updated to pyeconet 0.0.10 (home-assistant#21837)
  fix empty TOPIC_BASE issue (home-assistant#21740)
  Synology sensor quick return if attr is null (home-assistant#21709)
  Add support for Cisco Mobility Express (home-assistant#21531)
  Log if aiohttp hits error during IndieAuth (home-assistant#21780)
  Resolve auth_store loading race condition (home-assistant#21794)
  Load logger and system_log components as soon as possible (home-assistant#21799)
  ...

@wburgers wburgers deleted the wburgers:fix-dsmr branch Mar 10, 2019

@balloob balloob referenced this pull request Mar 20, 2019

Merged

0.90.0 #22216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.