-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newline on Template Sensors #115
Comments
Hi, the texts that are rendered to the button image are created as an SVG graphics. Allowing new-line characters to be parsed and converted into new text lines sounds easy but is a real pain. So unfortunatelly i will not support this in the near future :( |
wouldnt something like that work? @cgiesche // svgUtils.js
const text = (text, lineNr) => {
if (text.indexOf("\n") > -1) {
let lines = text.split("\n");
for (let i = lineNr; i < (lines.length + lineNr); i++) {
drawText(lines[i-lineNr], i);
}
return;
}
drawText(text, lineNr);
}
const drawText = (text, lineNr) => {
this.snap.text(0, 26 + lineNr * 36, text)
.attr(this.lineAttr)
.transform(`translateX(${this.halfRes})`);
} |
@cgiesche i can confirm that this works. btw a example on where to use it: - name: streamdecktemperature
state: "{{ states('sensor.aqara_outside_weather_temperature') | int }}° Outside{{- '\n' -}}{{ states('sensor.aqara_weather_temperature') | int }}° Inside" |
lul
Ok, you are right. This seems to be easier than i expected. The painful experience of programming SVG in JavaScript has discouraged me :D If you open a PR, i will accept it and build a prerelease. The official release to the store will take some time as it is a manual process including hand written mails to elgato. I always wait until enough changes have accumulated before asking Elgato to publish the plugin. |
fixed #139: UrlEncode whole text in SVG so no characters get lost or break the button.
fixed #139: UrlEncode whole text in SVG so no characters get lost or break the button.
If you have a template sensor which has a newline in it
{{- '\n' -}}
the icon is still displaying everything in one line.This actually is very useful if you want to display multiple sensor values in one button.
The text was updated successfully, but these errors were encountered: