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
854 stars 187 forks source link

Is it possible to have a screensaver weather override entity that is dynamic based on a template? #1191

Closed saschaludwig closed 2 months ago

saschaludwig commented 4 months ago

FEATURE DESCRIPTION

I have the following screensaver config:

screensaver:
      entities:
        - entity: weather.home
        - entity: weather.home
          type: 0
        - entity: weather.home
          type: 1
        - entity: weather.home
          type: 2
        - entity: sensor.fronius_7_inverter_watts
          name: Solar
          icon: mdi:solar-panel-large

It would be nice if there is any way to have that last entity change dynamically depending on a template. For example:

        - entity: >-
           {% if states('sensor.fronius_7_inverter_watts') < 1 %}
             sensor.pylontech_battery_soc
           {% else %}
             sensor.fronius_7_inverter_watts
           {% endif %}

ADDITIONAL CONTEXT

How can I achieve that or is there any other way to do that?

PANEL / FIRMWARE VERSION

EU / 4.3.3

blindguynar commented 2 months ago

You don't need a feature request here you can just create a template sensor. Then within that sensor do whatever you want to accomplish to get the desired behavior. Put that new sensor as the sensor entity in apps.yaml and then control it outside in your configuration.yaml or templates.yaml depending on how you have your configuration broken out.

Just an idea. i do this with a few sensors to do basically what you're asking for.

joBr99 commented 2 months ago

you can also show and hide entities based on a state or a state template (so you are just adding two both items to the config and hide/show them based on the state template)

https://docs.nspanel.pky.eu/stable/entities/?h=state#hide-item-based-on-state

saschaludwig commented 2 months ago

you can also show and hide entities based on a state or a state template (so you are just adding two both items to the config and hide/show them based on the state template) https://docs.nspanel.pky.eu/stable/entities/?h=state#hide-item-based-on-state

Ah nice! Had not thought about that one. It works like a charm. Thank you.

For reference:


    screensaver:
      entities:
        - entity: weather.home
        - entity: sensor.weather_forecast_daily
          type: 0
        - entity: sensor.weather_forecast_daily
          type: 1
        - entity: sensor.weather_forecast_daily
          type: 2
        - entity: sensor.fronius_7_inverter_dc_watts
          name: Solar
          icon: mdi:solar-panel-large
          state_template:  '{{ states("sensor.fronius_7_inverter_dc_watts") | float <= 100.0 }}'
        - entity: sensor.cerbo_pylontech_soc
          name: Speicher
          icon: mdi:battery
          state_template: '{{ states("sensor.fronius_7_inverter_dc_watts") | float > 100.0 }}'