Skip to content

Developer Templates

Armilar edited this page Mar 2, 2024 · 52 revisions

Content

Screensaver

Entities

cardEntities

cardMedia

Popup

Latest Changes


Screensaver

Screensaver - Changing Sunset/Sunrise in one Icon

        // Bottom 7 - Sonnenaufgang - Sonnenuntergang im Wechsel
        {
            template: 'text.accuweather.sunriseset',
            dpInit: '/^accuweather\.0.Daily.+/',
            modeScr: 'bottom',
            data: {
                icon: {
                    true: {
                        value: undefined,
                        color: {
                            type: 'const',
                            constVal: Color.MSYellow,
                        },
                    },
                    false: {
                        value: undefined,
                        color: {
                            type: 'const',
                            constVal: Color.MSYellow,
                        },
                    },
                },
                text: {
                    true: {
                        type: 'const',
                        constVal: 'sunriseToken',
                    },
                    false: {
                        type: 'const',
                        constVal: 'sunsetToken',
                    },
                },
            },
        },

Screensaver - accuweather.0. Forecast

        // Bottom 1 - accuWeather.0. Forecast Day 1
        {
            template: 'text.accuweather.bot2values',
            dpInit: '/^accuweather\\.0.+?d1$/',
            modeScr: 'bottom',
        },

        // Bottom 2 - accuWeather.0. Forecast Day 2
        {
            template: 'text.accuweather.bot2values',
            dpInit: '/^accuweather\\.0.+?d2$/',
            modeScr: 'bottom',
        },

        // Bottom 3 - accuWeather.0. Forecast Day 3
        {
            template: 'text.accuweather.bot2values',
            dpInit: '/^accuweather\\.0.+?d3$/',
            modeScr: 'bottom',
        },

        // Bottom 4 - accuWeather.0. Forecast Day 4
        {
            template: 'text.accuweather.bot2values',
            dpInit: '/^accuweather\\.0.+?d4$/',
            modeScr: 'bottom',
        },

        // Bottom 5 - accuWeather.0. Forecast Day 5
        {
            template: 'text.accuweather.bot2values',
            dpInit: '/^accuweather\\.0.+?d5$/',
            modeScr: 'bottom',
        },

Screensaver - daswetter.0. Forecast

