artem-sedykh / mini-climate-card

Minimalistic climate card for Home Assistant Lovelace UI
MIT License
262 stars 19 forks source link

how to change the icon #144

Closed a1ex-ak closed 5 months ago

a1ex-ak commented 5 months ago

I'm trying to change the secondary_info icon

secondary_info: 
      type: hvac-mode
      icon: 'mdi:thermostat'

Снимок экрана от 2024-02-05 13-11-20

but it doesn't change, what am I doing wrong?

regevbr commented 5 months ago

no idea, works for me:

image

regevbr commented 5 months ago

Please always paste full yaml config, not pictures

a1ex-ak commented 5 months ago

без понятия, у меня работает:

изображение

type: entities
show_header_toggle: false
state_color: true
entities:
  - entity: climate.kitchen_chalet
    type: custom:mini-climate
    name: 'Кухня '
    icon: mdi:countertop
    swap_temperatures: true
    group: true
    secondary_info: 
      type: hvac-mode
      icon: 'mdi:thermostat'
    toggle:
      hide: true
    hvac_mode:
      style: >-
        (value, entity) => ({ color: value !== 'off' ? 'orange !important' :
        'grey' })
      source:
        heat:
          icon: mdi:fire
          name: 'Обогрев '
        'off':
          icon: mdi:power
          name: 'Выкл. '
      change_action: >
        (selected, entity) => this.call_service('climate', 'set_hvac_mode', {
        entity_id: entity.entity_id, hvac_mode: selected })
    indicators:
      humidity:
        icon:
          template: () => 'mdi:water-percent'
          style: |
            (value) => (value > 0 ? { color: '#4682B4'} : {})
        unit: '%'
        round: 1
        source:
          entity: sensor.sonoff_a480072e16_humidity
      power_consumption:
        icon:
          template: >
            (value) => (value > 90 ? 'mdi:battery' : {}),(value) => (value < 60
            ? 'mdi:battery-50' : 'mdi:battery'),(value) => (value < 80 ?
            'mdi:battery-70' : 'mdi:battery')
          style: >
            (value) => (value > 90 ? { color: '#008000'} : {}),(value) => (value
            < 60 ? { color: '#FF0000'} : { color: '#008000'}),(value) => (value
            < 80 ? { color: '#FFFF00'} : { color: '#008000'})
        unit: '%'
        round: 1
        source:
          entity: sensor.sonoff_a480072e16_battery
  - type: divider
  - entity: switch.sonoff_1001676f3c
    icon: mdi:radiator
    secondary_info: last-changed
regevbr commented 5 months ago

hvac_mode not hvac-mode please pay attention

a1ex-ak commented 5 months ago
secondary_info: 
      type: hvac-mode
      icon: 'mdi:thermostat'

Corrected it, but now it only displays the icon and no text

secondary_info: 
      type: hvac_mode
      icon: 'mdi:thermostat'
    toggle:
      hide: true

Снимок экрана от 2024-02-05 13-27-05

regevbr commented 5 months ago

no idea, works for me:

image

regevbr commented 5 months ago

Im sorry I got it all wrong.... It should be hvac-mode. But in hvac-mode it will not use the provided icon as it doesn't really make sense - the icon need to change according to the HVAC mode. In order to overide icons (and the text shown) you need o map all possible hvac modes in the hvac_mode source attribute. For example:

type: custom:mini-climate
entity: climate.living_room
secondary_info:
  type: hvac-mode
hvac_mode:
  source:
    'off':
      name: bla
      icon: mdi:thermostat

image

Also please notice that the rendering of the component while you edit the config is not stable (not sure why) so to verify changes, please save it and see what happens

a1ex-ak commented 5 months ago
secondary_info:
  type: hvac-mode
hvac_mode:
  source:
    'off':
      name: bla
      icon: mdi:thermostat
