mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-21 15:04:24 +01:00
Merge branch 'main' into patch-8
This commit is contained in:
25
README.md
25
README.md
@@ -357,8 +357,7 @@ key | optional | type | default | description
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<details><summary>Possible configuration values for config key</summary>
|
### Possible configuration values for config key
|
||||||
<p>
|
|
||||||
|
|
||||||
key | optional | type | default | description
|
key | optional | type | default | description
|
||||||
-- | -- | -- | -- | --
|
-- | -- | -- | -- | --
|
||||||
@@ -424,8 +423,8 @@ key | optional | type | default | description
|
|||||||
</p>
|
</p>
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details><summary>Possible configuration values for a card in card config</summary>
|
#### Possible configuration values for a card in card config</summary>
|
||||||
<p>
|
|
||||||
|
|
||||||
key | optional | type | default | description
|
key | optional | type | default | description
|
||||||
-- | -- | -- | -- | --
|
-- | -- | -- | -- | --
|
||||||
@@ -436,11 +435,7 @@ key | optional | type | default | description
|
|||||||
`key` | True | string | `None` | Used by navigate items
|
`key` | True | string | `None` | Used by navigate items
|
||||||
|
|
||||||
|
|
||||||
</p>
|
#### Possible configuration values for screensaver config
|
||||||
</details>
|
|
||||||
|
|
||||||
<details><summary>Possible configuration values for screensaver config</summary>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
key | optional | type | default | description
|
key | optional | type | default | description
|
||||||
-- | -- | -- | -- | --
|
-- | -- | -- | -- | --
|
||||||
@@ -484,11 +479,6 @@ It is possible to schedule a brightness change for the screen at specific times.
|
|||||||
value: 0
|
value: 0
|
||||||
```
|
```
|
||||||
|
|
||||||
</p>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details><summary>Overrides and Navigation</summary>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
#### Override Icons or Names
|
#### Override Icons or Names
|
||||||
|
|
||||||
@@ -522,13 +512,6 @@ will allow you to navigate to a cardGrid page with the configured key testKey
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
</p>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
|
|
||||||
</p>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,10 @@ class LuiPagesGen(object):
|
|||||||
text_cur = convert_temperature(we.attributes.temperature, unit)
|
text_cur = convert_temperature(we.attributes.temperature, unit)
|
||||||
|
|
||||||
forecastSkip = self._config._config_screensaver.raw_config.get(f"forecastSkip")+1
|
forecastSkip = self._config._config_screensaver.raw_config.get(f"forecastSkip")+1
|
||||||
# check if the first 2 forecast items are on the same day
|
# check if the difference between the first 2 forecast items is less than 24h
|
||||||
same_day = dp.parse(we.attributes.forecast[0]['datetime']).weekday() == dp.parse(we.attributes.forecast[forecastSkip]['datetime']).weekday()
|
difference = (dp.parse(we.attributes.forecast[forecastSkip]['datetime']) - dp.parse(we.attributes.forecast[0]['datetime']))
|
||||||
|
total_seconds = difference.total_seconds()
|
||||||
|
same_day = total_seconds < 86400
|
||||||
weather_res = ""
|
weather_res = ""
|
||||||
for i in range(1,5):
|
for i in range(1,5):
|
||||||
wOF = self._config._config_screensaver.raw_config.get(f"weatherOverrideForecast{i}")
|
wOF = self._config._config_screensaver.raw_config.get(f"weatherOverrideForecast{i}")
|
||||||
@@ -77,7 +79,7 @@ class LuiPagesGen(object):
|
|||||||
fid = (i-1)*forecastSkip
|
fid = (i-1)*forecastSkip
|
||||||
if len(we.attributes.forecast) >= fid:
|
if len(we.attributes.forecast) >= fid:
|
||||||
up = we.attributes.forecast[fid]['datetime']
|
up = we.attributes.forecast[fid]['datetime']
|
||||||
up = dp.parse(up)
|
up = dp.parse(up).astimezone()
|
||||||
if babel_spec is not None:
|
if babel_spec is not None:
|
||||||
if same_day:
|
if same_day:
|
||||||
up = babel.dates.format_time(up, "H:mm", locale=self._locale)
|
up = babel.dates.format_time(up, "H:mm", locale=self._locale)
|
||||||
|
|||||||
@@ -13,6 +13,20 @@ const On: RGB = { red: 253, green: 216, blue: 53 };
|
|||||||
const BatteryFull: RGB = { red: 96, green: 176, blue: 62 }
|
const BatteryFull: RGB = { red: 96, green: 176, blue: 62 }
|
||||||
const BatteryEmpty: RGB = { red: 179, green: 45, blue: 25 }
|
const BatteryEmpty: RGB = { red: 179, green: 45, blue: 25 }
|
||||||
|
|
||||||
|
|
||||||
|
//----Ability to choose between Accu-Weather Forcast or self-defined values in the screensaver---------------------------------
|
||||||
|
var weatherForecast = true; //true = WheatherForecast 5 Days --- false = Config --> firstScreensaverEntity - fourthScreensaverEntity ...
|
||||||
|
|
||||||
|
//Alexa2-Instanz
|
||||||
|
var alexaInstanz = "alexa2.0"
|
||||||
|
var alexaDevice = "G0XXXXXXXXXXXXXX"; //Primär zu steuendes Device
|
||||||
|
//If alexaSpeakerList is defined, then entries are used, otherwise all relevant devices from the ioBroker Alexa2 adapter
|
||||||
|
const alexaSpeakerList = []; //Example ["Echo Spot Buero","Überall","Gartenhaus","Esszimmer","Heimkino"];
|
||||||
|
|
||||||
|
//Datenpunkte für Nachricht an Screensaver
|
||||||
|
var popupNotifyHeading = "0_userdata.0.NSPanel.1.popupNotifyHeading";
|
||||||
|
var popupNotifyText = "0_userdata.0.NSPanel.1.popupNotifyText";
|
||||||
|
|
||||||
var Wohnen: PageEntities =
|
var Wohnen: PageEntities =
|
||||||
{
|
{
|
||||||
"type": "cardEntities",
|
"type": "cardEntities",
|
||||||
@@ -52,6 +66,13 @@ var Müll: PageEntities =
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var Alexa: PageMedia =
|
||||||
|
{
|
||||||
|
"type": "cardMedia",
|
||||||
|
"heading": "Alexa",
|
||||||
|
"useColor": true,
|
||||||
|
"items": [<PageItem>{ id: "alias.0.NSPanel_1.Alexa.PlayerBuero" }]
|
||||||
|
};
|
||||||
|
|
||||||
var button1Page: PageGrid =
|
var button1Page: PageGrid =
|
||||||
{
|
{
|
||||||
@@ -95,7 +116,7 @@ export const config: Config = {
|
|||||||
defaultOnColor: On,
|
defaultOnColor: On,
|
||||||
defaultColor: Off,
|
defaultColor: Off,
|
||||||
temperatureUnit: "°C",
|
temperatureUnit: "°C",
|
||||||
pages: [Wohnen, Strom, Müll,
|
pages: [Wohnen, Strom, Müll, Alexa,
|
||||||
{
|
{
|
||||||
"type": "cardThermo",
|
"type": "cardThermo",
|
||||||
"heading": "Thermostat",
|
"heading": "Thermostat",
|
||||||
@@ -205,11 +226,14 @@ function GeneratePage(page: Page): void {
|
|||||||
case "cardGrid":
|
case "cardGrid":
|
||||||
SendToPanel(GenerateGridPage(<PageGrid>page));
|
SendToPanel(GenerateGridPage(<PageGrid>page));
|
||||||
break;
|
break;
|
||||||
|
case "cardMedia":
|
||||||
|
SendToPanel(GenerateMediaPage(<PageMedia>page));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function HandleHardwareButton(method: string): void {
|
function HandleHardwareButton(method: string): void {
|
||||||
let page: (PageThermo | PageEntities | PageGrid);
|
let page: (PageThermo | PageMedia | PageEntities | PageGrid);
|
||||||
if (config.button1Page !== null && method == "button1") {
|
if (config.button1Page !== null && method == "button1") {
|
||||||
page = config.button1Page;
|
page = config.button1Page;
|
||||||
pageId = -1;
|
pageId = -1;
|
||||||
@@ -275,6 +299,9 @@ function GeneratePageElements(page: Page): string {
|
|||||||
case "cardThermo":
|
case "cardThermo":
|
||||||
maxItems = 1;
|
maxItems = 1;
|
||||||
break;
|
break;
|
||||||
|
case "cardMedia":
|
||||||
|
maxItems = 1;
|
||||||
|
break;
|
||||||
case "cardEntities":
|
case "cardEntities":
|
||||||
maxItems = 4;
|
maxItems = 4;
|
||||||
break;
|
break;
|
||||||
@@ -517,6 +544,65 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
|
|||||||
return out_msgs
|
return out_msgs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GenerateMediaPage(page: PageMedia): Payload[] {
|
||||||
|
var id = page.items[0].id
|
||||||
|
var out_msgs: Array<Payload> = [];
|
||||||
|
out_msgs.push({ payload: "pageType~cardMedia" });
|
||||||
|
if (existsObject(id)) {
|
||||||
|
let name = getState(id + ".ALBUM").val;
|
||||||
|
let media_icon = Icons.GetIcon("playlist-music");
|
||||||
|
let title = getState(id + ".TITLE").val;
|
||||||
|
let author = getState(id + ".ARTIST").val;
|
||||||
|
let volume = getState(id + ".VOLUME").val;
|
||||||
|
var iconplaypause = Icons.GetIcon("pause"); //pause
|
||||||
|
var onoffbutton = 1374;
|
||||||
|
if (getState(id + ".STATE").val) {
|
||||||
|
onoffbutton = 65535;
|
||||||
|
iconplaypause = Icons.GetIcon("pause"); //pause
|
||||||
|
} else {
|
||||||
|
iconplaypause = Icons.GetIcon("play"); //play
|
||||||
|
}
|
||||||
|
let currentSpeaker = getState(([alexaInstanz,'.Echo-Devices.',alexaDevice,'.Info.name'].join(''))).val;
|
||||||
|
//console.log(id);
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------
|
||||||
|
// nachfolgend alle Alexa-Devices (ist Online / Player- und Commands-Verzeichnis vorhanden) auflisten und verketten
|
||||||
|
// Wenn Konstante alexaSpeakerList mind. einen Eintrag enthält, wird die Konstante verwendet - ansonsten Alle Devices aus dem Alexa Adapter
|
||||||
|
let speakerlist = "";
|
||||||
|
if (alexaSpeakerList.length > 0) {
|
||||||
|
for (let i_index in alexaSpeakerList) {
|
||||||
|
speakerlist = speakerlist + alexaSpeakerList[i_index] + "?";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let i_list = Array.prototype.slice.apply($('[state.id="' + alexaInstanz + '.Echo-Devices.*.Info.name"]'));
|
||||||
|
for (let i_index in i_list) {
|
||||||
|
let i = i_list[i_index];
|
||||||
|
let deviceId = i;
|
||||||
|
deviceId = deviceId.split('.');
|
||||||
|
if (getState(([alexaInstanz,'.Echo-Devices.',deviceId[3],'.online'].join(''))).val &&
|
||||||
|
existsObject(([alexaInstanz,'.Echo-Devices.',deviceId[3],'.Player'].join(''))) &&
|
||||||
|
existsObject(([alexaInstanz,'.Echo-Devices.',deviceId[3],'.Commands'].join('')))) {
|
||||||
|
speakerlist = speakerlist + getState(i).val + "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
speakerlist = speakerlist.substring(0,speakerlist.length-1);
|
||||||
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
out_msgs.push({ payload: "entityUpd~" +
|
||||||
|
name + "~" +
|
||||||
|
id + "~" +
|
||||||
|
id + "~" + //????
|
||||||
|
media_icon + "~" +
|
||||||
|
title + "~" +
|
||||||
|
author + "~" +
|
||||||
|
volume + "~" +
|
||||||
|
iconplaypause + "~" +
|
||||||
|
currentSpeaker + "~" +
|
||||||
|
speakerlist + "~" +
|
||||||
|
onoffbutton});
|
||||||
|
}
|
||||||
|
return out_msgs
|
||||||
|
}
|
||||||
|
|
||||||
function setIfExists(id: string, value: any, type: string | null = null): boolean {
|
function setIfExists(id: string, value: any, type: string | null = null): boolean {
|
||||||
if (type === null) {
|
if (type === null) {
|
||||||
@@ -600,6 +686,37 @@ function HandleButtonEvent(words): void {
|
|||||||
case "brightnessSlider":
|
case "brightnessSlider":
|
||||||
setIfExists(id + ".SET", parseInt(words[4])) ? true : setIfExists(id + ".ACTUAL", parseInt(words[4]));
|
setIfExists(id + ".SET", parseInt(words[4])) ? true : setIfExists(id + ".ACTUAL", parseInt(words[4]));
|
||||||
break;
|
break;
|
||||||
|
case "media-back":
|
||||||
|
setIfExists(id + ".PREV", true)
|
||||||
|
break;
|
||||||
|
case "media-pause":
|
||||||
|
if (getState(id + ".STATE").val === true) {
|
||||||
|
setIfExists(id + ".PAUSE", true)
|
||||||
|
} else {
|
||||||
|
setIfExists(id + ".PLAY", true)
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "media-next":
|
||||||
|
setIfExists(id + ".NEXT", true)
|
||||||
|
break;
|
||||||
|
case "volumeSlider":
|
||||||
|
setIfExists(id + ".VOLUME", parseInt(words[4]))
|
||||||
|
break;
|
||||||
|
case "speaker-sel":
|
||||||
|
let i_list = Array.prototype.slice.apply($('[state.id="' + alexaInstanz + '.Echo-Devices.*.Info.name"]'));
|
||||||
|
for (let i_index in i_list) {
|
||||||
|
let i = i_list[i_index];
|
||||||
|
if ((getState(i).val) === words[4]){
|
||||||
|
let deviceId = i;
|
||||||
|
deviceId = deviceId.split('.');
|
||||||
|
setIfExists(alexaInstanz + ".Echo-Devices." + alexaDevice + ".Commands.textCommand", "Schiebe meine Musik auf " + words[4]);
|
||||||
|
alexaDevice = deviceId[3]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "media-OnOff":
|
||||||
|
setIfExists(id + ".STOP", true)
|
||||||
|
break;
|
||||||
case "tempUpd":
|
case "tempUpd":
|
||||||
setIfExists(id + ".SET", parseInt(words[4]) / 10)
|
setIfExists(id + ".SET", parseInt(words[4]) / 10)
|
||||||
break;
|
break;
|
||||||
@@ -722,10 +839,22 @@ function HandleScreensaverUpdate(): void {
|
|||||||
"weatherUpdate~" + Icons.GetIcon(GetAccuWeatherIcon(parseInt(icon))) + "~"
|
"weatherUpdate~" + Icons.GetIcon(GetAccuWeatherIcon(parseInt(icon))) + "~"
|
||||||
+ temperature + " " + config.temperatureUnit + "~"
|
+ temperature + " " + config.temperatureUnit + "~"
|
||||||
|
|
||||||
|
if (weatherForecast == true) {
|
||||||
|
// Accu-Weather Forecast Tag 2 - Tag 5 -- Wenn weatherForecast = true
|
||||||
|
for (let i = 2; i < 6; i++) {
|
||||||
|
let TempMax = getState("accuweather.0.Summary.TempMax_d" + i).val;
|
||||||
|
let DayOfWeek = getState("accuweather.0.Summary.DayOfWeek_d" + i).val;
|
||||||
|
let WeatherIcon = GetAccuWeatherIcon(getState("accuweather.0.Summary.WeatherIcon_d" + i).val);
|
||||||
|
payloadString += DayOfWeek + "~" + Icons.GetIcon(WeatherIcon) + "~" + TempMax + " °C~";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//In Config definierte Zustände wenn weatherForecast = false
|
||||||
payloadString += GetScreenSaverEntityString(config.firstScreensaverEntity);
|
payloadString += GetScreenSaverEntityString(config.firstScreensaverEntity);
|
||||||
payloadString += GetScreenSaverEntityString(config.secondScreensaverEntity);
|
payloadString += GetScreenSaverEntityString(config.secondScreensaverEntity);
|
||||||
payloadString += GetScreenSaverEntityString(config.thirdScreensaverEntity);
|
payloadString += GetScreenSaverEntityString(config.thirdScreensaverEntity);
|
||||||
payloadString += GetScreenSaverEntityString(config.fourthScreensaverEntity);
|
payloadString += GetScreenSaverEntityString(config.fourthScreensaverEntity);
|
||||||
|
}
|
||||||
|
|
||||||
SendToPanel(<Payload>{ payload: payloadString });
|
SendToPanel(<Payload>{ payload: payloadString });
|
||||||
}
|
}
|
||||||
@@ -869,6 +998,11 @@ interface PageThermo extends Page {
|
|||||||
items: PageItem[],
|
items: PageItem[],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface PageMedia extends Page {
|
||||||
|
type: "cardMedia",
|
||||||
|
items: PageItem[],
|
||||||
|
};
|
||||||
|
|
||||||
type PageItem = {
|
type PageItem = {
|
||||||
id: string,
|
id: string,
|
||||||
icon: (string | undefined),
|
icon: (string | undefined),
|
||||||
@@ -901,9 +1035,9 @@ type Config = {
|
|||||||
defaultColor: RGB,
|
defaultColor: RGB,
|
||||||
defaultOnColor: RGB,
|
defaultOnColor: RGB,
|
||||||
defaultOffColor: RGB,
|
defaultOffColor: RGB,
|
||||||
pages: (PageThermo | PageEntities | PageGrid)[],
|
pages: (PageThermo | PageMedia | PageEntities | PageGrid)[],
|
||||||
button1Page: (PageThermo | PageEntities | PageGrid | null),
|
button1Page: (PageThermo | PageMedia | PageEntities | PageGrid | null),
|
||||||
button2Page: (PageThermo | PageEntities | PageGrid | null),
|
button2Page: (PageThermo | PageMedia | PageEntities | PageGrid | null),
|
||||||
};
|
};
|
||||||
|
|
||||||
type ScreenSaverElement = {
|
type ScreenSaverElement = {
|
||||||
|
|||||||
Reference in New Issue
Block a user