iobroker.nspanel-lovelace-ui
Version:
NsPanel Lovelace UI is a Firmware for the nextion screen inside of NSPanel in the Design of Lovelace UI Design.
1,724 lines (1,717 loc) • 139 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var text_exports = {};
__export(text_exports, {
textTemplates: () => textTemplates
});
module.exports = __toCommonJS(text_exports);
var import_Color = require("../const/Color");
const textTemplates = {
"text.clock": {
role: "text",
dpInit: "",
adapter: "",
type: "text",
data: {
entity2: {
value: {
type: "internal",
dp: "///time"
},
dateFormat: {
type: "const",
constVal: { local: "de", format: { hour: "2-digit", minute: "2-digit" } }
}
},
icon: {
true: {
value: { type: "const", constVal: "clock-outline" },
color: { type: "const", constVal: import_Color.Color.foreground },
text: {
value: {
type: "internal",
dp: "///time"
},
dateFormat: {
type: "const",
constVal: { local: "de", format: { hour: "2-digit", minute: "2-digit" } }
},
textSize: { type: "const", constVal: 1 }
}
}
}
}
},
"text.window.isOpen": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "window-open-variant" },
color: { type: "const", constVal: import_Color.Color.open }
},
false: {
value: { type: "const", constVal: "window-closed-variant" },
color: { type: "const", constVal: import_Color.Color.close }
}
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: ["sensor.window", "sensor.open"],
dp: ""
}
},
text: {
true: { type: "const", constVal: "window" },
false: void 0
},
text1: {
true: { type: "const", constVal: "opened" },
false: { type: "const", constVal: "closed" }
}
}
},
"text.window.isClose": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "window-closed-variant" },
color: { type: "const", constVal: import_Color.Color.close }
},
false: {
value: { type: "const", constVal: "window-open-variant" },
color: { type: "const", constVal: import_Color.Color.open }
}
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: ["sensor.window", "sensor.open"],
dp: "",
read: "return !val"
}
},
text: {
true: { type: "const", constVal: "window" },
false: void 0
},
text1: {
true: { type: "const", constVal: "closed" },
false: { type: "const", constVal: "opened" }
}
}
},
"text.temperature": {
role: "",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "temperature-celsius" },
text: {
value: {
type: "triggered",
mode: "auto",
role: "value.temperature",
dp: "",
read: "return Math.round(val*10)/10"
}
},
color: { type: "const", constVal: import_Color.Color.Red }
},
false: {
value: { type: "const", constVal: "temperature-celsius" },
color: { type: "const", constVal: import_Color.Color.Blue }
},
scale: { type: "const", constVal: { val_min: 40, val_max: 0, val_best: 25, mode: "quadriGradAnchor" } }
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: "value.temperature",
dp: ""
}
},
text: {
true: { type: "const", constVal: "Temperature" },
false: void 0
},
text1: {
true: {
type: "triggered",
mode: "auto",
role: "value.temperature",
dp: "",
read: "return Math.round(parseFloat(val)*10)/10"
},
false: void 0
}
}
},
"text.battery": {
/**
* entity1 enthält den Füllstand
* entity2 ebenfalls
* entity3 ist true für laden und false für entladen. default ist false entity3 wird nicht automatisch gefunden
*/
role: "battery",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: {
type: "triggered",
mode: "auto",
role: "value.battery",
dp: "",
read: `const v = Math.round(val / 10)
switch (v) {
case 0:
return 'battery-charging-outline';
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
return 'battery-charging-' + v + '0';
case 10:
default:
return 'battery-charging';}`
},
text: {
value: {
type: "triggered",
mode: "auto",
role: "value.battery",
dp: ""
},
unit: {
type: "const",
constVal: "%"
},
textSize: { type: "const", constVal: 2 }
},
color: {
type: "const",
constVal: import_Color.Color.Green
}
},
false: {
value: {
type: "triggered",
mode: "auto",
role: "value.battery",
dp: "",
read: `const v = Math.round(val / 10)
switch (v) {
case 0:
return 'battery-outline';
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
return 'battery-' + v + '0';
case 10:
default:
return 'battery';}`
},
color: {
type: "const",
constVal: import_Color.Color.Red
}
},
scale: { type: "const", constVal: { val_min: 10, val_max: 50, log10: "max" } }
},
entity1: {
value: {
type: "state",
mode: "auto",
role: "value.battery",
dp: ""
}
},
text: {
true: { type: "const", constVal: "Battery" },
false: void 0
},
entity2: {
value: {
type: "triggered",
mode: "auto",
role: "value.battery",
dp: ""
},
unit: { type: "const", constVal: "%" }
}
}
},
"text.battery.bydhvs": {
/**
* entity1 enthält den Füllstand
* entity2 ebenfalls
* entity3 ist true für laden und false für entladen. default ist false entity3 wird nicht automatisch gefunden
*/
template: "text.battery",
role: "battery",
adapter: "bydhvs",
type: "text",
dpInit: "/bydhvs\\.#\xB0^\xB0#\\./",
data: {
icon: {
true: {
value: {
type: "triggered",
mode: "auto",
role: "value.battery",
dp: "",
regexp: /\.State\.SOC$/,
read: `const v = Math.round(val / 10)
switch (v) {
case 0:
return 'battery-charging-outline';
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
return 'battery-charging-' + v + '0';
case 10:
default:
return 'battery-charging';}`
},
text: {
value: {
type: "triggered",
mode: "auto",
role: "value.battery",
dp: "",
regexp: /\.State\.SOC$/
},
unit: {
type: "const",
constVal: "%"
},
textSize: { type: "const", constVal: 2 }
},
color: void 0
},
false: {
value: {
type: "triggered",
mode: "auto",
role: "value.battery",
dp: "",
regexp: /\.State\.SOC$/,
read: `const v = Math.round(val / 10)
switch (v) {
case 0:
return 'battery-outline';
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
return 'battery-' + v + '0';
case 10:
default:
return 'battery';}`
},
color: void 0
},
scale: { type: "const", constVal: { val_min: 10, val_max: 50, log10: "max" } }
},
entity1: {
value: {
type: "state",
mode: "auto",
role: "value.battery",
dp: "",
regexp: /\.State\.SOC$/
}
},
text: {
true: { type: "const", constVal: "Battery" },
false: void 0
},
entity2: {
value: {
type: "triggered",
mode: "auto",
role: "value.battery",
dp: "",
regexp: /\.State\.SOC$/
},
unit: { type: "const", constVal: "%" }
},
entity3: {
value: {
type: "triggered",
mode: "auto",
role: "value.power",
dp: "",
regexp: /\.State\.Power$/,
read: "return val < 0"
}
}
}
},
"text.battery.low": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "battery-outline" },
color: { type: "const", constVal: import_Color.Color.Red }
},
false: {
value: { type: "const", constVal: "battery" },
color: { type: "const", constVal: import_Color.Color.Green }
}
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: "indicator.lowbat",
dp: ""
}
},
text: {
true: { type: "const", constVal: "Battery" },
false: void 0
},
text1: {
true: { type: "const", constVal: "ok" },
false: { type: "const", constVal: "low" }
}
}
},
"text.door.isOpen": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "door-open" },
color: { type: "const", constVal: import_Color.Color.open }
},
false: {
value: { type: "const", constVal: "door-closed" },
color: { type: "const", constVal: import_Color.Color.close }
}
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: ["sensor.door", "sensor.open"],
dp: ""
}
},
text: {
true: { type: "const", constVal: "door" },
false: void 0
},
text1: {
true: { type: "const", constVal: "opened" },
false: { type: "const", constVal: "closed" }
}
}
},
"text.gate.isOpen": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "garage-open" },
color: { type: "const", constVal: import_Color.Color.open }
},
false: {
value: { type: "const", constVal: "garage" },
color: { type: "const", constVal: import_Color.Color.close }
}
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: ["sensor.door", "switch.gate", "sensor.open"],
dp: ""
}
},
text: {
true: { type: "const", constVal: "gate" },
false: void 0
},
text1: {
true: { type: "const", constVal: "opened" },
false: { type: "const", constVal: "closed" }
}
}
},
"text.motion": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "motion-sensor" },
color: { type: "const", constVal: import_Color.Color.open }
},
false: {
value: { type: "const", constVal: "motion-sensor" },
color: { type: "const", constVal: import_Color.Color.close }
}
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: ["sensor.motion"],
dp: ""
}
},
text: {
true: { type: "const", constVal: "motion" },
false: void 0
},
text1: {
true: { type: "const", constVal: "On" },
false: { type: "const", constVal: "Off" }
}
}
},
"text.info": {
role: "",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: {
mode: "auto",
role: "state",
type: "triggered",
dp: "",
regexp: /\.USERICON$/,
def: "information-outline"
},
color: {
mode: "auto",
role: "value.rgb",
type: "triggered",
dp: "",
regexp: /\.COLORDEC$/,
def: import_Color.Color.activated
},
text: {
value: {
mode: "auto",
role: "state",
type: "triggered",
dp: "",
regexp: /\.ACTUAL$/,
def: "info"
}
}
},
false: {
value: {
mode: "auto",
role: "state",
type: "triggered",
dp: "",
regexp: /\.USERICON$/,
def: "information-off-outline"
},
color: {
mode: "auto",
role: "value.rgb",
type: "triggered",
dp: "",
regexp: /\.COLORDEC$/,
def: import_Color.Color.deactivated
},
text: {
value: {
mode: "auto",
role: "state",
type: "triggered",
dp: "",
regexp: /\.ACTUAL$/,
def: "info"
}
}
}
},
entity1: {
value: { mode: "auto", role: "state", type: "triggered", dp: "", regexp: /\.ACTUAL$/, def: "info" }
},
text: {
true: { mode: "auto", role: "text", type: "triggered", dp: "", regexp: /\.BUTTONTEXT$/, def: "info" },
false: {
mode: "auto",
role: "text",
type: "triggered",
dp: "",
regexp: /\.BUTTONTEXTOFF$/,
def: "info_off"
}
},
text1: {
true: { mode: "auto", role: "state", type: "triggered", dp: "", regexp: /\.ACTUAL$/, def: "info" }
}
}
},
"text.warning": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "alert-outline" },
color: { type: "const", constVal: import_Color.Color.Yellow }
},
false: void 0,
scale: { type: "const", constVal: { val_min: 4, val_max: 0, mode: "triGrad" } }
},
entity1: {
value: { mode: "auto", role: "value.warning", type: "triggered", dp: "", regexp: /\.LEVEL$/, def: 0 }
},
text: {
true: {
mode: "auto",
role: "weather.title.short",
type: "triggered",
dp: "",
regexp: /\.TITLE$/,
def: "title"
},
false: void 0
},
text1: {
true: {
mode: "auto",
role: "weather.title",
type: "triggered",
dp: "",
regexp: /\.INFO$/,
def: "info"
},
false: void 0
}
}
},
"text.wlan": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "wlan" },
color: { type: "const", constVal: import_Color.Color.Green }
},
false: void 0
},
entity1: void 0,
text: {
true: { type: "const", constVal: "SSID" },
false: void 0
},
text1: {
true: { type: "const", constVal: "opened" },
false: void 0
}
}
},
"text.shutter.navigation": {
type: "text",
role: "blind",
adapter: "",
data: {
icon: {
true: {
value: {
type: "const",
constVal: "window-shutter-open"
},
color: {
type: "const",
constVal: import_Color.Color.On
}
},
false: {
value: {
type: "const",
constVal: "window-shutter"
},
color: {
type: "const",
constVal: import_Color.Color.Off
}
},
unstable: {
value: {
type: "const",
constVal: "window-shutter-alert"
}
},
scale: void 0,
maxBri: void 0,
minBri: void 0
},
text: {
true: { type: "const", constVal: "Blind" }
},
text1: {
true: { type: "const", constVal: "opened" },
false: { type: "const", constVal: "closed" }
},
entity1: {
value: { mode: "auto", role: "", type: "triggered", dp: "", regexp: /\.ACTUAL$/ }
},
entity2: {
value: { mode: "auto", role: "", type: "triggered", dp: "", regexp: /\.TILT_ACTUAL$/ }
}
}
},
"text.lock": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "lock-open-variant" },
color: { type: "const", constVal: import_Color.Color.Cyan }
},
false: {
value: { type: "const", constVal: "lock" },
color: { type: "const", constVal: import_Color.Color.Green }
}
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: ["switch.lock", "state"],
dp: ""
}
},
text: {
true: { type: "const", constVal: "lock" },
false: void 0
},
text1: {
true: { type: "const", constVal: "isOpen" },
false: { type: "const", constVal: "isClose" }
}
}
},
"text.sainlogic.windarrow": {
role: "text",
type: "text",
modeScr: "bottom",
adapter: "sainlogic",
data: {
entity1: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /^sainlogic\.[0-9]+\.weather\.current\.windgustspeed/,
dp: ``
},
decimal: {
type: "const",
constVal: 0
},
unit: void 0
},
entity2: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /^sainlogic\.[0-9]+\.weather\.current\.windgustspeed/,
dp: ``
},
decimal: {
type: "const",
constVal: 0
},
unit: {
type: "const",
constVal: "km/h"
}
},
icon: {
true: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /^sainlogic\.[0-9]+\.weather\.current\.winddir/,
dp: ``,
read: `{
let dir = (val || 0)
dir = (dir - (options?.directionOfPanel || 0) + 360) % 360
let icon = 'arrow-'
let icontop/*: 'bottom-' | 'top-' | 'down-' | 'up-' | ''*/ = ''
let iconleft/*: 'left-' | 'right-' | ''*/ = ''
if (dir > 292.5 || dir < 67.5) {
icontop = 'top-'
}
else if(dir < 247.5 && dir > 112.5) {
icontop = 'bottom-'
}
if (dir < 337.5 && dir > 212.5) {
iconleft = 'left-'
}
else if((dir < 157.5 && dir > 32.5)) {
iconleft = 'right-'
}
if (iconleft === '' && icontop) {
if (icontop === 'top-') {
icontop = 'up-';
} else {
icontop = 'down-';
}
}
return icon + icontop + iconleft + (options?.icon || 'bold-outline')
}`
},
color: {
type: "const",
constVal: import_Color.Color.MSRed
}
},
false: {
color: {
type: "const",
constVal: import_Color.Color.MSGreen
}
},
scale: {
type: "const",
constVal: { val_min: 60, val_max: 0, val_best: 20, mode: "triGradAnchor" }
},
maxBri: void 0,
minBri: void 0
},
text: {
true: {
type: "const",
constVal: "Wind"
},
false: void 0
}
}
},
"text.custom.windarrow": {
role: "text",
type: "text",
modeScr: "bottom",
adapter: "sainlogic",
data: {
entity1: {
value: {
mode: "auto",
role: "value.speed.wind",
type: "triggered",
dp: ``
},
decimal: {
type: "const",
constVal: 0
},
unit: void 0
},
entity2: {
value: {
mode: "auto",
role: "value.speed.wind",
type: "triggered",
dp: ``
},
decimal: {
type: "const",
constVal: 0
}
},
icon: {
true: {
value: {
mode: "auto",
role: "value.direction.wind",
type: "triggered",
dp: ``,
read: `{
let dir = (val || 0)
dir = (dir - (options?.directionOfPanel || 0) + 360) % 360
let icon = 'arrow-'
let icontop/*: 'bottom-' | 'top-' | 'down-' | 'up-' | ''*/ = ''
let iconleft/*: 'left-' | 'right-' | ''*/ = ''
if (dir > 292.5 || dir < 67.5) {
icontop = 'top-'
}
else if(dir < 247.5 && dir > 112.5) {
icontop = 'bottom-'
}
if (dir < 337.5 && dir > 212.5) {
iconleft = 'left-'
}
else if((dir < 157.5 && dir > 32.5)) {
iconleft = 'right-'
}
if (iconleft === '' && icontop) {
if (icontop === 'top-') {
icontop = 'up-';
} else {
icontop = 'down-';
}
}
return icon + icontop + iconleft + (options?.icon || 'bold-outline')
}`
},
color: {
type: "const",
constVal: import_Color.Color.MSRed
}
},
false: {
color: {
type: "const",
constVal: import_Color.Color.MSGreen
}
},
scale: {
type: "const",
constVal: { val_min: 120, val_max: 0, val_best: 20, mode: "triGradAnchor" }
},
maxBri: void 0,
minBri: void 0
},
text: {
true: {
type: "const",
constVal: "Wind"
},
false: void 0
}
}
},
"text.hmip.windcombo": {
role: "textNotIcon",
type: "text",
modeScr: "bottom",
adapter: "hmip",
data: {
entity1: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /.channels\.1\.windSpeed/,
dp: ``
},
decimal: {
type: "const",
constVal: 0
},
unit: void 0
},
entity2: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /.channels\.1\.windSpeed/,
dp: ``
},
decimal: {
type: "const",
constVal: 0
},
unit: {
type: "const",
constVal: "km/h"
}
},
icon: {
true: {
text: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /\.channels\.1\.windDirection/,
dp: ``,
read: `{
const directions = [
"N", "NNE", "NE", "ENE",
"E", "ESE", "SE", "SSE",
"S", "SSW", "SW", "WSW",
"W", "WNW", "NW", "NNW"
];
const index = Math.round((val % 360) / 22.5) % 16;
return directions[index];
}`
}
},
color: {
type: "const",
constVal: import_Color.Color.MSRed
}
},
false: {
color: {
type: "const",
constVal: import_Color.Color.MSGreen
}
},
scale: {
type: "const",
constVal: { val_min: 130, val_max: 0, mode: "triGrad" }
},
maxBri: void 0,
minBri: void 0
},
text: {
true: {
type: "const",
constVal: "Wind"
},
false: void 0
}
}
},
"text.isOnline": {
role: "text",
adapter: "",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "earth" },
color: { type: "const", constVal: import_Color.Color.Green }
},
false: {
value: { type: "const", constVal: "earth-off" },
color: { type: "const", constVal: import_Color.Color.Red }
}
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: ["indicator.reachable"],
dp: ""
}
},
text: {
true: { type: "const", constVal: "Internet" },
false: void 0
},
text1: {
true: { type: "const", constVal: "online" },
false: { type: "const", constVal: "offline" }
}
}
},
"text.openweathermap.sunriseset": {
role: "4values",
adapter: "openweathermap",
type: "text",
data: {
icon: {
true: {
value: { type: "const", constVal: "weather-sunset-up" },
color: { type: "const", constVal: { r: 253, g: 251, b: 29 } }
},
false: {
value: { type: "const", constVal: "weather-sunset-down" },
color: { type: "const", constVal: { r: 255, g: 138, b: 18 } }
}
},
entity1: {
value: {
type: "triggered",
mode: "auto",
role: "date.sunrise",
dp: "",
read: `
if (new Date().getDate() !== new Date(val).getDate()){
return null;
}
const t = new Date(val).getTime();
if (t < Date.now()) return null;
return t;`
},
dateFormat: {
type: "const",
constVal: { local: "de", format: { hour: "2-digit", minute: "2-digit" } }
}
},
entity2: {
value: {
type: "triggered",
mode: "auto",
role: "date.sunset",
dp: "",
read: `
if (new Date().getDate() !== new Date(val).getDate()){
return null;
}
const n = Date.now();
const t = new Date(val).getTime();
if (t < n) return null;
return t;`
},
dateFormat: {
type: "const",
constVal: { local: "de", format: { hour: "2-digit", minute: "2-digit" } }
}
},
entity3: {
value: {
type: "triggered",
mode: "auto",
role: "date.sunrise",
dp: ""
},
dateFormat: {
type: "const",
constVal: { local: "de", format: { hour: "2-digit", minute: "2-digit" } }
}
},
text: {
true: { type: "const", constVal: "sunriseToken" },
false: { type: "const", constVal: "sunsetToken" }
},
text1: void 0
}
},
"text.openweathermap.favorit": {
role: "text",
adapter: "openweathermap",
type: "text",
modeScr: "favorit",
data: {
entity2: {
value: {
role: "value.temperature",
mode: "auto",
type: "state",
dp: "",
regexp: /\.current\.temperature$/
},
decimal: {
type: "const",
constVal: 1
},
factor: void 0
/*unit: {
type: 'const',
constVal: '°C',
},*/
},
icon: {
true: {
value: {
type: "state",
role: "weather.icon",
mode: "auto",
dp: "",
/**
* How to use
* this run its own this. U dont have accress to variables that no definied for this.
* Color: in a import of color.ts
* val: is the incoming value - raw
*
* The best thing is to write the function with () => { here }. Then remove the () => {}
* and convert it into a template literal, using ``. A return is mandatory.
*/
read: `{
if (val && val.split('/').length > 1) {
val = val.split('/').pop();
val = val.split('.')[0];
}
switch (val) {
case "01d":
return 'weather-sunny';
case "01n":
return 'weather-night';
case "02d": //few clouds day
return 'weather-partly-cloudy';
case "02n": //few clouds night
return 'weather-night-partly-cloudy';
case "03d": //scattered clouds
case "03n":
return 'weather-cloudy';
case "04d": // cloudy
case "04n":
return 'weather-cloudy';
case "09d": //shower rain
case "09n":
return 'weather-rainy';
case "10d": //rain
case "10n":
return 'weather-pouring';
case "11d": //Thunderstorm
case "11n":
return 'weather-lightning';
case "13d": //snow
case "13n":
return 'weather-snowy';
case "50d": //mist
case "50n":
return 'weather-fog';
default:
return 'alert-circle-outline';
}
}`
},
color: {
type: "triggered",
role: "weather.icon",
mode: "auto",
dp: "",
read: `
if (val && val.split('/').length > 1) {
val = val.split('/').pop();
val = val.split('.')[0];
}
switch (val) {
case "01d": //clear sky day
return Color.sunny;
case "01n": //clear sky night
return Color.clearNight;
case "02d": //few clouds day
case "02n": //few clouds night
return Color.partlyCloudy;
case "03d": //scattered clouds
case "03n":
return Color.cloudy;
case "04d": //broken clouds
case "04n":
return Color.cloudy;
case "09d": //shower rain
case "09n":
return Color.rainy;
case "10d": //rain
case "10n":
return Color.pouring;
case "11d": //Thunderstorm
case "11n":
return Color.lightningRainy;
case "13d": //snow
case "13n":
return Color.snowy;
case "50d": //mist
case "50n":
return Color.fog;
default:
return Color.White;
}`
}
},
false: { value: void 0, color: void 0 }
},
text: {
true: void 0,
false: void 0
}
}
},
"text.openweathermap.bot2values": {
role: "2values",
type: "text",
modeScr: "bottom",
adapter: "openweathermap",
data: {
entity1: {
value: {
mode: "auto",
role: "",
type: "triggered",
dp: "",
regexp: /\.temperatureMin$/
},
decimal: {
type: "const",
constVal: 0
},
factor: void 0,
unit: {
type: "const",
constVal: "\xB0 "
}
},
entity2: {
value: {
mode: "auto",
role: "",
type: "triggered",
dp: "",
regexp: /\.temperatureMax$/
},
decimal: {
type: "const",
constVal: 0
},
factor: void 0,
unit: {
type: "const",
constVal: "\xB0"
}
},
icon: {
true: {
value: {
type: "state",
role: "",
regexp: /.icon$/,
mode: "auto",
dp: "",
/**
* How to use
* this run its own this. U dont have accress to variables that no definied for this.
* Color: in a import of color.ts
* val: is the incoming value - raw
*
* The best thing is to write the function with () => { here }. Then remove the () => {}
* and convert it into a template literal, using ``. A return is mandatory.
*/
read: `{
if (val && val.split('/').length > 1) {
val = val.split('/').pop();
val = val.split('.')[0];
}
switch (val) {
case "01d":
return 'weather-sunny';
case "01n":
return 'weather-night';
case "02d": //few clouds day
return 'weather-partly-cloudy';
case "02n": //few clouds night
return 'weather-night-partly-cloudy';
case "03d": //scattered clouds
case "03n":
return 'weather-cloudy';
case "04d": // cloudy
case "04n":
return 'weather-cloudy';
case "09d": //shower rain
case "09n":
return 'weather-rainy';
case "10d": //rain
case "10n":
return 'weather-pouring';
case "11d": //Thunderstorm
case "11n":
return 'weather-lightning';
case "13d": //snow
case "13n":
return 'weather-snowy';
case "50d": //mist
case "50n":
return 'weather-fog';
default:
return 'alert-circle-outline';
}
}`
},
color: {
type: "triggered",
role: "",
regexp: /.icon$/,
mode: "auto",
dp: "",
read: `
if (val && val.split('/').length > 1) {
val = val.split('/').pop();
val = val.split('.')[0];
}
switch (val) {
case "01d": //clear sky day
return Color.sunny;
case "01n": //clear sky night
return Color.clearNight;
case "02d": //few clouds day
case "02n": //few clouds night
return Color.partlyCloudy;
case "03d": //scattered clouds
case "03n":
return Color.cloudy;
case "04d": //broken clouds
case "04n":
return Color.cloudy;
case "09d": //shower rain
case "09n":
return Color.rainy;
case "10d": //rain
case "10n":
return Color.pouring;
case "11d": //Thunderstorm
case "11n":
return Color.lightningRainy;
case "13d": //snow
case "13n":
return Color.snowy;
case "50d": //mist
case "50n":
return Color.fog;
default:
return Color.White;
}`
}
},
false: { value: void 0, color: void 0 }
},
text: {
true: {
mode: "auto",
role: "",
type: "triggered",
dp: "",
regexp: /\.date$/,
read: `{
if (!val) {
return null;
}
const date = new Date(val);
if (!date) {
return null;
}
return date.toLocaleDateString(language || 'en', { weekday: "short" });
}`
},
false: void 0
}
}
},
"text.openweathermap.windspeed": {
role: "text",
type: "text",
modeScr: "bottom",
adapter: "openweathermap",
data: {
entity1: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /^openweathermap\.[0-9]+\.forecast\.current\.windSpeed/,
dp: ``
},
decimal: {
type: "const",
constVal: 0
},
unit: void 0
},
entity2: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /^openweathermap\.[0-9]+\.forecast\.current\.windSpeed/,
dp: ``
},
decimal: {
type: "const",
constVal: 0
},
unit: {
type: "const",
constVal: "km/h"
}
},
icon: {
true: {
value: {
type: "const",
constVal: "weather-windy"
},
color: {
type: "const",
constVal: import_Color.Color.MSRed
}
},
false: {
value: {
type: "const",
constVal: "weather-windy"
},
color: {
type: "const",
constVal: import_Color.Color.MSGreen
}
},
scale: {
type: "const",
constVal: { val_min: 0, val_max: 80 }
},
maxBri: void 0,
minBri: void 0
},
text: {
true: {
type: "const",
constVal: "Wind"
},
false: void 0
}
}
},
"text.openweathermap.winddirection": {
role: "text",
type: "text",
modeScr: "bottom",
adapter: "openweathermap",
data: {
entity2: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /^openweathermap\.[0-9]+\.forecast\.current\.windDirection$/,
dp: ``,
read: `{
const directions = [
"N", "NNO", "NO", "ONO",
"O", "OSO", "SO", "SSO",
"S", "SSW", "SW", "WSW",
"W", "WNW", "NW", "NNW"
];
// 360 Grad in 16 Sektoren aufteilen - 22.5\xB0 pro Richtung
const index = Math.round(((val % 360) / 22.5)) % 16;
return directions[index];
}`
},
decimal: {
type: "const",
constVal: 0
},
factor: void 0,
unit: {
type: "const",
constVal: ""
}
},
icon: {
true: {
value: {
type: "const",
constVal: "windsock"
},
color: {
type: "const",
constVal: "#FFFFFF"
}
},
false: {
value: void 0,
color: void 0
},
scale: void 0,
maxBri: void 0,
minBri: void 0
},
text: {
true: {
type: "const",
constVal: "Windr."
},
false: void 0
}
}
},
"text.openweathermap.windgust": {
role: "text",
type: "text",
modeScr: "bottom",
adapter: "openweathermap",
data: {
entity1: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /^openweathermap\.[0-9]+\.forecast\.current\.windGust$/,
dp: ``
},
decimal: {
type: "const",
constVal: 0
},
unit: void 0
},
entity2: {
value: {
mode: "auto",
role: "",
type: "triggered",
regexp: /^openweathermap\.[0-9]+\.forecast\.current\.windGust$/,
dp: ``
},
decimal: {
type: "const",
constVal: 0
},
unit: {
type: "const",
constVal: "m/s"
}
},
icon: {
true: {
value: {
type: "const",
constVal: "weather-tornado"
},
color: {
type: "const",
constVal: import_Color.Color.MSRed
}
},
false: {
value: {
type: "const",
constVal: "weather-tornado"
},
color: {
type: "const",
constVal: import_Color.Color.MSGreen
}
},
scale: {
type: "const",
constVal: { val_min: 0, val_max: 80 }
},
maxBri: void 0,
minBri: void 0
},
text: {
true: {
type: "const",
constVal: "B\xF6en"
},
false: void 0
}
}
},
"text.pirate-weather.favorit": {
role: "text",
adapter: "pirate-weather",
type: "text",
modeScr: "favorit",
data: {
entity2: {
value: {
role: "value.temperature",
mode: "auto",
type: "state",
dp: "",
regexp: /\.currently\.temperature$/
},
decimal: {
type: "const",
constVal: 1
},
factor: void 0
/*unit: {
type: 'const',
constVal: '°C',
},*/
},
icon: {
true: {
value: {
type: "state",
role: "weather.icon.name",
mode: "auto",
dp: "",
read: `switch (val) {
case 'cloudy':
case 'mostly-cloudy-day':
case 'mostly-cloudy-night':
return 'weather-cloudy';
case 'fog':
case 'mist':
case 'smoke':
return 'weather-fog';
case 'hail':
return 'weather-hail';
case 'haze':
return 'weather-hazy'
case 'thunderstorm':
return 'weather-lightning';
case 'possible-precipitation-day':
case 'possible-precipitation-night':
return 'weather-lightning-rainy';
case 'clear-night':
case 'mostly-clear-night':
return 'weather-night';
case 'partly-cloudy-night':
return 'weather-night-partly-cloudy';
case 'mostly-cloudy-day':
case 'partly-cloudy-day':
return 'weather-partly-cloudy';
case 'possible-rain-day':
case 'possible-rain-night':
return 'weather-partly-rainy';