type: entities
show_header_toggle: false
state_color: true
entities:
  - entity: climate.kitchen_chalet
    type: custom:mini-climate
    name: 'Кухня '
    icon: mdi:countertop
    swap_temperatures: true
    group: true
    #secondary_info: hvac-mode
    secondary_info:
      type: hvac-mode
    hvac_mode:
      source:
        'off':
          name: bla
          icon: mdi:thermostat
        heat:
          name: Обогрев
          icon: mdi:thermostat
    toggle:
      hide: true
    hvac_mode:
      style: >-
        (value, entity) => ({ color: value !== 'off' ? 'orange !important' :
        'grey' })
      source:
        heat:
          icon: mdi:fire
          name: 'Обогрев '
        'off':
          icon: mdi:power
          name: 'Выкл. '
      change_action: >
        (selected, entity) => this.call_service('climate', 'set_hvac_mode', {
        entity_id: entity.entity_id, hvac_mode: selected })
    indicators:
      humidity:
        icon:
          template: () => 'mdi:water-percent'
          style: |
            (value) => (value > 0 ? { color: '#4682B4'} : {})
        unit: '%'
        round: 1
        source:
          entity: sensor.sonoff_a480072e16_humidity
      power_consumption:
        icon:
          template: >
            (value) => (value > 90 ? 'mdi:battery' : {}),(value) => (value < 60
            ? 'mdi:battery-50' : 'mdi:battery'),(value) => (value < 80 ?
            'mdi:battery-70' : 'mdi:battery')
          style: >
            (value) => (value > 90 ? { color: '#008000'} : {}),(value) => (value
            < 60 ? { color: '#FF0000'} : { color: '#008000'}),(value) => (value
            < 80 ? { color: '#FFFF00'} : { color: '#008000'})
        unit: '%'
        round: 1
        source:
          entity: sensor.sonoff_a480072e16_battery
  - type: divider
  - entity: switch.sonoff_1001676f3c
    icon: mdi:radiator
    secondary_info: last-changed

errror

Обнаружены ошибки конфигурации:
duplicated mapping key (12:5)

  9 |     swap_temperatures: true
 10 |     group: true
 11 |     secondary_info: hvac-mode
 12 |     secondary_info:
----------^
 13 |       type: hvac-mode
 14 |     hvac_mode:
regevbr commented 5 months ago

so act according to what the message says - remove the duplicate key

a1ex-ak commented 5 months ago

поэтому действуйте согласно сообщению - удалите дубликат переключателя

I don’t quite understand how to do this, since the duplicate hvac_mode is a button in front of the temperature numbers

Снимок экрана от 2024-02-05 14-19-55

secondary_info:
      type: hvac-mode
    hvac_mode:
      source:
        'off':
          name: bla
          icon: mdi:thermostat
        heat:
          name: Обогрев
          icon: mdi:thermostat
    toggle:
      hide: true
    hvac_mode:
      style: >-
        (value, entity) => ({ color: value !== 'off' ? 'orange !important' :
        'grey' })
      source:
        heat:
          icon: mdi:fire
          name: 'Обогрев '
        'off':
          icon: mdi:power
          name: 'Выкл. '
      change_action: >
        (selected, entity) => this.call_service('climate', 'set_hvac_mode', {
        entity_id: entity.entity_id, hvac_mode: selected })
regevbr commented 5 months ago

it is talking about the yaml syntax, not related to the card itself. You can't have a yaml that have duplicate keys:

a: 1
a: 1
a1ex-ak commented 5 months ago

речь идет о синтаксисе yaml, не имеющем отношения к самой карте. У вас может быть yaml с повторяющимися ключами:

a: 1
a: 1

Please forgive me, but I'm even more confused

regevbr commented 5 months ago

Just past the full config here that gives you that error

regevbr commented 5 months ago

I had a typo in the last comment I fixed it

a1ex-ak commented 5 months ago

Just past the full config here that gives you that error

I'm sorry, but I don't understand. Pok your nose, what am I doing wrong?

regevbr commented 5 months ago

Please paste the full config here so I can check

regevbr commented 5 months ago

*paste

