public void OnPresenceStarted(object?sender, HassEventArgs args) { if (_configurator.LuxAboveLimit) { return; } DisposeTimer(args); TurnOnControlEntities(); _app.LogEventHandled(args); }
public void OnHouseModeChanged(object?sender, HassEventArgs args) { if (!IsActive) { _configurator.Configure(_app); // Configure so entities are ready for next time return; } TurnOffControlEntities(); _configurator.Configure(_app); TurnOnControlEntities(); _app.LogEventHandled(args); }
public void OnPresenceStopped(object?sender, HassEventArgs args) { if (IsActive) { _app.LogInformation("{CorrelationId} - Presence Active: {RoomName} no timer set. Active sensors {Sensors}", args.CorrelationId, args.RoomName, string.Join(", ", _configurator.ActivePresenceSensors.Select(p => p.EntityId))); _app.LogEventHandled(args); return; } SetTimer(TimeSpan.FromSeconds(_configurator.TimeoutSeconds), () => { TurnOffControlEntities(); _app.LogEventHandled(args); }, args); }
private void DisposeTimer(HassEventArgs args) { _timer?.Dispose(); _timer = null; _app.LogInformation("{CorrelationId} - Timer disposed: {RoomName}", args.CorrelationId, args.RoomName); }
private void SetTimer(TimeSpan ts, Action action, HassEventArgs args) { DisposeTimer(args); _timer = _app.RunIn(ts, action); _app.LogInformation("{CorrelationId} - Timer set: {RoomName} for {Timeout}", args.CorrelationId, args.RoomName, ts); }
public static void LogEventHandled(this INetDaemonRxApp app, HassEventArgs args) { app.LogInformation("{CorrelationId} - Event Handled: {EventType}", args.CorrelationId, args.EventType); }