v3.5.0.4 Reengineering Media Subscriptions

This commit is contained in:
Armilar
2022-11-01 12:29:07 +01:00
committed by GitHub
parent 7133062f6b
commit ecb96bf20c

View File

@@ -1,20 +1,16 @@
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------
TypeScript v3.5.0.2 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar/@Britzelpuf TypeScript v3.5.0.4 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar/@Sternmiere/@Britzelpuf
- abgestimmt auf TFT 43 / v3.5.0 / BerryDriver 4 / Tasmota 12.2.0 - abgestimmt auf TFT 43 / v3.5.0 / BerryDriver 4 / Tasmota 12.2.0
@joBr99 Projekt: https://github.com/joBr99/nspanel-lovelace-ui/tree/main/ioBroker @joBr99 Projekt: https://github.com/joBr99/nspanel-lovelace-ui/tree/main/ioBroker
NsPanelTs.ts (dieses TypeScript in ioBroker) Stable: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/NsPanelTs.ts NsPanelTs.ts (dieses TypeScript in ioBroker) Stable: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/NsPanelTs.ts
icon_mapping.ts: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/icon_mapping.ts (TypeScript muss in global liegen) icon_mapping.ts: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/icon_mapping.ts (TypeScript muss in global liegen)
ioBroker-Unterstützung: https://forum.iobroker.net/topic/50888/sonoff-nspanel ioBroker-Unterstützung: https://forum.iobroker.net/topic/50888/sonoff-nspanel
WIKI zu diesem Projekt unter: https://github.com/joBr99/nspanel-lovelace-ui/wiki (siehe Sidebar) WIKI zu diesem Projekt unter: https://github.com/joBr99/nspanel-lovelace-ui/wiki (siehe Sidebar)
Icons unter: https://htmlpreview.github.io/?https://github.com/jobr99/Generate-HASP-Fonts/blob/master/cheatsheet.html Icons unter: https://htmlpreview.github.io/?https://github.com/jobr99/Generate-HASP-Fonts/blob/master/cheatsheet.html
******************************************************************************* *******************************************************************************
Achtung Änderung des Sonoff ESP-Temperatursensors Achtung Änderung des Sonoff ESP-Temperatursensors
!!! Bitte "SetOption146 1" in der Tasmota-Console ausführen !!! !!! Bitte "SetOption146 1" in der Tasmota-Console ausführen !!!
******************************************************************************* *******************************************************************************
ReleaseNotes: ReleaseNotes:
Bugfixes und Erweiterungen: Bugfixes und Erweiterungen:
- cardQR (für Gäste WLAN) - cardQR (für Gäste WLAN)
@@ -45,6 +41,7 @@ ReleaseNotes:
- 13.09.2022 - v3.3.1.3 Überarbeitung und BugFix und Refresh Features für cardMedia (Breaking Changes) - 13.09.2022 - v3.3.1.3 Überarbeitung und BugFix und Refresh Features für cardMedia (Breaking Changes)
- 13.09.2022 - v3.3.1.3 Hinzufügen von SpotifyPremium, Sonos und Chromecast (Google home) zur cardMedia-Logik - 13.09.2022 - v3.3.1.3 Hinzufügen von SpotifyPremium, Sonos und Chromecast (Google home) zur cardMedia-Logik
- 15.09.2022 - V3.4.0 - BugFix Dimmode - 15.09.2022 - V3.4.0 - BugFix Dimmode
- 15.09.2022 - v3.4.0 Upgrade TFT 42
- 15.09.2022 - V3.4.0 - Colormode für Screensaver + AutoColor WeatherForecast - 15.09.2022 - V3.4.0 - Colormode für Screensaver + AutoColor WeatherForecast
- 16.09.2022 - v3.4.0.1 Visualisierung der Relay Zustände (MRIcons) im Screensaver + Bugfix Screensaver MRIcon2 - 16.09.2022 - v3.4.0.1 Visualisierung der Relay Zustände (MRIcons) im Screensaver + Bugfix Screensaver MRIcon2
- 17.09.2022 - v3.4.0.2 Bugfix for screensaver icons with scaled colors - 17.09.2022 - v3.4.0.2 Bugfix for screensaver icons with scaled colors
@@ -56,6 +53,7 @@ ReleaseNotes:
- 03.10.2022 - v3.4.0.6 Add cardPower (experimental) - 03.10.2022 - v3.4.0.6 Add cardPower (experimental)
- 05.10.2022 - v3.4.0.6 Add sueezeboxrpc to cardMedia - 05.10.2022 - v3.4.0.6 Add sueezeboxrpc to cardMedia
- 07.10.2022 - v3.4.0.6 Time-configurable change for screensaver icons - 07.10.2022 - v3.4.0.6 Time-configurable change for screensaver icons
- 07.10.2022 - v3.5.0 Upgrade TFT 43
- 07.10.2022 - v3.5.0 Add Backgroundcolor to Pages - 07.10.2022 - v3.5.0 Add Backgroundcolor to Pages
- 08.10.2022 - v3.5.0 Add Tilt-Slider and TILT_Fucntions (Open/Stop/Close) to Blinds/Cover/Shutter popUp - 08.10.2022 - v3.5.0 Add Tilt-Slider and TILT_Fucntions (Open/Stop/Close) to Blinds/Cover/Shutter popUp
- 12.10.2022 - v3.5.0 Add PageNavigation via Datapoint - 12.10.2022 - v3.5.0 Add PageNavigation via Datapoint
@@ -63,14 +61,13 @@ ReleaseNotes:
- 26.10.2022 - v3.5.0.1 Fix Thermostat for tado Support (by Sternmiere) - 26.10.2022 - v3.5.0.1 Fix Thermostat for tado Support (by Sternmiere)
- 27.10.2022 - v3.5.0.1 Add VirtualDevice Gate - 27.10.2022 - v3.5.0.1 Add VirtualDevice Gate
- 27.10.2022 - v3.5.0.2 Applied Boy Scout Rule (Fixed some typos, changed var to let, fixed min/max colorTemp Bug) - 27.10.2022 - v3.5.0.2 Applied Boy Scout Rule (Fixed some typos, changed var to let, fixed min/max colorTemp Bug)
- 27.10.2022 - v3.5.0.3 Fixed Media Play/Pause icon for alexa (and others) devices - 30.10.2022 - v3.5.0.3 Fixed Media Play/Pause icon for alexa (and others) devices
- 31.10.2022 - v3.5.0.4 Reengineering Media Subscriptions
Wenn Rule definiert, dann können die Hardware-Tasten ebenfalls für Seitensteuerung (dann nicht mehr als Relais) genutzt werden Wenn Rule definiert, dann können die Hardware-Tasten ebenfalls für Seitensteuerung (dann nicht mehr als Relais) genutzt werden
Tasmota Konsole: Tasmota Konsole:
Rule2 on Button1#state do Publish %topic%/%prefix%/RESULT {"CustomRecv":"event,button1"} endon on Button2#state do Publish %topic%/%prefix%/RESULT {"CustomRecv":"event,button2"} endon Rule2 on Button1#state do Publish %topic%/%prefix%/RESULT {"CustomRecv":"event,button1"} endon on Button2#state do Publish %topic%/%prefix%/RESULT {"CustomRecv":"event,button2"} endon
Rule2 1 (Rule aktivieren) Rule2 1 (Rule aktivieren)
Rule2 0 (Rule deaktivieren) Rule2 0 (Rule deaktivieren)
Mögliche Seiten-Ansichten: Mögliche Seiten-Ansichten:
screensaver Page - wird nach definiertem Zeitraum (config) mit Dimm-Modus aktiv (Uhrzeit, Datum, Aktuelle Temperatur mit Symbol) screensaver Page - wird nach definiertem Zeitraum (config) mit Dimm-Modus aktiv (Uhrzeit, Datum, Aktuelle Temperatur mit Symbol)
(die 4 kleineren Icons können als Wetter-Vorschau + 4Tage (Symbol + Höchsttemperatur) oder zur Anzeige definierter Infos konfiguriert werden) (die 4 kleineren Icons können als Wetter-Vorschau + 4Tage (Symbol + Höchsttemperatur) oder zur Anzeige definierter Infos konfiguriert werden)
@@ -80,13 +77,11 @@ Mögliche Seiten-Ansichten:
cardMedia Page - Mediaplayer - Ausnahme: Alias sollte mit Alias-Manager automatisch über Alexa-Verzeichnis Player angelegt werden cardMedia Page - Mediaplayer - Ausnahme: Alias sollte mit Alias-Manager automatisch über Alexa-Verzeichnis Player angelegt werden
cardAlarm Page - Alarmseite mit Zustand und Tastenfeld cardAlarm Page - Alarmseite mit Zustand und Tastenfeld
cardPower Page - Energiefluss cardPower Page - Energiefluss
Popup-Pages: Popup-Pages:
popupLight Page - in Abhängigkeit zum gewählten Alias werden "Helligkeit", "Farbtemperatur" und "Farbauswahl" bereitgestellt popupLight Page - in Abhängigkeit zum gewählten Alias werden "Helligkeit", "Farbtemperatur" und "Farbauswahl" bereitgestellt
popupShutter Page - die Shutter-Position (Rollo, Jalousie, Markise, Leinwand, etc.) kann über einen Slider verändert werden. popupShutter Page - die Shutter-Position (Rollo, Jalousie, Markise, Leinwand, etc.) kann über einen Slider verändert werden.
popupNotify Page - Info - Seite mit Headline Text und Buttons - Intern für manuelle Updates / Extern zur Befüllung von Datenpunkten unter 0_userdata popupNotify Page - Info - Seite mit Headline Text und Buttons - Intern für manuelle Updates / Extern zur Befüllung von Datenpunkten unter 0_userdata
screensaver Notify - Über zwei externe Datenpunkte in 0_userdata können "Headline" und "Text" an den Screensaver zur Info gesendet werden screensaver Notify - Über zwei externe Datenpunkte in 0_userdata können "Headline" und "Text" an den Screensaver zur Info gesendet werden
Mögliche Aliase: (Vorzugsweise mit ioBroker-Adapter "Geräte verwalten" konfigurieren, da SET, GET, ACTUAL, etc. verwendet werden) Mögliche Aliase: (Vorzugsweise mit ioBroker-Adapter "Geräte verwalten" konfigurieren, da SET, GET, ACTUAL, etc. verwendet werden)
Info - Werte aus Datenpunkt Info - Werte aus Datenpunkt
Schieberegler - Slider numerische Werte (SET/ACTUAL) Schieberegler - Slider numerische Werte (SET/ACTUAL)
@@ -111,17 +106,14 @@ Mögliche Aliase: (Vorzugsweise mit ioBroker-Adapter "Geräte verwalten" konfigu
Feuchtigkeit - Anzeige von Humidity - Datenpunkten, analog Info Feuchtigkeit - Anzeige von Humidity - Datenpunkten, analog Info
Medien - Steuerung von Alexa - Über Alias-Manager im Verzeichnis Player automatisch anlegen (Geräte-Manager funktioniert nicht) Medien - Steuerung von Alexa - Über Alias-Manager im Verzeichnis Player automatisch anlegen (Geräte-Manager funktioniert nicht)
Wettervorhersage - Aktuelle Außen-Temperatur (Temp) und aktuelles AccuWeather-Icon (Icon) für Screensaver Wettervorhersage - Aktuelle Außen-Temperatur (Temp) und aktuelles AccuWeather-Icon (Icon) für Screensaver
Interne Sonoff-Sensoren (über Tasmota): Interne Sonoff-Sensoren (über Tasmota):
ESP-Temperatur - wird in 0_userdata.0. abgelegt, kann als Alias importiert werden --> SetOption146 1 ESP-Temperatur - wird in 0_userdata.0. abgelegt, kann als Alias importiert werden --> SetOption146 1
Temperatur - Raumtemperatur - wird in 0_userdata.0. abgelegt, kann als Alias importiert werden Temperatur - Raumtemperatur - wird in 0_userdata.0. abgelegt, kann als Alias importiert werden
(!!! Achtung: der interne Sonoff-Sensor liefert keine exakten Daten, da das NSPanel-Board und der ESP selbst Hitze produzieren !!! (!!! Achtung: der interne Sonoff-Sensor liefert keine exakten Daten, da das NSPanel-Board und der ESP selbst Hitze produzieren !!!
ggf. Offset einplanen oder besser einen externen Sensor über Zigbee etc. verwenden) ggf. Offset einplanen oder besser einen externen Sensor über Zigbee etc. verwenden)
Timestamp - wird in 0_userdata.0. Zeitpunkt der letzten Sensorübertragung Timestamp - wird in 0_userdata.0. Zeitpunkt der letzten Sensorübertragung
Tasmota-Status0 - (zyklische Ausführung) Tasmota-Status0 - (zyklische Ausführung)
liefert relevanten Tasmota-Informationen und kann bei Bedarf in "function get_tasmota_status0()" erweitert werden. Daten werden in 0_userdata.0. abgelegt liefert relevanten Tasmota-Informationen und kann bei Bedarf in "function get_tasmota_status0()" erweitert werden. Daten werden in 0_userdata.0. abgelegt
Erforderliche Adapter: Erforderliche Adapter:
AccuWeather: - Bei Nutzung der Wetterfunktionen (und zur Icon-Konvertierung) im Screensaver AccuWeather: - Bei Nutzung der Wetterfunktionen (und zur Icon-Konvertierung) im Screensaver
Alexa2: - Bei Nutzung der dynamischen SpeakerList in der cardMedia Alexa2: - Bei Nutzung der dynamischen SpeakerList in der cardMedia
@@ -129,14 +121,11 @@ Erforderliche Adapter:
Alias-Manager - !!! ausschließlich für MEDIA-Alias Alias-Manager - !!! ausschließlich für MEDIA-Alias
MQTT-Adapter - Für Kommunikation zwischen Skript und Tasmota MQTT-Adapter - Für Kommunikation zwischen Skript und Tasmota
JavaScript-Adapter JavaScript-Adapter
Upgrades in Konsole: Upgrades in Konsole:
Tasmota BerryDriver : Backlog UpdateDriverVersion https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be; Restart 1 Tasmota BerryDriver : Backlog UpdateDriverVersion https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be; Restart 1
TFT EU STABLE Version : FlashNextion http://nspanel.pky.eu/lovelace-ui/github/nspanel-v3.5.0.tft TFT EU STABLE Version : FlashNextion http://nspanel.pky.eu/lovelace-ui/github/nspanel-v3.5.0.tft
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
*/ */
import { config } from './NsPanelTs'
let Icons = new IconsSelector(); let Icons = new IconsSelector();
let timeoutSlider: any; let timeoutSlider: any;
let manually_Update = false; let manually_Update = false;
@@ -232,10 +221,47 @@ let vwIconColor = [];
//-- ENDE der Variablen für Seitengestaltung -- Aliase erforderlich ------------------ //-- ENDE der Variablen für Seitengestaltung -- Aliase erforderlich ------------------
export const config: Config = {
panelRecvTopic: 'mqtt.0.SmartHome.NSPanel_1.tele.RESULT', // anpassen
panelSendTopic: 'mqtt.0.SmartHome.NSPanel_1.cmnd.CustomSend', // anpassen
firstScreensaverEntity: { ScreensaverEntity: 'accuweather.0.Hourly.h0.PrecipitationProbability', ScreensaverEntityIcon: 'weather-pouring', ScreensaverEntityText: 'Regen', ScreensaverEntityUnitText: '%', ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 100} },
secondScreensaverEntity: { ScreensaverEntity: 'accuweather.0.Current.WindSpeed', ScreensaverEntityIcon: 'weather-windy', ScreensaverEntityText: "Wind", ScreensaverEntityUnitText: 'km/h', ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 120} },
thirdScreensaverEntity: { ScreensaverEntity: 'accuweather.0.Current.UVIndex', ScreensaverEntityIcon: 'solar-power', ScreensaverEntityText: 'UV', ScreensaverEntityUnitText: '', ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 9} },
fourthScreensaverEntity: { ScreensaverEntity: 'accuweather.0.Current.RelativeHumidity', ScreensaverEntityIcon: 'water-percent', ScreensaverEntityText: 'Luft', ScreensaverEntityUnitText: '%', ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 100, 'val_best': 65} },
alternativeScreensaverLayout: false,
autoWeatherColorScreensaverLayout: true,
mrIcon1ScreensaverEntity: { ScreensaverEntity: null, ScreensaverEntityIcon: 'light-switch', ScreensaverEntityOnColor: On, ScreensaverEntityOffColor: Off },
mrIcon2ScreensaverEntity: { ScreensaverEntity: null, ScreensaverEntityIcon: 'lightbulb', ScreensaverEntityOnColor: On, ScreensaverEntityOffColor: Off },
timeoutScreensaver: 20,
dimmode: 20,
active: 100, //Standard-Brightness TFT
screenSaverDoubleClick: true,
locale: 'de-DE', // en-US, de-DE, nl-NL, da-DK, es-ES, fr-FR, it-IT, ru-RU, etc.
timeFormat: '%H:%M', // currently not used
dateFormat: '%A, %d. %B %Y', // currently not used
weatherEntity: 'alias.0.Wetter', // Dieser Alias muss erstellt werden, damit die 4 kleineren Icons (Wetter oder DP) angezeigt werden können
defaultOffColor: Off,
defaultOnColor: On,
defaultColor: Off,
defaultBackgroundColor: Black, //New Parameter
temperatureUnit: '°C',
pages: [
],
subPages: [
],
button1Page: null, //Beispiel-Seite auf Button 1, wenn Rule2 definiert - Wenn nicht definiert --> button1Page: null,
button2Page: null //Beispiel-Seite auf Button 2, wenn Rule2 definiert - Wenn nicht definiert --> button1Page: null,
};
// _________________________________ Ab hier keine Konfiguration mehr _____________________________________ // _________________________________ Ab hier keine Konfiguration mehr _____________________________________
const request = require('request'); const request = require('request');
let useMediaEvents: boolean = false;
let timeoutMedia: any;
//---------------------Begin PageNavi //---------------------Begin PageNavi
async function InitPageNavi() { async function InitPageNavi() {
try { try {
@@ -295,8 +321,8 @@ async function InitWeatherForecast() {
try { try {
//----Möglichkeit, im Screensaver zwischen Accu-Weather Forecast oder selbstdefinierten Werten zu wählen--------------------------------- //----Möglichkeit, im Screensaver zwischen Accu-Weather Forecast oder selbstdefinierten Werten zu wählen---------------------------------
if (existsState(NSPanel_Path + "ScreensaverInfo.weatherForecast") == false || if (existsState(NSPanel_Path + "ScreensaverInfo.weatherForecast") == false ||
existsState(NSPanel_Path + "ScreensaverInfo.weatherForecastTimer") == false || existsState(NSPanel_Path + "ScreensaverInfo.weatherForecastTimer") == false ||
existsState(NSPanel_Path + "ScreensaverInfo.entityChangeTime") == false) { existsState(NSPanel_Path + "ScreensaverInfo.entityChangeTime") == false) {
await createStateAsync(NSPanel_Path + "ScreensaverInfo.weatherForecast", true, { type: 'boolean' }); await createStateAsync(NSPanel_Path + "ScreensaverInfo.weatherForecast", true, { type: 'boolean' });
await createStateAsync(NSPanel_Path + "ScreensaverInfo.weatherForecastTimer", true, { type: 'boolean' }); await createStateAsync(NSPanel_Path + "ScreensaverInfo.weatherForecastTimer", true, { type: 'boolean' });
await createStateAsync(NSPanel_Path + "ScreensaverInfo.entityChangeTime", 60, { type: 'number' }); await createStateAsync(NSPanel_Path + "ScreensaverInfo.entityChangeTime", 60, { type: 'number' });
@@ -437,22 +463,22 @@ async function InitPopupNotify() {
let v_popupNotifyIcon = (getState(popupNotifyIcon).val != null) ? getState(popupNotifyIcon).val : 'alert' let v_popupNotifyIcon = (getState(popupNotifyIcon).val != null) ? getState(popupNotifyIcon).val : 'alert'
notification = 'entityUpdateDetail' + '~' notification = 'entityUpdateDetail' + '~'
+ getState(popupNotifyInternalName).val + '~' + getState(popupNotifyInternalName).val + '~'
+ getState(popupNotifyHeading).val + '~' + getState(popupNotifyHeading).val + '~'
+ v_popupNotifyHeadingColor + '~' + v_popupNotifyHeadingColor + '~'
+ getState(popupNotifyButton1Text).val + '~' + getState(popupNotifyButton1Text).val + '~'
+ v_popupNotifyButton1TextColor + '~' + v_popupNotifyButton1TextColor + '~'
+ getState(popupNotifyButton2Text).val + '~' + getState(popupNotifyButton2Text).val + '~'
+ v_popupNotifyButton2TextColor + '~' + v_popupNotifyButton2TextColor + '~'
+ getState(popupNotifyText).val + '~' + getState(popupNotifyText).val + '~'
+ v_popupNotifyTextColor + '~' + v_popupNotifyTextColor + '~'
+ getState(popupNotifySleepTimeout).val; + getState(popupNotifySleepTimeout).val;
if (getState(popupNotifyLayout).val == 2) { if (getState(popupNotifyLayout).val == 2) {
notification = notification + '~' notification = notification + '~'
+ v_popupNotifyFontIdText + '~' + v_popupNotifyFontIdText + '~'
+ Icons.GetIcon(v_popupNotifyIcon) + '~' + Icons.GetIcon(v_popupNotifyIcon) + '~'
+ v_popupNotifyIconColor; + v_popupNotifyIconColor;
} }
setIfExists(config.panelSendTopic, 'pageType~popupNotify'); setIfExists(config.panelSendTopic, 'pageType~popupNotify');
@@ -1103,6 +1129,7 @@ function HandleMessage(typ: string, method: string, page: number, words: Array<s
GeneratePage(config.pages[0]); GeneratePage(config.pages[0]);
break; break;
case 'sleepReached': case 'sleepReached':
useMediaEvents = false;
screensaverEnabled = true; screensaverEnabled = true;
if (pageId < 0) if (pageId < 0)
pageId = 0; pageId = 0;
@@ -1172,6 +1199,7 @@ function GeneratePage(page: Page): void {
SendToPanel(GenerateGridPage(<PageGrid>page)); SendToPanel(GenerateGridPage(<PageGrid>page));
break; break;
case 'cardMedia': case 'cardMedia':
useMediaEvents = true;
SendToPanel(GenerateMediaPage(<PageMedia>page)); SendToPanel(GenerateMediaPage(<PageMedia>page));
break; break;
case 'cardAlarm': case 'cardAlarm':
@@ -1710,11 +1738,11 @@ function GetIconColor(pageItem: PageItem, value: (boolean | number), useColors:
value = value < minValue ? minValue : value; value = value < minValue ? minValue : value;
return rgb_dec565( return rgb_dec565(
Interpolate( Interpolate(
pageItem.offColor !== undefined ? pageItem.offColor : config.defaultOffColor, pageItem.offColor !== undefined ? pageItem.offColor : config.defaultOffColor,
pageItem.onColor !== undefined ? pageItem.onColor : config.defaultOnColor, pageItem.onColor !== undefined ? pageItem.onColor : config.defaultOnColor,
scale(value, minValue, maxValue, 0, 1) scale(value, minValue, maxValue, 0, 1)
) )
); );
} }
@@ -1872,9 +1900,9 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
for (let i_index in i_list) { for (let i_index in i_list) {
let thermostatState = i_list[i_index].split('.'); let thermostatState = i_list[i_index].split('.');
if ( if (
thermostatState[thermostatState.length - 1] != 'SET' && thermostatState[thermostatState.length - 1] != 'SET' &&
thermostatState[thermostatState.length - 1] != 'ACTUAL' && thermostatState[thermostatState.length - 1] != 'ACTUAL' &&
thermostatState[thermostatState.length - 1] != 'MODE' thermostatState[thermostatState.length - 1] != 'MODE'
) { ) {
i++; i++;
@@ -2023,22 +2051,22 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpd~' payload: 'entityUpd~'
+ name + '~' // Heading + name + '~' // Heading
+ GetNavigationString(pageId) + '~' // Page Navigation + GetNavigationString(pageId) + '~' // Page Navigation
+ id + '~' // internalNameEntity + id + '~' // internalNameEntity
+ currentTemp + config.temperatureUnit + '~' // Ist-Temperatur (String) + currentTemp + config.temperatureUnit + '~' // Ist-Temperatur (String)
+ destTemp + '~' // Soll-Temperatur (numerisch ohne Komma) + destTemp + '~' // Soll-Temperatur (numerisch ohne Komma)
+ statusStr + '~' // Mode + statusStr + '~' // Mode
+ minTemp + '~' // Thermostat Min-Temperatur + minTemp + '~' // Thermostat Min-Temperatur
+ maxTemp + '~' // Thermostat Max-Temperatur + maxTemp + '~' // Thermostat Max-Temperatur
+ stepTemp + '~' // Schritte für Soll (5°C) + stepTemp + '~' // Schritte für Soll (5°C)
+ icon_res // Icons Status + icon_res // Icons Status
+ findLocale('thermostat', 'Currently') + '~' // Bezeichner vor Aktueller Raumtemperatur + findLocale('thermostat', 'Currently') + '~' // Bezeichner vor Aktueller Raumtemperatur
+ findLocale('thermostat', 'State') + '~' // Bezeichner vor + findLocale('thermostat', 'State') + '~' // Bezeichner vor
+ '~' // Bezeichner vor HVAC -- Gibt es nicht mehr + '~' // Bezeichner vor HVAC -- Gibt es nicht mehr
+ config.temperatureUnit + '~' // Bezeichner hinter Solltemp + config.temperatureUnit + '~' // Bezeichner hinter Solltemp
+ '' + '~' // iconTemperature dstTempTwoTempMode + '' + '~' // iconTemperature dstTempTwoTempMode
+ '' // dstTempTwoTempMode + '' // dstTempTwoTempMode
}); });
} }
@@ -2052,12 +2080,40 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
} }
} }
function unsubscribeMediaSubscriptions(): void {
for (let i = 0; i < config.pages.length; i++) {
if (config.pages[i].type == 'cardMedia') {
let mediaID = config.pages[i].items[0].id;
unsubscribe(mediaID + '.STATE')
unsubscribe(mediaID + '.ARTIST')
unsubscribe(mediaID + '.TITLE')
unsubscribe(mediaID + '.ALBUM')
unsubscribe(mediaID + '.VOLUME')
}
}
}
function subscribeMediaSubscriptions(id: string): void {
on({id: [].concat([id + '.STATE']).concat([id + '.VOLUME']).concat([id + '.ARTIST']).concat([id + '.ALBUM']).concat([id + '.TITLE']), change: "ne"}, async function () {
(function () { if (timeoutMedia) { clearTimeout(timeoutMedia); timeoutMedia = null; } })();
timeoutMedia = setTimeout(async function () {
if (useMediaEvents) {
GeneratePage(activePage);
}
},25)
});
}
function GenerateMediaPage(page: PageMedia): Payload[] { function GenerateMediaPage(page: PageMedia): Payload[] {
try { try {
let id = page.items[0].id let id = page.items[0].id
let out_msgs: Array<Payload> = []; let out_msgs: Array<Payload> = [];
unsubscribeMediaSubscriptions();
subscribeMediaSubscriptions(id);
out_msgs.push({ payload: 'pageType~cardMedia' }); out_msgs.push({ payload: 'pageType~cardMedia' });
if (existsObject(id)) { if (existsObject(id)) {
let name = getState(id + '.ALBUM').val; let name = getState(id + '.ALBUM').val;
@@ -2077,11 +2133,9 @@ function GenerateMediaPage(page: PageMedia): Payload[] {
name = getState(id + '.CONTEXT_DESCRIPTION').val; name = getState(id + '.CONTEXT_DESCRIPTION').val;
let nameLength = name.length; let nameLength = name.length;
if (name.substring(0,9) == 'Playlist:') { if (name.substring(0,9) == 'Playlist:') {
let nameLength = name.length; name = name.slice(10, 26) + '...';
name = name.slice(10, nameLength);
} else if (name.substring(0,6) == 'Album:') { } else if (name.substring(0,6) == 'Album:') {
let nameLength = name.length; name = name.slice(7, 23) + '...';
name = name.slice(10, nameLength);
} else if (name.substring(0,6) == 'Track') { } else if (name.substring(0,6) == 'Track') {
name = 'Spotify-Premium'; name = 'Spotify-Premium';
} }
@@ -2144,11 +2198,13 @@ function GenerateMediaPage(page: PageMedia): Payload[] {
} }
//Ausnahme für squeezebox, da State = Power //Ausnahme für squeezebox, da State = Power
if (getState(id + '.PAUSE').val === false && v2Adapter == 'squeezeboxrpc') { if (v2Adapter == 'squeezeboxrpc') {
onoffbutton = 65535; if (getState(id + '.PAUSE').val === false) {
iconplaypause = Icons.GetIcon('pause'); //pause onoffbutton = 65535;
} else { iconplaypause = Icons.GetIcon('pause'); //pause
iconplaypause = Icons.GetIcon('play'); //play } else {
iconplaypause = Icons.GetIcon('play'); //play
}
} }
if (Debug) { if (Debug) {
@@ -2183,8 +2239,8 @@ function GenerateMediaPage(page: PageMedia): Payload[] {
let deviceId = i; let deviceId = i;
deviceId = deviceId.split('.'); deviceId = deviceId.split('.');
if (getState(([page.items[0].adapterPlayerInstance, 'Echo-Devices.', deviceId[3], '.online'].join(''))).val && if (getState(([page.items[0].adapterPlayerInstance, 'Echo-Devices.', deviceId[3], '.online'].join(''))).val &&
existsObject(([page.items[0].adapterPlayerInstance, 'Echo-Devices.', deviceId[3], '.Player'].join(''))) && existsObject(([page.items[0].adapterPlayerInstance, 'Echo-Devices.', deviceId[3], '.Player'].join(''))) &&
existsObject(([page.items[0].adapterPlayerInstance, 'Echo-Devices.', deviceId[3], '.Commands'].join('')))) { existsObject(([page.items[0].adapterPlayerInstance, 'Echo-Devices.', deviceId[3], '.Commands'].join('')))) {
speakerList = speakerList + getState(i).val + '?'; speakerList = speakerList + getState(i).val + '?';
} }
} }
@@ -2194,18 +2250,18 @@ function GenerateMediaPage(page: PageMedia): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpd~' + //entityUpd payload: 'entityUpd~' + //entityUpd
name + '~' + //heading name + '~' + //heading
GetNavigationString(pageId) + '~' + //navigation GetNavigationString(pageId) + '~' + //navigation
id + '~' + //internalNameEntiy id + '~' + //internalNameEntiy
media_icon + '~' + //icon media_icon + '~' + //icon
title + '~' + //title title + '~' + //title
author + '~' + //author author + '~' + //author
volume + '~' + //volume volume + '~' + //volume
iconplaypause + '~' + //playpauseicon iconplaypause + '~' + //playpauseicon
currentSpeaker + '~' + //currentSpeaker currentSpeaker + '~' + //currentSpeaker
speakerList + '~' + //speakerList-seperated-by-? speakerList + '~' + //speakerList-seperated-by-?
onoffbutton onoffbutton //On/Off Button Color
}); //On/Off Button Color });
} }
if (Debug) { if (Debug) {
console.log(out_msgs); console.log(out_msgs);
@@ -2297,20 +2353,20 @@ function GenerateAlarmPage(page: PageAlarm): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpd~' + //entityUpd~* payload: 'entityUpd~' + //entityUpd~*
id + '~' + //internalNameEntity*~* id + '~' + //internalNameEntity*~*
GetNavigationString(pageId) + '~' + //navigation*~* --> hiddenCards GetNavigationString(pageId) + '~' + //navigation*~* --> hiddenCards
arm1 + '~' + //arm1*~* arm1 + '~' + //arm1*~*
arm1ActionName + '~' + //arm1ActionName*~* arm1ActionName + '~' + //arm1ActionName*~*
arm2 + '~' + //arm2*~* arm2 + '~' + //arm2*~*
arm2ActionName + '~' + //arm2ActionName*~* arm2ActionName + '~' + //arm2ActionName*~*
arm3 + '~' + //arm3*~* arm3 + '~' + //arm3*~*
arm3ActionName + '~' + //arm3ActionName*~* arm3ActionName + '~' + //arm3ActionName*~*
arm4 + '~' + //arm4*~* arm4 + '~' + //arm4*~*
arm4ActionName + '~' + //arm4ActionName*~* arm4ActionName + '~' + //arm4ActionName*~*
icon + '~' + //icon*~* icon + '~' + //icon*~*
iconcolor + '~' + //iconcolor*~* iconcolor + '~' + //iconcolor*~*
numpadStatus + '~' + //numpadStatus*~* numpadStatus + '~' + //numpadStatus*~*
flashing flashing
}); //flashing* }); //flashing*
if (Debug) { if (Debug) {
@@ -2369,21 +2425,21 @@ function GenerateQRPage(page: PageQR): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpd~' + //entityUpd payload: 'entityUpd~' + //entityUpd
heading + '~' + //heading heading + '~' + //heading
GetNavigationString(pageId) + '~' + //navigation GetNavigationString(pageId) + '~' + //navigation
textQR + '~' + //textQR textQR + '~' + //textQR
type1 + '~' + //type type1 + '~' + //type
internalName1 + '~' + //internalName internalName1 + '~' + //internalName
iconId1 + '~' + //iconId iconId1 + '~' + //iconId
65535 + '~' + //iconColor 65535 + '~' + //iconColor
displayName1 + '~' + //displayName displayName1 + '~' + //displayName
optionalValue1 + '~' + //optionalValue optionalValue1 + '~' + //optionalValue
type2 + '~' + //type type2 + '~' + //type
internalName2 + '~' + //internalName internalName2 + '~' + //internalName
iconId2 + '~' + //iconId iconId2 + '~' + //iconId
65535 + '~' + //iconColor 65535 + '~' + //iconColor
displayName2 + '~' + //displayName displayName2 + '~' + //displayName
optionalValue2 optionalValue2
}); //optionalValue }); //optionalValue
//entityUpd,heading,navigation,textQR[,type,internalName,iconId,displayName,optionalValue]x2 //entityUpd,heading,navigation,textQR[,type,internalName,iconId,displayName,optionalValue]x2
@@ -2415,7 +2471,7 @@ function GeneratePowerPage(page: PagePower): Payload[] {
let heading = 'cardPower Example'; let heading = 'cardPower Example';
if (demoMode != true) { if (demoMode != true) {
let o = getObject(id) let o = getObject(id)
heading = page.heading !== undefined ? page.heading : o.common.name.de heading = page.heading !== undefined ? page.heading : o.common.name.de
} }
const obj = JSON.parse((getState(page.items[0].id + '.ACTUAL').val)); const obj = JSON.parse((getState(page.items[0].id + '.ACTUAL').val));
@@ -2453,12 +2509,12 @@ function GeneratePowerPage(page: PagePower): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpd~' + //entityUpd~* payload: 'entityUpd~' + //entityUpd~*
heading + '~' + //internalNameEntity*~* heading + '~' + //internalNameEntity*~*
GetNavigationString(pageId) + '~' + //navigation*~* GetNavigationString(pageId) + '~' + //navigation*~*
rgb_dec565(array_icon_color[0]) + '~' + // icon_color~ Mitte rgb_dec565(array_icon_color[0]) + '~' + // icon_color~ Mitte
Icons.GetIcon(array_icon[0]) + '~' + // icon~ Mitte Icons.GetIcon(array_icon[0]) + '~' + // icon~ Mitte
array_powerspeed[0] + '~' + // entity.state~ Mitte array_powerspeed[0] + '~' + // entity.state~ Mitte
power_string power_string
}); });
return out_msgs return out_msgs
@@ -2752,11 +2808,6 @@ function HandleButtonEvent(words): void {
break; break;
case 'media-back': case 'media-back':
setIfExists(id + '.PREV', true); setIfExists(id + '.PREV', true);
on({id: id + '.TITLE', change: "ne"}, async function () {
setTimeout(function(){
GeneratePage(activePage);
},25)
});
break; break;
case 'media-pause': case 'media-pause':
let pageItemTemp = findPageItem(id); let pageItemTemp = findPageItem(id);
@@ -2777,24 +2828,9 @@ function HandleButtonEvent(words): void {
setIfExists(id + '.PLAY', true); setIfExists(id + '.PLAY', true);
} }
} }
on({id: id + '.STATE', val: true}, async function () {
on({id: [].concat([id + '.ARTIST']).concat([id + '.ALBUM']).concat([id + '.TITLE']), change: "ne"}, async function () {
setTimeout(function(){
GeneratePage(activePage);
},25)
});
});
on({id: id + '.STATE', val: false}, async function () {
GeneratePage(activePage);
});
break; break;
case 'media-next': case 'media-next':
setIfExists(id + '.NEXT', true); setIfExists(id + '.NEXT', true);
on({id: id + '.TITLE', change: "ne"}, async function () {
setTimeout(function(){
GeneratePage(activePage);
},25)
});
break; break;
case 'volumeSlider': case 'volumeSlider':
setIfExists(id + '.VOLUME', parseInt(words[4])) setIfExists(id + '.VOLUME', parseInt(words[4]))
@@ -3055,16 +3091,16 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpdateDetail' + '~' // entityUpdateDetail payload: 'entityUpdateDetail' + '~' // entityUpdateDetail
+ id + '~' + id + '~'
+ icon + '~' // iconId + icon + '~' // iconId
+ iconColor + '~' // iconColor + iconColor + '~' // iconColor
+ switchVal + '~' // buttonState + switchVal + '~' // buttonState
+ 'disable' + '~' // sliderBrightnessPos + 'disable' + '~' // sliderBrightnessPos
+ 'disable' + '~' // sliderColorTempPos + 'disable' + '~' // sliderColorTempPos
+ 'disable' + '~' // colorMode + 'disable' + '~' // colorMode
+ '' + '~' // Color-Bezeichnung + '' + '~' // Color-Bezeichnung
+ findLocale('lights', 'Temperature') + '~' // Temperature-Bezeichnung + findLocale('lights', 'Temperature') + '~' // Temperature-Bezeichnung
+ findLocale('lights', 'Brightness') + findLocale('lights', 'Brightness')
}); // Brightness-Bezeichnung }); // Brightness-Bezeichnung
} }
@@ -3104,16 +3140,16 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpdateDetail' + '~' //entityUpdateDetail payload: 'entityUpdateDetail' + '~' //entityUpdateDetail
+ id + '~' + id + '~'
+ icon + '~' //iconId + icon + '~' //iconId
+ iconColor + '~' //iconColor + iconColor + '~' //iconColor
+ switchVal + '~' //buttonState + switchVal + '~' //buttonState
+ brightness + '~' //sliderBrightnessPos + brightness + '~' //sliderBrightnessPos
+ 'disable' + '~' //sliderColorTempPos + 'disable' + '~' //sliderColorTempPos
+ 'disable' + '~' //colorMod + 'disable' + '~' //colorMod
+ '' + '~' //Color-Bezeichnung + '' + '~' //Color-Bezeichnung
+ findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung + findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung
+ findLocale('lights', 'Brightness') + findLocale('lights', 'Brightness')
}); //Brightness-Bezeichnung }); //Brightness-Bezeichnung
console.log('light.' + id) console.log('light.' + id)
@@ -3173,16 +3209,16 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpdateDetail' + '~' //entityUpdateDetail payload: 'entityUpdateDetail' + '~' //entityUpdateDetail
+ id + '~' + id + '~'
+ icon + '~' //iconId + icon + '~' //iconId
+ iconColor + '~' //iconColor + iconColor + '~' //iconColor
+ switchVal + '~' //buttonState + switchVal + '~' //buttonState
+ brightness + '~' //sliderBrightnessPos + brightness + '~' //sliderBrightnessPos
+ colorTemp + '~' //sliderColorTempPos + colorTemp + '~' //sliderColorTempPos
+ colorMode + '~' //colorMode (if hue-alias without hue-datapoint, then disable) + colorMode + '~' //colorMode (if hue-alias without hue-datapoint, then disable)
+ 'Color' + '~' //Color-Bezeichnung + 'Color' + '~' //Color-Bezeichnung
+ findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung + findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung
+ findLocale('lights', 'Brightness') + findLocale('lights', 'Brightness')
}); //Brightness-Bezeichnung }); //Brightness-Bezeichnung
} }
@@ -3238,16 +3274,16 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpdateDetail' + '~' //entityUpdateDetail payload: 'entityUpdateDetail' + '~' //entityUpdateDetail
+ id + '~' + id + '~'
+ icon + '~' //iconId + icon + '~' //iconId
+ iconColor + '~' //iconColor + iconColor + '~' //iconColor
+ switchVal + '~' //buttonState + switchVal + '~' //buttonState
+ brightness + '~' //sliderBrightnessPos + brightness + '~' //sliderBrightnessPos
+ colorTemp + '~' //sliderColorTempPos + colorTemp + '~' //sliderColorTempPos
+ colorMode + '~' //colorMode (if hue-alias without hue-datapoint, then disable) + colorMode + '~' //colorMode (if hue-alias without hue-datapoint, then disable)
+ 'Color' + '~' //Color-Bezeichnung + 'Color' + '~' //Color-Bezeichnung
+ findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung + findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung
+ findLocale('lights', 'Brightness') + findLocale('lights', 'Brightness')
}); //Brightness-Bezeichnung }); //Brightness-Bezeichnung
} }
@@ -3307,16 +3343,16 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpdateDetail' + '~' //entityUpdateDetail payload: 'entityUpdateDetail' + '~' //entityUpdateDetail
+ id + '~' + id + '~'
+ icon + '~' //iconId + icon + '~' //iconId
+ iconColor + '~' //iconColor + iconColor + '~' //iconColor
+ switchVal + '~' //buttonState + switchVal + '~' //buttonState
+ brightness + '~' //sliderBrightnessPos + brightness + '~' //sliderBrightnessPos
+ colorTemp + '~' //sliderColorTempPos + colorTemp + '~' //sliderColorTempPos
+ colorMode + '~' //colorMode (if hue-alias without hue-datapoint, then disable) + colorMode + '~' //colorMode (if hue-alias without hue-datapoint, then disable)
+ 'Color' + '~' //Color-Bezeichnung + 'Color' + '~' //Color-Bezeichnung
+ findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung + findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung
+ findLocale('lights', 'Brightness') + findLocale('lights', 'Brightness')
}); //Brightness-Bezeichnung }); //Brightness-Bezeichnung
} }
@@ -3364,16 +3400,16 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpdateDetail' + '~' //entityUpdateDetail payload: 'entityUpdateDetail' + '~' //entityUpdateDetail
+ id + '~' + id + '~'
+ icon + '~' //iconId + icon + '~' //iconId
+ iconColor + '~' //iconColor + iconColor + '~' //iconColor
+ switchVal + '~' //buttonState + switchVal + '~' //buttonState
+ brightness + '~' //sliderBrightnessPos + brightness + '~' //sliderBrightnessPos
+ colorTemp + '~' //sliderColorTempPos + colorTemp + '~' //sliderColorTempPos
+ colorMode + '~' //colorMode (if hue-alias without hue-datapoint, then disable) + colorMode + '~' //colorMode (if hue-alias without hue-datapoint, then disable)
+ 'Color' + '~' //Color-Bezeichnung + 'Color' + '~' //Color-Bezeichnung
+ findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung + findLocale('lights', 'Temperature') + '~' //Temperature-Bezeichnung
+ findLocale('lights', 'Brightness') + findLocale('lights', 'Brightness')
}); //Brightness-Bezeichnung }); //Brightness-Bezeichnung
} }
} }
@@ -3430,25 +3466,25 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] {
out_msgs.push({ out_msgs.push({
payload: 'entityUpdateDetail' + '~' //entityUpdateDetail payload: 'entityUpdateDetail' + '~' //entityUpdateDetail
+ id + '~' //entity_id + id + '~' //entity_id
+ val + '~' //Shutterposition + val + '~' //Shutterposition
+ textSecondRow + '~' //pos_status 2.line + textSecondRow + '~' //pos_status 2.line
+ findLocale('blinds', 'Position') + '~' //pos_translation + findLocale('blinds', 'Position') + '~' //pos_translation
+ icon_id + '~' //{icon_id}~ + icon_id + '~' //{icon_id}~
+ icon_up + '~' //{icon_up}~ + icon_up + '~' //{icon_up}~
+ icon_stop + '~' //{icon_stop}~ + icon_stop + '~' //{icon_stop}~
+ icon_down + '~' //{icon_down}~ + icon_down + '~' //{icon_down}~
+ icon_up_status + '~' //{icon_up_status}~ + icon_up_status + '~' //{icon_up_status}~
+ icon_stop_status + '~' //{icon_stop_status}~ + icon_stop_status + '~' //{icon_stop_status}~
+ icon_down_status + '~' //{icon_down_status}~ + icon_down_status + '~' //{icon_down_status}~
+ textTilt + '~' //{textTilt}~ + textTilt + '~' //{textTilt}~
+ iconTiltLeft + '~' //{iconTiltLeft}~ + iconTiltLeft + '~' //{iconTiltLeft}~
+ iconTiltStop + '~' //{iconTiltStop}~ + iconTiltStop + '~' //{iconTiltStop}~
+ iconTiltRight + '~' //{iconTiltRight}~ + iconTiltRight + '~' //{iconTiltRight}~
+ iconTiltLeftStatus + '~' //{iconTiltLeftStatus}~ + iconTiltLeftStatus + '~' //{iconTiltLeftStatus}~
+ iconTiltStopStatus + '~' //{iconTiltStopStatus}~ + iconTiltStopStatus + '~' //{iconTiltStopStatus}~
+ iconTiltRightStatus + '~' //{iconTiltRightStatus}~ + iconTiltRightStatus + '~' //{iconTiltRightStatus}~
+ tilt_pos //{tilt_pos}") + tilt_pos //{tilt_pos}")
}); });
} }
} }
@@ -3492,16 +3528,16 @@ function HandleScreensaverUpdate(): void {
let icon = getState(config.weatherEntity + '.ICON').val; let icon = getState(config.weatherEntity + '.ICON').val;
let temperature = let temperature =
existsState(config.weatherEntity + '.ACTUAL') ? getState(config.weatherEntity + '.ACTUAL').val : existsState(config.weatherEntity + '.ACTUAL') ? getState(config.weatherEntity + '.ACTUAL').val :
existsState(config.weatherEntity + '.TEMP') ? getState(config.weatherEntity + '.TEMP').val : 'null'; existsState(config.weatherEntity + '.TEMP') ? getState(config.weatherEntity + '.TEMP').val : 'null';
if (config.alternativeScreensaverLayout) { if (config.alternativeScreensaverLayout) {
temperature = parseInt(Math.round(temperature).toFixed()); temperature = parseInt(Math.round(temperature).toFixed());
} }
let payloadString = let payloadString =
'weatherUpdate~' + Icons.GetIcon(GetAccuWeatherIcon(parseInt(icon))) + '~' 'weatherUpdate~' + Icons.GetIcon(GetAccuWeatherIcon(parseInt(icon))) + '~'
+ temperature + ' ' + config.temperatureUnit + '~'; + temperature + ' ' + config.temperatureUnit + '~';
vwIconColor[0] = GetAccuWeatherIconColor(parseInt(icon)); vwIconColor[0] = GetAccuWeatherIconColor(parseInt(icon));
if (Debug) { if (Debug) {
@@ -3558,7 +3594,7 @@ function HandleScreensaverUpdate(): void {
} else if (valueScale > iconvalbest || iconvalbest != iconvalmin) { } else if (valueScale > iconvalbest || iconvalbest != iconvalmin) {
valueScale = scale(valueScale,iconvalbest, iconvalmax, 10, 0) valueScale = scale(valueScale,iconvalbest, iconvalmax, 10, 0)
} else { } else {
valueScale = scale(valueScale,iconvalmin, iconvalmax, 10, 0) valueScale = scale(valueScale,iconvalmin, iconvalmax, 10, 0)
} }
} }
let valueScaletemp = (Math.round(valueScale)).toFixed(); let valueScaletemp = (Math.round(valueScale)).toFixed();
@@ -3632,7 +3668,7 @@ function HandleScreensaverUpdate(): void {
} else if (valueScale > iconvalbest || iconvalbest != iconvalmin) { } else if (valueScale > iconvalbest || iconvalbest != iconvalmin) {
valueScale = scale(valueScale,iconvalbest, iconvalmax, 10, 0) valueScale = scale(valueScale,iconvalbest, iconvalmax, 10, 0)
} else { } else {
valueScale = scale(valueScale,iconvalmin, iconvalmax, 10, 0) valueScale = scale(valueScale,iconvalmin, iconvalmax, 10, 0)
} }
} }
let valueScaletemp = (Math.round(valueScale)).toFixed(); let valueScaletemp = (Math.round(valueScale)).toFixed();
@@ -3706,7 +3742,7 @@ function HandleScreensaverUpdate(): void {
} else if (valueScale > iconvalbest || iconvalbest != iconvalmin) { } else if (valueScale > iconvalbest || iconvalbest != iconvalmin) {
valueScale = scale(valueScale,iconvalbest, iconvalmax, 10, 0) valueScale = scale(valueScale,iconvalbest, iconvalmax, 10, 0)
} else { } else {
valueScale = scale(valueScale,iconvalmin, iconvalmax, 10, 0) valueScale = scale(valueScale,iconvalmin, iconvalmax, 10, 0)
} }
} }
let valueScaletemp = (Math.round(valueScale)).toFixed(); let valueScaletemp = (Math.round(valueScale)).toFixed();
@@ -3780,7 +3816,7 @@ function HandleScreensaverUpdate(): void {
} else if (valueScale > iconvalbest || iconvalbest != iconvalmin) { } else if (valueScale > iconvalbest || iconvalbest != iconvalmin) {
valueScale = scale(valueScale,iconvalbest, iconvalmax, 10, 0) valueScale = scale(valueScale,iconvalbest, iconvalmax, 10, 0)
} else { } else {
valueScale = scale(valueScale,iconvalmin, iconvalmax, 10, 0) valueScale = scale(valueScale,iconvalmin, iconvalmax, 10, 0)
} }
} }
let valueScaletemp = (Math.round(valueScale)).toFixed(); let valueScaletemp = (Math.round(valueScale)).toFixed();
@@ -3917,29 +3953,29 @@ function HandleScreensaverColors(): void {
} }
let payloadString = 'color' + '~' + let payloadString = 'color' + '~' +
rgb_dec565(scbackground) + '~' + //background rgb_dec565(scbackground) + '~' + //background
rgb_dec565(sctime) + '~' + //time rgb_dec565(sctime) + '~' + //time
rgb_dec565(sctimeAMPM) + '~' + //timeAMPM~ rgb_dec565(sctimeAMPM) + '~' + //timeAMPM~
rgb_dec565(scdate) + '~' + //date~ rgb_dec565(scdate) + '~' + //date~
vwIcon[0] + '~' + //tMainIcon~ rgb_dec565(sctMainIcon) vwIcon[0] + '~' + //tMainIcon~ rgb_dec565(sctMainIcon)
rgb_dec565(sctMainText) + '~' + //tMainText~ rgb_dec565(sctMainText) + '~' + //tMainText~
rgb_dec565(sctForecast1) + '~' + //tForecast1~ rgb_dec565(sctForecast1) + '~' + //tForecast1~
rgb_dec565(sctForecast2) + '~' + //tForecast2~ rgb_dec565(sctForecast2) + '~' + //tForecast2~
rgb_dec565(sctForecast3) + '~' + //tForecast3~ rgb_dec565(sctForecast3) + '~' + //tForecast3~
rgb_dec565(sctForecast4) + '~' + //tForecast4~ rgb_dec565(sctForecast4) + '~' + //tForecast4~
vwIcon[1] + '~' + //tF1Icon~ rgb_dec565(sctF1Icon) vwIcon[1] + '~' + //tF1Icon~ rgb_dec565(sctF1Icon)
vwIcon[2] + '~' + //tF2Icon~ rgb_dec565(sctF2Icon) vwIcon[2] + '~' + //tF2Icon~ rgb_dec565(sctF2Icon)
vwIcon[3] + '~' + //tF3Icon~ rgb_dec565(sctF3Icon) vwIcon[3] + '~' + //tF3Icon~ rgb_dec565(sctF3Icon)
vwIcon[4] + '~' + //tF4Icon~ rgb_dec565(sctF4Icon) vwIcon[4] + '~' + //tF4Icon~ rgb_dec565(sctF4Icon)
rgb_dec565(sctForecast1Val) + '~' + //tForecast1Val~ rgb_dec565(sctForecast1Val) + '~' + //tForecast1Val~
rgb_dec565(sctForecast2Val) + '~' + //tForecast2Val~ rgb_dec565(sctForecast2Val) + '~' + //tForecast2Val~
rgb_dec565(sctForecast3Val) + '~' + //tForecast3Val~ rgb_dec565(sctForecast3Val) + '~' + //tForecast3Val~
rgb_dec565(sctForecast4Val) + '~' + //tForecast4Val~ rgb_dec565(sctForecast4Val) + '~' + //tForecast4Val~
rgb_dec565(scbar) + '~' + //bar~ rgb_dec565(scbar) + '~' + //bar~
rgb_dec565(sctMainIconAlt) + '~' + //tMainIconAlt rgb_dec565(sctMainIconAlt) + '~' + //tMainIconAlt
rgb_dec565(sctMainTextAlt) + '~' + //tMainTextAlt rgb_dec565(sctMainTextAlt) + '~' + //tMainTextAlt
rgb_dec565(sctTimeAdd); rgb_dec565(sctTimeAdd);
//true; //true;
SendToPanel(<Payload>{ payload: payloadString }); SendToPanel(<Payload>{ payload: payloadString });
} catch (err) { } catch (err) {
@@ -4192,11 +4228,11 @@ function hsv2rgb(hue: number, saturation: number, value: number) {
let chroma = value * saturation; let chroma = value * saturation;
let x = chroma * (1 - Math.abs((hue % 2) - 1)); let x = chroma * (1 - Math.abs((hue % 2) - 1));
let rgb = hue <= 1 ? [chroma, x, 0] : let rgb = hue <= 1 ? [chroma, x, 0] :
hue <= 2 ? [x, chroma, 0] : hue <= 2 ? [x, chroma, 0] :
hue <= 3 ? [0, chroma, x] : hue <= 3 ? [0, chroma, x] :
hue <= 4 ? [0, x, chroma] : hue <= 4 ? [0, x, chroma] :
hue <= 5 ? [x, 0, chroma] : hue <= 5 ? [x, 0, chroma] :
[chroma, 0, x]; [chroma, 0, x];
return rgb.map(v => (v + value - chroma) * 255); return rgb.map(v => (v + value - chroma) * 255);
} }
@@ -4248,22 +4284,22 @@ function pos_to_color(x: number, y: number): RGB {
function rgb_to_cie(red, green, blue) function rgb_to_cie(red, green, blue)
{ {
//Apply a gamma correction to the RGB values, which makes the color more vivid and more the like the color displayed on the screen of your device //Apply a gamma correction to the RGB values, which makes the color more vivid and more the like the color displayed on the screen of your device
let vred = (red > 0.04045) ? Math.pow((red + 0.055) / (1.0 + 0.055), 2.4) : (red / 12.92); let vred = (red > 0.04045) ? Math.pow((red + 0.055) / (1.0 + 0.055), 2.4) : (red / 12.92);
let vgreen = (green > 0.04045) ? Math.pow((green + 0.055) / (1.0 + 0.055), 2.4) : (green / 12.92); let vgreen = (green > 0.04045) ? Math.pow((green + 0.055) / (1.0 + 0.055), 2.4) : (green / 12.92);
let vblue = (blue > 0.04045) ? Math.pow((blue + 0.055) / (1.0 + 0.055), 2.4) : (blue / 12.92); let vblue = (blue > 0.04045) ? Math.pow((blue + 0.055) / (1.0 + 0.055), 2.4) : (blue / 12.92);
//RGB values to XYZ using the Wide RGB D65 conversion formula //RGB values to XYZ using the Wide RGB D65 conversion formula
let X = vred * 0.664511 + vgreen * 0.154324 + vblue * 0.162028; let X = vred * 0.664511 + vgreen * 0.154324 + vblue * 0.162028;
let Y = vred * 0.283881 + vgreen * 0.668433 + vblue * 0.047685; let Y = vred * 0.283881 + vgreen * 0.668433 + vblue * 0.047685;
let Z = vred * 0.000088 + vgreen * 0.072310 + vblue * 0.986039; let Z = vred * 0.000088 + vgreen * 0.072310 + vblue * 0.986039;
//Calculate the xy values from the XYZ values //Calculate the xy values from the XYZ values
let ciex = (X / (X + Y + Z)).toFixed(4); let ciex = (X / (X + Y + Z)).toFixed(4);
let ciey = (Y / (X + Y + Z)).toFixed(4); let ciey = (Y / (X + Y + Z)).toFixed(4);
let cie = "[" + ciex + "," + ciey + "]" let cie = "[" + ciex + "," + ciey + "]"
return cie; return cie;
} }
function spotifyGetDeviceID(vDeviceString) { function spotifyGetDeviceID(vDeviceString) {