a1ex-ak commented 5 months ago
type: entities
show_header_toggle: false
state_color: true
entities:
  - entity: climate.kitchen_chalet
    type: custom:mini-climate
    name: 'Кухня '
    icon: mdi:countertop
    swap_temperatures: true
    group: true
    secondary_info:
      type: hvac-mode
      hvac_mode:
        source:
          'off':
            name: bla
            icon: mdi:thermostat
          heat:
            name: Обогрев
            icon: mdi:thermostat
    toggle:
      hide: true
    hvac_mode:
      style: >-
        (value, entity) => ({ color: value !== 'off' ? 'orange !important' :
        'grey' })
      source:
        heat:
          icon: mdi:fire
          name: 'Обогрев '
        'off':
          icon: mdi:power
          name: 'Выкл. '
      change_action: >
        (selected, entity) => this.call_service('climate', 'set_hvac_mode', {
        entity_id: entity.entity_id, hvac_mode: selected })
    indicators:
      humidity:
        icon:
          template: () => 'mdi:water-percent'
          style: |
            (value) => (value > 0 ? { color: '#4682B4'} : {})
        unit: '%'
        round: 1
        source:
          entity: sensor.sonoff_a480072e16_humidity
      power_consumption:
        icon:
          template: >
            (value) => (value > 90 ? 'mdi:battery' : {}),(value) => (value < 60
            ? 'mdi:battery-50' : 'mdi:battery'),(value) => (value < 80 ?
            'mdi:battery-70' : 'mdi:battery')
          style: >
            (value) => (value > 90 ? { color: '#008000'} : {}),(value) => (value
            < 60 ? { color: '#FF0000'} : { color: '#008000'}),(value) => (value
            < 80 ? { color: '#FFFF00'} : { color: '#008000'})
        unit: '%'
        round: 1
        source:
          entity: sensor.sonoff_a480072e16_battery
  - type: divider
  - entity: switch.sonoff_1001676f3c
    icon: mdi:radiator
    secondary_info: last-changed
regevbr commented 5 months ago

And what is the issue with it?

a1ex-ak commented 5 months ago

И в чем проблема?

Снимок экрана от 2024-02-05 14-33-28

mdi:fire instead of mdi:thermostat

regevbr commented 5 months ago

According to docs, hvac_mode is not inside the secondary info object, but outside of it, you already have it fix it there please

a1ex-ak commented 5 months ago

According to docs, hvac_mode is not inside the secondary info object, but outside of it, you already have it fix it there please

So this is exactly what I can’t figure out how to do?

so that the second displays what I need and the button works. Is this possible?

regevbr commented 5 months ago
type: entities
show_header_toggle: false
state_color: true
entities:
  - entity: climate.living_room
    type: custom:mini-climate
    name: 'Кухня '
    icon: mdi:countertop
    swap_temperatures: true
    group: true
    secondary_info:
      type: hvac-mode
    toggle:
      hide: true
    hvac_mode:
      style: >-
        (value, entity) => ({ color: value !== 'off' ? 'orange !important' :
        'grey' })
      source:
        'off':
          name: bla
          icon: mdi:thermostat
        heat:
          name: Обогрев
          icon: mdi:thermostat
      change_action: >
        (selected, entity) => this.call_service('climate', 'set_hvac_mode', {
        entity_id: entity.entity_id, hvac_mode: selected })
    indicators:
      humidity:
        icon:
          template: () => 'mdi:water-percent'
          style: |
            (value) => (value > 0 ? { color: '#4682B4'} : {})
        unit: '%'
        round: 1
        source:
          entity: sensor.sonoff_a480072e16_humidity
      power_consumption:
        icon:
          template: >
            (value) => (value > 90 ? 'mdi:battery' : {}),(value) => (value < 60
            ? 'mdi:battery-50' : 'mdi:battery'),(value) => (value < 80 ?
            'mdi:battery-70' : 'mdi:battery')
          style: >
            (value) => (value > 90 ? { color: '#008000'} : {}),(value) => (value
            < 60 ? { color: '#FF0000'} : { color: '#008000'}),(value) => (value
            < 80 ? { color: '#FFFF00'} : { color: '#008000'})
        unit: '%'
        round: 1
        source:
          entity: sensor.sonoff_a480072e16_battery
  - type: divider
  - entity: switch.sonoff_1001676f3c
    icon: mdi:radiator
    secondary_info: last-changed

You already have hvac_mode set in your coniofg , just use it instead

a1ex-ak commented 5 months ago
type: entities
...
  - type: divider
  - entity: switch.sonoff_1001676f3c
    icon: mdi:radiator
    secondary_info: last-changed

You already have hvac_mode set in your coniofg , just use it instead

doesn't work for me result

Снимок экрана от 2024-02-05 14-43-15

regevbr commented 5 months ago

Im sorry don't know how to help any further than that

a1ex-ak commented 5 months ago

Thank you ))