private async Task ProcessOverrides(BaseTile tile) { switch (tile) { // Calendars use a special API that isn't (might not be?) exposed via the WebSocket API. case CalendarTile ct: // Required because for some reason, the calendar API is not available // via the "inside" supervisor API, only the "external" fully-qualified // API endpoint. var config = await ConfigStore.GetConfigAsync(); var calClient = new CalendarClient(new Uri(!string.IsNullOrWhiteSpace(config.Settings?.OverrideAssetUri) ? config.Settings.OverrideAssetUri : config.Settings.BaseUri), config.Settings.AccessToken); var state = await StatesClient.GetState(ct.EntityId); var calItems = await calClient.GetEvents(ct.EntityId); await Clients.Caller.SendCalendarInfo(ct, state, calItems); break; // Date and time are rendered server-side to verify server connection, and to enforce timezone and date format selection. case DateTile dt: var date = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(dt.TimeZoneId)); await Clients.Caller.SendDateTime(dt, date.ToString(dt.DateFormatString ?? "dddd MMMM d"), date.ToString(dt.TimeFormatString ?? "h:mm tt")); break; } }
private async Task ProcessOverrides(BaseTile tile) { switch (tile) { // Calendars use a special API that isn't (might not be?) exposed via the WebSocket API. case CalendarTile ct: await Clients.Caller.SendCalendarInfo(ct, await StatesClient.GetState(ct.EntityId), await CalendarClient.GetEvents(ct.EntityId)); break; // Date and time are rendered server-side to verify server connection, and to enforce timezone and date format selection. case DateTile dt: var date = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(dt.TimeZoneId)); await Clients.Caller.SendDateTime(dt, date.ToString(dt.DateFormatString ?? "dddd MMMM d"), date.ToString(dt.TimeFormatString ?? "h:mm tt")); break; } }
private async Task ProcessOverrides(BaseTile tile) { switch (tile) { // Calendars use a special API that isn't (might not be?) exposed via the WebSocket API. case CalendarTile ct: await Clients.All.SendCalendarInfo(ct, await StatesClient.GetState(ct.EntityId), await CalendarClient.GetEvents(ct.EntityId)); break; // Date and time are rendered server-side to verify server connection, and to enforce timezone and date format selection. case DateTile dt: var date = !string.IsNullOrWhiteSpace(dt.TimeZoneId) ? TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(dt.TimeZoneId)) : DateTime.Now; await Clients.All.SendDateTime(dt, date.ToString(dt.DateFormatString ?? "dddd MMMM d"), date.ToString(dt.TimeFormatString ?? "h:mm tt")); break; } }