joBr99 / nspanel-lovelace-ui

Custom Firmware for NsPanel with the design of HomeAssistant's lovelace UI in mind, works with Tasmota.
GNU General Public License v3.0
886 stars 191 forks source link

[BUG] StatusIcons with state-bound icons break the screensaver, colors don't work in dev #622

Closed blubbel42 closed 1 year ago

blubbel42 commented 1 year ago

PROBLEM DESCRIPTION

A clear and concise description of what the problem is. When configuring StatusIcons in the newest dev (e2e91ad) which use colors for different states the colorchange will not work, when using different icons for different states all status and weathericons dissapear. Everything else works fine

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [ ] Go to Settings>Add-ons>AppDaemon>Log (or the output of your TS script) and then, provide the output of the log during your issue/bug occurs:

Log output here:



### TO REPRODUCE
_Steps to reproduce the behavior:_
Configure a binary_sensor Status icon with two different icons for "on" and "off" state, then weathericons and statusicons dissapear.
If you just use different colors the icons will be shown with the color for off, but not change with statechanges of the used sensor.

### EXPECTED BEHAVIOUR
_A clear and concise description of what you expected to happen._
Icons should change with state changes as before.

### SCREENSHOTS
_If applicable, add screenshots/pictures to help explain your problem._

### ADDITIONAL CONTEXT
_Add any other context about the problem here._
_Please note here in case you are using ioBroker_

### PANEL / FIRMWARE VERION
_Please add the Panel/Firmware Version you are using (EU, US-L or US-P)_
EU, Tasmota 12.1.1, newest Nextion firmware
joBr99 commented 1 year ago

thanks for repoting

was able to reproduce; state based icon overwires are broken will have a look

joBr99 commented 1 year ago

hey, should be fixed update to main in hacs and restart appdaemon

blubbel42 commented 1 year ago

Thanx!! That was really damn fast! Can confirm Bug is fixed, does work now.

ebendl commented 1 year ago

Not sure where to ask this, but is there an easier way to do this?

      weatherOverrideForecast4:
        entity: sensor.victron_battery
        name: Batt
        icon: 
            "100": mdi:battery
            "99": mdi:battery-90
            "98": mdi:battery-90
            "97": mdi:battery-90
            "96": mdi:battery-90
            "95": mdi:battery-90
            "94": mdi:battery-90
            "93": mdi:battery-90
            "92": mdi:battery-90
            "91": mdi:battery-90
            "90": mdi:battery-90
            "89": mdi:battery-80
            "88": mdi:battery-80
            "87": mdi:battery-80
            "86": mdi:battery-80
            "85": mdi:battery-80
            "84": mdi:battery-80
            "83": mdi:battery-80
            <etc>
joBr99 commented 1 year ago

you can do this based on homeassistant templates:

        icon: 'ha:{{ state_attr("climate.wohnzimmer_boden","current_temperature")}}'

you just need a template that outputs the icon name you are searching for

https://docs.nspanel.pky.eu/entities/?h=icons#override-icons-or-names https://www.home-assistant.io/integrations/template/

You can test templates in the HA Dev Tools

(best way to implement this is probably do devide the battery value by 10 and convert it to an iteger and then append it to the name of the icon)

ebendl commented 1 year ago

I had this originally, but it didn't work:

         icon: >
            {%if(int(states("sensor.victron_battery")) > 99) %} 
            mdi:battery
            {%elif(int(states("sensor.victron_battery")) < 10) %} 
            mdi:battery-alert-variant-outline
            {%else%}
            mdi:battery-{{int(states("sensor.victron_battery")) // 10}}0
            {%endif%}

Where do I need to insert the "ha:"?

joBr99 commented 1 year ago

try this

         icon: >
            ha:{%if(int(states("sensor.victron_battery")) > 99) %} 
            mdi:battery
            {%elif(int(states("sensor.victron_battery")) < 10) %} 
            mdi:battery-alert-variant-outline
            {%else%}
            mdi:battery-{{int(states("sensor.victron_battery")) // 10}}0
            {%endif%}

I'm not sure if the newlines are an issue, maybe you have to do it in one line:

ha:{%if(int(states("sensor.0x00158d0004314218_battery")) > 99) %}mdi:battery{%elif(int(states("sensor.0x00158d0004314218_battery")) < 10) %}mdi:battery-alert-variant-outline{%else%}mdi:battery-{{int(states("sensor.0x00158d0004314218_battery")) // 10}}0{%endif%}

ebendl commented 1 year ago

I tried it like this:

        icon: 'ha:{%if(int(states("sensor.victron_battery")) > 99) %}battery{%elif(int(states("sensor.victron_battery")) < 10) %}battery-alert-variant-outline{%else%}battery-{{int(states("sensor.victron_battery")) // 10}}0{%endif%}'

(and I checked that I got ha:battery-50 in the Template playground in Dev tools with a 50% charge), but unfortunately it still doesn't render an icon, just text:

IMG_1888 2

Adding "mdi:" back resulted in this:

IMG_1887

This is running version 3.7.3, by the way, on the US-P display.

joBr99 commented 1 year ago

You are right, the main reason for the templates was to display values from HA instead of icons. You can use the character of the icon instead of the name. Just click on the U in the cheat sheet and use it instead if the name.

https://docs.nspanel.pky.eu/icon-cheatsheet.html