Skip to content

Add force_update to timer integration#31646

Merged
balloob merged 7 commits intohome-assistant:devfrom
akasma74:patch-7
Apr 3, 2020
Merged

Add force_update to timer integration#31646
balloob merged 7 commits intohome-assistant:devfrom
akasma74:patch-7

Conversation

@akasma74
Copy link
Copy Markdown
Contributor

@akasma74 akasma74 commented Feb 8, 2020

Breaking change

It is not a breaking change as far as I understand.

Proposed change

As per this discussion we need to update last_changed when active timer restarted.
One way to do that is to force HA update the state on each request even if it remains the same.

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

Example entry for configuration.yaml:

# Example configuration.yaml

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

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

As per this discussion we need to update last_changed when active timer restarted.
One way to do that is to force HA update the state on each request even if it remains the same.
More details here - home-assistant/architecture#345
@balloob
Copy link
Copy Markdown
Member

balloob commented Feb 8, 2020

Please add a test.

@akasma74
Copy link
Copy Markdown
Contributor Author

akasma74 commented Feb 8, 2020

@balloob could you point me to the description how to do that - I've never done it.
or tell me who to ask at discord if that's easier ;)

@MartinHjelmare MartinHjelmare changed the title Timer intergation: force_update added Add force_update to timer integration Feb 8, 2020
@Adminiuga
Copy link
Copy Markdown
Contributor

IMO you could tap into https://github.com/home-assistant/home-assistant/blob/e3894d212c8d7b2ab36e33b4911460352625e64a/tests/components/timer/test_init.py#L342-L406

Define another fakelistener and listen for STATE_CHANGED events? Then every time a timer service is called, state_changed listener should get a new result?

@akasma74
Copy link
Copy Markdown
Contributor Author

akasma74 commented Feb 8, 2020

Thanks Alexei, will try my best in finding out how the tests work.

@Adminiuga
Copy link
Copy Markdown
Contributor

you also may want to install pre-commit for git, so it would take care of formatting and sorting imports
see https://developers.home-assistant.io/blog/2019/07/31/black.html

@stale
Copy link
Copy Markdown

stale Bot commented Mar 21, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale Bot added the stale label Mar 21, 2020
@akasma74
Copy link
Copy Markdown
Contributor Author

bump, will deal with it soon

@stale stale Bot removed the stale label Mar 21, 2020
akasma74 added 3 commits April 3, 2020 00:48
make sure state_change event fired every time timer (re)started
Copy link
Copy Markdown
Contributor

@Adminiuga Adminiuga left a comment

Choose a reason for hiding this comment

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

LGTM, once lint is happy

Comment thread tests/components/timer/test_init.py Outdated
akasma74 and others added 3 commits April 3, 2020 01:33
Co-Authored-By: Alexei Chetroi <lexoid@gmail.com>
@balloob balloob merged commit 83cc871 into home-assistant:dev Apr 3, 2020
@lock lock Bot locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants