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
870 stars 189 forks source link

[Feature Request] change background/time/date/bar colors on screensaver, based on state of an entity #529

Closed sn00zerman closed 1 year ago

sn00zerman commented 1 year ago

FEATURE DESCRIPTION

A clear and concise description of what the feature should do. I want to be able to change the color of the background / time / date / bar off the screensaver, based on the state of an entity.

ADDITIONAL CONTEXT

Add any other context about the problem here. Hello,

I'm looking for a way, to change the color of the background / time / date / bar off the screensaver, based on the state of an entity, (Just as it is possible the change icons / colors, based on the state of an entity)

those colors: screensaver: theme:

time: [220, 0, 255]

date: [220, 0, 255]

bar: [220, 0, 255]

By doing logic, something like this maybe ?: time: entity: light.xxx color: "on": [96,255,96] "off": [255,64,64]

bar: entity: light.xxx color: "on": [96,255,96] "off": [255,64,64]

PANEL / FIRMWARE VERION

Please add the Panel/Firmware Version you are using (EU, US-L or US-P) EU, latest firmware version

andrei-micu-ro commented 1 year ago

This will probably not work because the Nextion display used in the NSPanel doesn't support transparency for images/layers. As per the current HMI file because of the weather icons you can't achieve full background support with the Weather icons displayed correctly.

I tried this in the past with a custom HMI and the only way to achieve this was with extensive Photoshop:

This way you "could" achieve the transparency you want and also have background support, the only problem is that the buttons will be FIXED in place and anytime you want to change the layout (add a new button/image, reorder existing ones, etc.) you will need to re-create the button images from Photoshop so they match the background.

Alternatively you could design a screensaver with no images (only text). You could then add a background image (in Nextion Editor - grab the HMI file, add your background image, compile and generate your own .tft file). The only problem is that you need to add "click" support on texts if you want to.

joBr99 commented 1 year ago

I think this is only about making the existing feature of changing the colors if the icons/background dynamic to the state of entities.

https://docs.nspanel.pky.eu/config-screensaver/#possible-configuration-values-for-screensaver-theme-config

andrei-micu-ro commented 1 year ago

Oh, I didn't play with the themes yet :) thanks for pointing it out. Because of my previous trials with NSPanel custom GUI I thought he was going towards a more colorful Screensaver (background, transparent elements, etc.).

But speaking of which, would you be kind enough to add some extra fields or alternative layouts to the screensaver ? I changed mime to also show the home temperature and humidity next to the clock. I'll still play with the layout and once I find some good alternative I'll send it to you - maybe it helps :)

joBr99 commented 1 year ago

with 3.7.3 you can now do this though homeassistant templates

            color: '{{iif(states("binary_sensor.test")=="on", "[0,255,0]", "[255,165,0]")}}'

However there are no callbacks for entities inside of the template; the entity needs to be added somewhere else on the screensaver to have it rerenderd on changes (as overwrite or as status icon)

ebendl commented 1 year ago

with 3.7.3 you can now do this though homeassistant templates

            color: '{{iif(states("binary_sensor.test")=="on", "[0,255,0]", "[255,165,0]")}}'

However there are no callbacks for entities inside of the template; the entity needs to be added somewhere else on the screensaver to have it rerenderd on changes (as overwrite or as status icon)

Basically, I have backup batteries for my house, and if my grid power is out, I want to show the battery's percentage (states("sensor.victron_battery")) as the date line and then adjust the color of it (date theme config) based on states("sensor.victron_battery") as well.

joBr99 commented 1 year ago

As already noted in the cite: In general for all templates rendered through AppDeamon, they don't support callbacks for templates; so configured templates will never result in automaticly updating anything. There are no addional triggers for rendering the date, it's rendered hourly.

Use one of the forecast icons or one of the status icons for it.

ebendl commented 1 year ago

As already noted in the cite: In general for all templates rendered through AppDeamon, they don't support callbacks for templates; so configured templates will never result in automaticly updating anything. There are no addional triggers for rendering the date, it's rendered hourly.

Use one of the forecast icons or one of the status icons for it.

Is there a MQTT command I can send Tasmota/the Panel to force an update? I do have a bunch of template-based theme colors which I've now noticed use entities which aren't on the standby/screensaver, because I was planning on using color to indicate more statuses. But I can happily "reset" the display every time these events occur - it updates quickly enough.

duanemck commented 1 year ago

Forcing a refresh via MQTT would be great. I have a similar issue where I display templated information int the dateAdditionalTemplate that I would like to be updated more regularly than once an hour.

Or perhaps a config on the screensaver to set a refresh interval?

joBr99 commented 1 year ago

I didn't confirm this, however because of the way the code works internally it should be possible to add a dummy enitity to the screensaver and changeing it's value will result in a screensaver update. (with the 3.9 release)

    screensaver:
      entities:
        - entity: weather.demo_weather_north
        - entity: weather.demo_weather_north
          type: 0
        - entity: weather.demo_weather_north
          type: 1
        - entity: weather.demo_weather_north
          type: 2
        - entity: weather.demo_weather_north
          type: 2
        - delete
        - entity: input_number.refresh_screensaver

It won't be displayed, because the screensaver doesn't have enough space for it, but changeing the value of the input_numer should result in a refresh.