From e4ca6e74a6009e82b5315169537f35c57a192b77 Mon Sep 17 00:00:00 2001 From: Joshua Rich Date: Sat, 21 Dec 2024 13:49:59 +1000 Subject: [PATCH] feat(linux/power): :sparkles: power state and screen lock sensor requests will be retried on response failure - retry power/screen lock state sensor updates on response failure. this will hopefully ensure the power state is properly updated after coming back up from suspend state and detecting the state change before the network is back up --- .vscode/settings.json | 3 ++- internal/linux/power/powerState.go | 3 +++ internal/linux/power/screenLock.go | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 54dbf9d22..9797380a3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,7 +33,8 @@ "linux/cpu", "linux/system", "linux/mem", - "BREAKING_CHANGES" + "BREAKING_CHANGES", + "linux/power" ], "go.testFlags": ["-v"], "[markdown]": { diff --git a/internal/linux/power/powerState.go b/internal/linux/power/powerState.go index af4a4f1e5..9eda3287c 100644 --- a/internal/linux/power/powerState.go +++ b/internal/linux/power/powerState.go @@ -42,6 +42,9 @@ func newPowerState(name powerSignal, value any) sensor.Entity { Attributes: map[string]any{ "data_source": linux.DataSrcDbus, }, + RequestMetadata: sensor.RequestMetadata{ + RetryRequest: true, + }, }, } } diff --git a/internal/linux/power/screenLock.go b/internal/linux/power/screenLock.go index ee85efef8..9b6a9e7dc 100644 --- a/internal/linux/power/screenLock.go +++ b/internal/linux/power/screenLock.go @@ -37,6 +37,9 @@ func newScreenlockSensor(value bool) sensor.Entity { Attributes: map[string]any{ "data_source": linux.DataSrcDbus, }, + RequestMetadata: sensor.RequestMetadata{ + RetryRequest: true, + }, }, } }