mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Increase uptime deviation for Shelly (#142996)
* Increase uptime deviation for Shelly * fix test * make troubleshooting easy * change deviation interval * increase deviation to 1m
This commit is contained in:
parent
e240707b32
commit
74c4553bb0
@ -209,7 +209,7 @@ KELVIN_MIN_VALUE_COLOR: Final = 3000
|
|||||||
BLOCK_WRONG_SLEEP_PERIOD = 21600
|
BLOCK_WRONG_SLEEP_PERIOD = 21600
|
||||||
BLOCK_EXPECTED_SLEEP_PERIOD = 43200
|
BLOCK_EXPECTED_SLEEP_PERIOD = 43200
|
||||||
|
|
||||||
UPTIME_DEVIATION: Final = 5
|
UPTIME_DEVIATION: Final = 60
|
||||||
|
|
||||||
# Time to wait before reloading entry upon device config change
|
# Time to wait before reloading entry upon device config change
|
||||||
ENTRY_RELOAD_COOLDOWN = 60
|
ENTRY_RELOAD_COOLDOWN = 60
|
||||||
|
@ -200,8 +200,18 @@ def get_device_uptime(uptime: float, last_uptime: datetime | None) -> datetime:
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
not last_uptime
|
not last_uptime
|
||||||
or abs((delta_uptime - last_uptime).total_seconds()) > UPTIME_DEVIATION
|
or (diff := abs((delta_uptime - last_uptime).total_seconds()))
|
||||||
|
> UPTIME_DEVIATION
|
||||||
):
|
):
|
||||||
|
if last_uptime:
|
||||||
|
LOGGER.debug(
|
||||||
|
"Time deviation %s > %s: uptime=%s, last_uptime=%s, delta_uptime=%s",
|
||||||
|
diff,
|
||||||
|
UPTIME_DEVIATION,
|
||||||
|
uptime,
|
||||||
|
last_uptime,
|
||||||
|
delta_uptime,
|
||||||
|
)
|
||||||
return delta_uptime
|
return delta_uptime
|
||||||
|
|
||||||
return last_uptime
|
return last_uptime
|
||||||
|
@ -21,6 +21,7 @@ from homeassistant.components.shelly.const import (
|
|||||||
GEN1_RELEASE_URL,
|
GEN1_RELEASE_URL,
|
||||||
GEN2_BETA_RELEASE_URL,
|
GEN2_BETA_RELEASE_URL,
|
||||||
GEN2_RELEASE_URL,
|
GEN2_RELEASE_URL,
|
||||||
|
UPTIME_DEVIATION,
|
||||||
)
|
)
|
||||||
from homeassistant.components.shelly.utils import (
|
from homeassistant.components.shelly.utils import (
|
||||||
get_block_channel_name,
|
get_block_channel_name,
|
||||||
@ -188,8 +189,9 @@ async def test_get_device_uptime() -> None:
|
|||||||
) == dt_util.as_utc(dt_util.parse_datetime("2019-01-10 18:42:00+00:00"))
|
) == dt_util.as_utc(dt_util.parse_datetime("2019-01-10 18:42:00+00:00"))
|
||||||
|
|
||||||
assert get_device_uptime(
|
assert get_device_uptime(
|
||||||
50, dt_util.as_utc(dt_util.parse_datetime("2019-01-10 18:42:00+00:00"))
|
55 - UPTIME_DEVIATION,
|
||||||
) == dt_util.as_utc(dt_util.parse_datetime("2019-01-10 18:42:10+00:00"))
|
dt_util.as_utc(dt_util.parse_datetime("2019-01-10 18:42:00+00:00")),
|
||||||
|
) == dt_util.as_utc(dt_util.parse_datetime("2019-01-10 18:43:05+00:00"))
|
||||||
|
|
||||||
|
|
||||||
async def test_get_block_input_triggers(
|
async def test_get_block_input_triggers(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user