From 1b1dc8fe7f55936704229e018acdc4d5a4a906d9 Mon Sep 17 00:00:00 2001 From: Christoph Giesche Date: Wed, 3 Feb 2021 21:17:26 +0100 Subject: [PATCH] Added missing fallback label-templates for default sensor. --- README.md | 2 +- src/modules/plugin/imageUtils.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1284ede..612d22a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # streamdeck-homeassistant -The aim of this project is to allow owners of an eglato StreamDeck to control their entities or display sensor data via +The aim of this project is to allow owners of an elgato StreamDeck to control their entities or display sensor data via their StreamDeck. As the code is kept very generic, nearly every sensor should work out of the box as well as every service that does not need any more information but the entity id. diff --git a/src/modules/plugin/imageUtils.js b/src/modules/plugin/imageUtils.js index 39b6809..09ca9d1 100644 --- a/src/modules/plugin/imageUtils.js +++ b/src/modules/plugin/imageUtils.js @@ -99,7 +99,7 @@ export const IconFactory = { }, default: (state, attributes, labelTemplate) => { - return Icon.labelledIcon(state, attributes, labelTemplate) + return Icon.labelledIcon(state, attributes, labelTemplate || IconFactory.sensor._defaultLabelTemplate) } } @@ -217,8 +217,8 @@ const Icon = { return `${weatherIcon}` }, - labelledIcon: (state, attributes, templates, image = "", labelTopOffset = 30) => { - const line1 = new Handlebars.compile(templates.line1)({...{state}, ...attributes, ...{colors}}) + labelledIcon: (state, attributes, templates = {}, image = "", labelTopOffset = 30) => { + const line1 = new Handlebars.compile(templates.line1 || "{{state}}")({...{state}, ...attributes, ...{colors}}) const line2 = new Handlebars.compile(templates.line2 || "")({...{state}, ...attributes, ...{colors}}) const line3 = new Handlebars.compile(templates.line3 || "")({...{state}, ...attributes, ...{colors}})