I created my own widget for showing the level of something.
I have for example different temperature sensors with different output.
One sensor gives as battery state: high, middle and low
Another sensor gives as battery state: ON and OFF
Another sensor gives as battery state: percentage value (for example 85%)
If i want to set the icon by state, all are working except the percentage items. I tried many ways to get it work, but i can’t find a soultion.
f7: "=(items[props.item_4].state === 'OFF') ? props.icon_high : (items[props.item_4].state === 'high') ? props.icon_high : (Number.parseFloat(item_4.state) >= '60') ? props.icon_high : (items[props.item_4].state === 'middle') ? props.icon_medium : (Number.parseFloat(item_4.state) >= '25') ? props.icon_medium : (items[props.item_4].state === 'ON') ? props.icon_low : (items[props.item_4].state === 'low') ? props.icon_low : (Number.parseFloat(item_4.state) < '25') ? props.icon_low : '?'"
Any ideas how to get it working with percentage output?
I would also like to move the state at the end of the card:
But it don’t want to work:
slots:
default:
- component: f7-icon
config:
style:
margin-top: 6px
f7: "=(items[props.item_4].state === 'OFF') ? props.icon_high : (items[props.item_4].state === 'high') ? props.icon_high : (Number.parseFloat(item_4.state) >= '60') ? props.icon_high : (items[props.item_4].state === 'middle') ? props.icon_medium : (Number.parseFloat(item_4.state) >= '25') ? props.icon_medium : (items[props.item_4].state === 'ON') ? props.icon_low : (items[props.item_4].state === 'low') ? props.icon_low : (Number.parseFloat(item_4.state) < '25') ? props.icon_low : '?'"
Any help would be very nice. Btw. i’m not good in programming
Thank you.