mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-02-16 10:58:32 -05:00
Handle first update immediately
This commit is contained in:
@@ -52,15 +52,15 @@ public class MessageHandler : IHostedService
|
|||||||
if (_deviceTimers.ContainsKey(newDevice.Name))
|
if (_deviceTimers.ContainsKey(newDevice.Name))
|
||||||
await _deviceTimers[newDevice.Name].DisposeAsync();
|
await _deviceTimers[newDevice.Name].DisposeAsync();
|
||||||
|
|
||||||
if (newDevice.Status)
|
if (!_deviceRepository.ContainsKey(newDevice.Name) || newDevice.Status)
|
||||||
{
|
{
|
||||||
WriteLog($"{arg.ApplicationMessage.Topic}: Status true, handling immediately");
|
WriteLog($"{arg.ApplicationMessage.Topic}: Handling status immediately");
|
||||||
|
|
||||||
await HandleDeviceMessage(newDevice);
|
await HandleDeviceMessage(newDevice);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteLog($"{arg.ApplicationMessage.Topic}: Status false, setting timer");
|
WriteLog($"{arg.ApplicationMessage.Topic}: Setting timer for status");
|
||||||
|
|
||||||
_deviceTimers[newDevice.Name] = new Timer(OnDeviceTimer, newDevice, _deviceDelayTime, Timeout.InfiniteTimeSpan);
|
_deviceTimers[newDevice.Name] = new Timer(OnDeviceTimer, newDevice, _deviceDelayTime, Timeout.InfiniteTimeSpan);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user