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

Double reset_timer set execution time to first time set #1905

Open
JacekJaszczuk opened this issue Dec 28, 2023 · 0 comments
Open

Double reset_timer set execution time to first time set #1905

JacekJaszczuk opened this issue Dec 28, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@JacekJaszczuk
Copy link

What happened?

Hello. When my PIRs triggers on same time, the timer reset to first time set. Example code in code section. In my opinion reset_timer function should always reset timer to delay time.

Version

4.4.2

Installation type

Docker container

Relevant log output

Start timer
(datetime.datetime(2023, 12, 28, 9, 49, 17, 752991), 0, {})
PIR1 trigger
(datetime.datetime(2023, 12, 28, 9, 49, 24, 752991), 0, {}) # Reset OK.
PIR2 trigger
(datetime.datetime(2023, 12, 28, 9, 49, 31, 752991), 0, {}) # Reset OK.
PIR1 and PIR2 trigger on same time
(datetime.datetime(2023, 12, 28, 9, 49, 17, 752991), 0, {}) # Reset to first time here.

Relevant code in the app or config file that caused the issue

import hassapi as hass
from time import sleep

class ResetTest(hass.Hass):
    def light_off(self, kwargs):
        # Off the light code.
        print("Light off!", flush=True)

    def initialize(self):
        # Light off after 30 seconds after PIR1 or PIR2.

        # Start timer:
        print("Start timer", flush=True)
        timer = self.run_in(self.light_off, 30)
        print(self.info_timer(timer), flush=True)

        # After 7 seconds PIR1 triggered, reset timer:
        sleep(7)
        print("PIR1 trigger", flush=True)
        self.reset_timer(timer)
        print(self.info_timer(timer), flush=True)

        # After 7 seconds PIR2 triggered, reset timer:
        sleep(7)
        print("PIR2 trigger", flush=True)
        self.reset_timer(timer)
        print(self.info_timer(timer), flush=True)

        # After 5 seconds PIR1 and PIR2 triggered, double reset and error time:
        sleep(5)
        print("PIR1 and PIR2 trigger on same time", flush=True)
        self.reset_timer(timer)
        self.reset_timer(timer)
        print(self.info_timer(timer), flush=True)

Anything else?

No response

@JacekJaszczuk JacekJaszczuk added the bug Something isn't working label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant