Blackymas / NSPanel_HA_Blueprint

This allows you to configure your complete NSPanel via Blueprint with UI and without changing anything in the code
1.33k stars 247 forks source link

Reload icons from sensors (not only states) #963

Closed kroessig closed 7 months ago

kroessig commented 1 year ago

I change the symbol of my sensor, e.g. to visualize the state of charge. This then only occupies one icon slot from the 7 "chips" and not three. The value is updated regularly, but the sensor's icon is not.

My code:

(my first entry)

edwardtfn commented 1 year ago

Which version of the blueprint/tft/esphome are you running? Are you setting any icon for this chip on the Blueprint settings?

Your sensor is changing icon when battery is less than -100% or more than 100%. None of these conditions will ever happen.

edwardtfn commented 1 year ago

Try this:

  - sensor:
    - name: "Symbol Batterie"
      unique_id: Symbol_Batterie
      unit_of_measurement: "%"
      state: "{{ float(states('sensor.byd_battery_box_premium_hv_ladezustand')) }}"
      icon: >-
        {% set battery_level = states('sensor.solarnet_leistung_von_der_batterie') | float(-1) %}
        {% if battery_level > 98 %}
          mdi:battery
        {% elif battery_level > 90 %}
          mdi:battery-90
        {% elif battery_level > 80 %}
          mdi:battery-80
        {% elif battery_level > 70 %}
          mdi:battery-70
        {% elif battery_level > 60 %}
          mdi:battery-60
        {% elif battery_level > 50 %}
          mdi:battery-50
        {% elif battery_level > 40 %}
          mdi:battery-40
        {% elif battery_level > 30 %}
          mdi:battery-30
        {% elif battery_level > 20 %}
          mdi:battery-20
        {% elif battery_level > 10 %}
          mdi:battery-10
        {% elif battery_level > 0 %}
          mdi:battery-outline
        {% else %}
          mdi:battery-unknown
        {% endif %}
kroessig commented 1 year ago

Hey, thanks for the quick reply. I'm using version 2023.7.1.

There is a misunderstanding. I don't want to change the icon depending on the battery level (SoC). The SoC-Level is only the value. The icon should depend on whether the battery is in the:

(the functionality is of course the same)

  - sensor:
      - name: "Symbol Batterie"
        unique_id: Symbol_Batterie
        unit_of_measurement: "%"
        state: >-
          {{ float(states('sensor.byd_battery_box_premium_hv_ladezustand')) }}   #only value
        icon: >-
          {% if float(states('sensor.solarnet_leistung_von_der_batterie')) < -100 %}   # that's the power
          mdi:battery-arrow-up
          {% elif float(states('sensor.solarnet_leistung_von_der_batterie')) > 100 %}  # that's the power
          mdi:battery-arrow-down
          {% else %}
          mdi:battery-60
          {% endif %}   

I added this sensor on the "SENSOR HOME PAGE". The value (SoC-Level) works well, but the icon doesn't change.

edwardtfn commented 1 year ago

I'm using version 2023.7.1.

This is the version of your Home Assistant or ESPHome, my question was more related to the version of files of this project, but I don't think this is very relevant now.

There is a misunderstanding. I don't want to change the icon depending on the battery level (SoC). The SoC-Level is only the value. The icon should depend on whether the battery is in the:

  • charging mode (power to the battery over 100 (watts)
  • Discharging (power from the battery over 100 (watts)
  • almost constant (between "100 from battery" to "100 to battery")

(the functionality is of course the same)

Ok, my apologies. I misunderstood you.

I added this sensor on the "SENSOR HOME PAGE". The value (SoC-Level) works well, but the icon doesn't change.

I think I got that now. Before I thought you have used on chips. Anyways, my question about the icon selection in the blueprint settings is still valid. If you select an icon there, that will take precedence over the entity's icon. image

edwardtfn commented 1 year ago

Well, I was looking the code (https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/dev/nspanel_blueprint.yaml#L6854) and I notice these sensors on the home page never try to read the icon from the entity, so if an icon isn't selected it will shown an "unknown" icon. I will try to find some time to work at this for the coming release.

edwardtfn commented 1 year ago

I've implement the change to dev and it will be included in the next release.

kroessig commented 8 months ago

I've implement the change to dev and it will be included in the next release.

Hey Edward, Is the change already implemented? If I leave the icon field empty in the blueprint, the one defined in the HA is not displayed.

edwardtfn commented 8 months ago

Yes, that was published a while ago. Please let me know if this is not working properly.

kroessig commented 8 months ago

hey Edward,

sorry about the late reply.

The icon changes for chips and custom buttons unfortunately not for the sensor entities. (HOME PAGE - SENSORS 1 - 3). This includes the temperature sensors too (WEATHER AND TEMPERATURE)

It would be nice if you could set this up.

edwardtfn commented 8 months ago

Let's see if this time it works as expected. It's in dev and hopefully will be included in the coming release.

kroessig commented 8 months ago

Can you tell me briefly what I have to change to use the dev version? I take the blueprint from the Dev folder and under esphome I change main to Dev. But when I want to install it I get:

INFO ESPHome 2023.11.6
INFO Reading configuration /config/esphome/nspanelwoziblueprint.yaml...
INFO Updating https://github.com/Blackymas/NSPanel_HA_Blueprint@dev
INFO Detected time zone 'Europe/Berlin'
Failed config

esphome: None
  name: panelwozi

  Your ESPHome version is too old. Please update to at least 2023.12.0.
  min_version: 2023.12.0b1
  platformio_options:
    build_flags:
      - -Wno-missing-field-initializers

Is there an esp-dev version and do you need it? i think the official version is 2023.11.6.

edwardtfn commented 8 months ago

Unfortunately I've recently added some code which requires ESPHome 2023.12.0, which will hopefully be released later today.

Wait a bit for the new ESPHome and try again. 😉

edwardtfn commented 8 months ago

ESPHome 2023.12.0 is available now.

kroessig commented 8 months ago

hey,

I think something went wrong in version: v4.2dev.1. All components (ESP, Blueprint, TFT) have version: v4.2dev.1.

Previously image

afterward: image

image

Neither the chips nor the custom buttons show the correct icons. The entity names are also no longer available.

image

did I forgot something...?

edwardtfn commented 8 months ago

😞

edwardtfn commented 8 months ago

Can you see anything in your Home Assistant logs (Settings > System > Logs)?

kroessig commented 8 months ago

for example:

Error while executing automation automation.farbe_warmwasser: extra keys not allowed @ data['backgroud']
19:06:55 – (FEHLER) Automatisierung - Die Nachricht ist zum ersten Mal am 17:58:46 aufgetreten und erscheint 819 mal
Farbe Warmwasser: If at step 1: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data['backgroud']

If I run the service manually I can even do that, but I have to delete the "background [0,0,0]" (in the past i used background: [0,0,0])

service: esphome.panelwozi_set_component_color
data:
  component: icon_top_04
  foreground: [0,0,255]

thats works. maybe thats the solution

edwardtfn commented 8 months ago

But this is related to some of your own automation, right? Not the one using the Blueprint, correct?

kroessig commented 8 months ago

ahh, that's right. i disabled these automatisations and will remove the background line.

One log is still there, but I'm not sure where it belongs

Logger: homeassistant.components.automation.nspanel_configuration
Source: helpers/script.py:1783
Integration: Automatisierung (documentation, issues)
First occurred: 17:58:47 (78 occurrences)
Last logged: 19:08:46

NSPanel Configuration: Main choices: Automation reloaded: Choose at step 4: choice 1: Repeat at step 12: If at step 1: If at step 4: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: 'dict object' has no attribute 'icon_color_rgb'
NSPanel Configuration: Main choices: NSPanel event: Choose at step 2: Page changed: Choose at step 1: Home page: Repeat at step 12: If at step 1: If at step 4: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: 'dict object' has no attribute 'icon_color_rgb'
NSPanel Configuration: Main choices: Home page - status bar: Repeat at step 2: If at step 1: If at step 4: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: 'dict object' has no attribute 'icon_color_rgb'

What keywords should I search for there?

edwardtfn commented 8 months ago

I cannot test right now, but I've pushed a fix to this message. It is related to icons on the chips, so it could partially solve the issues you reported, but still not changing icons in other areas. I will look at that tomorrow.

Please let me know if you find other error messages.

edwardtfn commented 8 months ago

@kroessig, could you please try this again?

I believe it was fixed on #1455.

kroessig commented 8 months ago

not now, but tomorrow

should i update only the blueprint or "all"? there is ne new esp version ...

kroessig commented 7 months ago

so, it looks very good. At least it looks almost the same as before. The icons now also change

I still have the following questions/suggestions:

shouldn't it be value03 for example? Unfortunately that doesn't work.

kroessig commented 7 months ago

ahh... #800 . --> home.value03_icon

maybe it's useful to add the information for icon_top_XX and home.valueXX_icon unter Customization

edwardtfn commented 7 months ago

so, it looks very good. At least it looks almost the same as before. The icons now also change

Nice!! So, I will close this issue and we take the new things in it's specific issues, ok?

kroessig commented 7 months ago

you are great. this can be closed

edwardtfn commented 7 months ago