mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-14 01:25:38 -05:00
Handle first update immediately
This commit is contained in:
@@ -52,15 +52,15 @@ public class MessageHandler : IHostedService
|
||||
if (_deviceTimers.ContainsKey(newDevice.Name))
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user