Ersetzen, wenn Template steht

        // Bottom 6 - daswetter.0. Forecast Day 6
        {
            role: '2values',
            dpInit: '',
            type: 'text',
            modeScr: 'bottom',
            data: {
                entity1: {
                    value: { type: 'triggered', dp: 'daswetter.0.NextDays.Location_1.Day_6.Minimale_Temperatur_value' },
                    decimal: {
                        type: 'const',
                        constVal: 0,
                    },
                    factor: undefined,
                    unit: {
                        type: 'const',
                        constVal: '° ',
                    },
                },
                entity2: {
                    value: { type: 'triggered', dp: 'daswetter.0.NextDays.Location_1.Day_6.Maximale_Temperatur_value' },
                    decimal: {
                        type: 'const',
                        constVal: 0,
                    },
                    factor: undefined,
                    unit: {
                        type: 'const',
                        constVal: '°',
                    },
                },
                icon: {
                    true: {
                        value: {
                            type: 'triggered',
                            dp: 'daswetter.0.NextDays.Location_1.Day_6.Wetter_Symbol_id',
                            read: `{
                                        switch (val) {
		                                    case 1:         // Sonnig
                                                return 'weather-sunny';  // sunny
 
			                                case 2:         // Teils bewölkt
                                            case 3:         // Bewölkt
                                                return 'weather-partly-cloudy';  // partlycloudy
				
                                            case 4:         // Bedeckt
                                                return 'weather-cloudy';  // cloudy
				
                                            case 5:        // Teils bewölkt mit leichtem Regen
                                            case 6:        // Bewölkt mit leichtem Regen
                                            case 8:        // Teils bewölkt mit mäßigem Regen
                                            case 9:        // Bewölkt mit mäßigem Regen
                                                return 'weather-partly-rainy';  // partly-rainy
				
                                            case 7:        // Bedeckt mit leichtem Regen
                                                return 'weather-rainy';  // rainy
				
		                                    case 10:        // Bedeckt mit mäßigem Regen
                                                return 'weather-pouring';  // pouring
				
                                            case 11:        // Teils bewölkt mit starken Regenschauern
                                            case 12:        // Bewölkt mit stürmischen Regenschauern
                                                return 'weather-partly-lightning';  // partlylightning
				
                                            case 13:        // Bedeckt mit stürmischen Regenschauern
                                                return 'weather-lightning';  // lightning
				
                                            case 14:        // Teils bewölkt mit stürmischen Regenschauern und Hagel
			                                case 15:        // Bewölkt mit stürmischen Regenschauern und Hagel
			                                case 16:        // Bedeckt mit stürmischen Regenschauern und Hagel
                                                return 'weather-hail';  // Hail
 
                                            case 17:        // Teils bewölkt mit Schnee
                                            case 18:        // Bewölkt mit Schnee
                                                return 'weather-partly-snowy';  // partlysnowy

                                            case 19:        // Bedeckt mit Schneeschauern
                                                return 'weather-snowy';  // snowy
 
                                            case 20:        // Teils bewölkt mit Schneeregen
                                            case 21:        // Bewölkt mit Schneeregen
                                                return 'weather-partly-snowy-rainy';
 
                                            case 22:        // Bedeckt mit Schneeregen
                                                return 'weather-snowy-rainy';  // snowy-rainy
 
                                            default:
                                                return 'alert-circle-outline';
                                        }
                                    }`,
                        },
                        color: {
                            type: 'triggered',
                            dp: 'daswetter.0.NextDays.Location_1.Day_6.Wetter_Symbol_id',
                            read: `{
                                        switch (val) {
                                            case 1:         // Sonnig
                                                return Color.swSunny;
 
                                            case 2:         // Teils bewölkt
                                            case 3:         // Bewölkt
                                                return Color.swPartlycloudy;
 
                                            case 4:         // Bedeckt
                                                return Color.swCloudy;
 
                                            case 5:        // Teils bewölkt mit leichtem Regen
                                            case 6:        // Bewölkt mit leichtem Regen
                                            case 8:        // Teils bewölkt mit mäßigem Regen
                                            case 9:        // Bewölkt mit mäßigem Regen
                                                return Color.swRainy;
 
                                            case 7:        // Bedeckt mit leichtem Regen
                                                return Color.swRainy;

                                            case 10:        // Bedeckt mit mäßigem Regen
                                                return Color.swPouring;
 
                                            case 11:        // Teils bewölkt mit starken Regenschauern
                                            case 12:        // Bewölkt mit stürmischen Regenschauern
                                                return Color.swLightningRainy;
 
                                            case 13:        // Bedeckt mit stürmischen Regenschauern
                                                return Color.swLightning;
 
                                            case 14:        // Teils bewölkt mit stürmischen Regenschauern und Hagel
			                                case 15:        // Bewölkt mit stürmischen Regenschauern und Hagel
			                                case 16:        // Bedeckt mit stürmischen Regenschauern und Hagel
                                                return Color.swHail;
 
                                            case 17:        // Teils bewölkt mit Schnee
                                            case 18:        // Bewölkt mit Schnee
                                                return Color.swSnowy;
 
                                            case 19:        // Bedeckt mit Schneeschauern
                                                return Color.swSnowy;
 
                                            case 20:        // Teils bewölkt mit Schneeregen
                                            case 21:        // Bewölkt mit Schneeregen
                                                return Color.swSnowyRainy;  // snowy-rainy
 
                                            case 22:        // Bedeckt mit Schneeregen
                                                return Color.swSnowyRainy;
 
                                            default:
                                                return Color.White;
                                        }
                                    }`,
                        },
                    },
                    false: {
                        value: undefined,
                        color: undefined
                    },
                    scale: undefined,
                    maxBri: undefined,
                    minBri: undefined,
                },
                text: {
                    true: {
                        type: 'triggered',
                        dp: 'daswetter.0.NextDays.Location_1.Day_6.Tag_value',                        
                        read:  `{
                                    return (val).substring(0,2);
                                }`,
                    },
                    false: undefined,
                },
            },
        },

Entities

bydhvs

        {
            dpInit: 'bydhvs',
            template: 'text.battery.bydhvs',
        },

deConz - IKEA Fyrtur

        // Ikea Fyrtur Rollo - Template
        {
            role: '',
            type: 'shutter',
            dpInit: 'deconz.0.Lights.37',
            data: {
                icon: {
                    true: {
                        value: { 
                            type: 'const', 
                            constVal: 'window-shutter-open' 
                        },
                        color: { 
                            type: 'const', 
                            constVal: Color.Green 
                        },
                    },
                    false: {
                        value: { 
                            type: 'const', 
                            constVal: 'window-shutter' 
                        },
                        color: { 
                            type: 'const', 
                            constVal: Color.HMIOff 
                        },
                    },
                    scale: undefined,
                    maxBri: undefined,
                    minBri: undefined,
                },
                // 1. slider
                entity1: {
                    // button
                    value: { 
                        mode: 'auto', 
                        role: 'level.value', 
                        type: 'triggered', 
                        dp: '.lift' 
                    },
                    decimal: undefined,
                    factor: undefined,
                    unit: undefined,
                    minScale: { 
                        type: 'const', 
                        constVal: 1 
                    },
                    maxScale: { 
                        type: 'const', 
                        constVal: 78 
                    },
                },
                // 2. slider
                entity2: undefined,
                text: {
                    true: {
                        type: 'const',
                        constVal: 'Büro',
                    },
                    false: undefined,
                },
                headline: {
                    type: 'const',
                    constVal: 'IKEA Fyrtur',
                },
                text1: {
                    true: {
                        type: 'const',
                        constVal: 'Rollo Position',
                    },
                    false: undefined,
                },
                text2: undefined,
                up: { 
                    mode: 'auto', 
                    role: 'level.value', 
                    type: 'triggered', 
                    dp: '.lift' , 
                    write: 'return 1'
                },
                down: { 
                    mode: 'auto', 
                    role: 'level.value', 
                    type: 'triggered', 
                    dp: '.lift' , 
                    write: 'return 78'
                },
                stop: {
                    type: 'state',
                    dp: '.stop',
                    mode: 'auto',
                    role: ['button'],
                },
            },
        },

