Hey there
I have troubles figuring out how to properly create a template with value mapping (transformation). My item is a modbus channel which I can write to. I tried using String to map the numbers but I cannot write then (probably error 30).
Unfortunately the dummy widget doesn’t allow mappings either (if they don’t come from the item itself) so I guess the only way to do it is using a template-widget. Since I want it to look like the original, I used a guide from here. Googled and tried things for the last few hours to no avail. I hope you guys can help me out.
HABPanel
<style>.myVersionOfWidget {padding: 0; margin: 0; border: none;}</style>
<div class="myVersionOfWidget" ng-init='myWidget={
"name": ngModel.name,
"item": "FiltrationState",
"type": "dummy",
"font_size": "20",
"backdrop_iconset": "smarthome-set",
"backdrop_icon": "power-button",
"backdrop_center": true,
"hidelabel": false,
"hideonoff": false
}'>
<widget-dummy ng-model="myWidget">
</widget-dummy>
</div>
I also tried adding the following here and there but it doesn’t work
<div ng-if=\"itemState(config.dummy_item) == '0'\">Aus</div>
<div ng-if=\"itemState(config.dummy_item) == '1'\">Ein</div>
Item
Number FiltrationState "Pumpe ist [%s]" { channel="modbus:data:oxilifepool:register1057:FiltrationState:number" }
Sitemap
Text item=FiltrationState label="Pumpe ist [MAP(simpleonoff.map):%s]" icon="pump"
simpleonoff.map
0=Aus
1=An
=default
-=undefined
NULL=NULL
This works plain but is missing the style and such
{{itemValue('FiltrationState') == 0 ? 'Aus' : 1 ? 'An' : 'Unbekannt'}}