deConz - Battery Load

        {
            type: 'text',
            dpInit: 'deconz.0.Sensors.3',
            template: 'text.battery',
            // Optional
            data: {
                icon: {
                    true: {
                        color: {
                            type: 'const',
                            constVal: Color.MSGreen,
                        },
                    },
                    false: {
                        color: {
                            type: 'const',
                            constVal: Color.MSRed,
                        },
                    },
                },
            },
        },

deConz- window isOpen

        // deConz - Fenstersensor - sensor.open
        {
            type: 'text',
            dpInit: 'deconz.0.Sensors.3',
            template: 'text.window.isOpen',
            data: {
                icon: {
                    true: {
                        color: { type: 'const', constVal: Color.MSRed },
                    },
                    false: {
                        color: { type: 'const', constVal: Color.MSGreen },
                    },
                },
            },
        },

general - button iconLeftSize

        {
            role: 'text.list',
            type: 'button',
            template: 'button.iconLeftSize',
            dpInit: '',
        },

general - button iconRightSize

        {
            role: 'text.list',
            type: 'button',
            template: 'button.iconRightSize',
            dpInit: '',
        },

general - window isOpen

general - window isClose

generic - Shutter

        {
            template: 'generic.shutter',
            dpInit: '0_userdata.0.shutter_test',
            data: {
                icon: {
                    true: {
                        value: { type: 'const', constVal: 'window-open' },
                        color: { type: 'const', constVal: 'aqua', role: 'level.color.name' },
                    },
                    false: null,
                },
            },
        },

shelly - rgbw2

        {
            role: 'rgbSingle',
            type: 'light',
            dpInit: 'shelly.0.SHCB-1#3494546EE3C9#1',
            template: 'light.shelly.rgbw2',
        },

shelly - shutter - 2PM

        {
            type: 'shutter',
            dpInit: '0_userdata.0.shelly.0.SHSW-25#C45BBE5FC53F#1',
            template: 'shutter.shelly.2PM',
        },

zigbee2mqtt - battery Load

        {
            type: 'text',
            dpInit: 'zigbee2mqtt.0.0x00158d00041fdbcb',
            template: 'text.temperature',
        },

zigbee2mqtt - temperature

        {
            type: 'text',
            dpInit: 'zigbee2mqtt.0.0x00158d00041fdbcb',
            template: 'text.temperature',
        },

cardEntities

Waste Calendar

const pageAbfall: pages.PageBaseConfig = {
    card: 'cardEntities',
    dpInit: '0_userdata.0.Abfallkalender',
    uniqueID: 'abfall1',
    template: 'entities.waste-calendar',
};

cardMedia

spotify-premium.0. - Template

const pageMediaSpotifyPremium: pages.PageBaseConfig = {
    template: 'media.spotify-premium',
    dpInit: 'spotify-premium.0',
    alwaysOn: 'always',
    uniqueID: 'media3',
    card: 'cardMedia',
};

Popup

popupTimer - Countdown

        {
            role: 'timer',
            type: 'timer',
            dpInit: '',
            data: {
                icon: {
                    true: {
                        value: {type: 'const', constVal: 'timer'},
                        color: {type: 'const', constVal: Color.MSRed},
                    },
                    false: {
                        value: undefined,
                        color: {type: 'const', constVal: Color.MSGreen},
                    },
                },
                entity1: {
                    value: {
                        type: 'const',
                        constVal: true,
                    },
                },
                headline: {type: 'const', constVal: 'Timer'},
                setValue1: {type: 'state', dp: '0_userdata.0.example_state'},
            },
        },

Latest Changes

Konfiguration - Enums

  • Enums für Page und PageItems hinzugefügt optional: string oder `string[]``
  • enum.rooms und enum.functions verfügbar die Strings müssen auch so anfangen.
  • sind nicht in templates verfügbar - macht auch keinen Sinn - vielleicht für functions dann müssten wir aber erst definieren welche Funktion was bewirkt.
        {
            enums: 'enum.rooms.kitchen' /* oder ['enum.rooms.kitchen'],
            template: 'text.battery.bydhvs',
        },

Platzhalter - dbInit

  • dbInit ist in Templates verfügbar überall optional
  • Platzhalter für dbInit hinzugefügt.
  • dpInit muß immer ein string sein, regexp wird aus diesem String gebaut.
  • device hinzugefügt string
  • #°^°# // das ist ein plazhalter der mit device aufgefüllt wird. Wenn dpInit eine regex sein soll, muß die natürlich als String angelegt werden und das device muss dann für einen regexp escaped werden.

Beispiel:

        {
            device: '0',
            template: 'text.battery.bydhvs',
        },

Auschnitt aus dem Template:

    '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\\.#°^°#\\./',

        data: {

Da alle regexp darunter mit dem dpInit nur auf einen State zutreffen können, ist das Item mit dem device='0' konfiguriert.


Clone this wiki locally