artem-sedykh / mini-climate-card

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

Use hvac_action Attribute in hvac_mode Section #141

Closed V3L closed 5 months ago

V3L commented 5 months ago

So I am trying to replace the standard hvac_mode status/icon with the value store in hvac_action (attribute), as my heating always shows as on, but hvac_action will show whether it is actually heating or not based on current temperature and set temperature.

I think I found the part in the docs, but I can't seem to get it to display anything and adding the extra parts for hvac_mode removes the icon: Example mini-climate card config:

type: custom:mini-climate
name: YYYY's Office
entity: climate.office
swap_temperatures: true
icon: mdi:radiator
group: true
secondary_info:
  hide: true
toggle:
  hide: true
hvac_mode:
  state:
    entity: climate.office
    attribute: hvac_action

image

I will also want to vary the yellow icon at the start to change based on this value, so if you can advise on that as well that would be great!

Thanks, Vel

regevbr commented 5 months ago

I think you need to set the source attribute otherwise it doesn't know which icon to set

regevbr commented 5 months ago

You also need to provide active and disabled so it can know its state

V3L commented 5 months ago

Thanks for the quick response, would you be able to update my yaml to explain what you mean?

regevbr commented 5 months ago

https://github.com/artem-sedykh/mini-climate-card?tab=readme-ov-file#hvac_mode

V3L commented 5 months ago

Thanks for the link. I’ve read through that and the examples a bunch of times, but I can’t quite figure out the syntax for my scenario, are you able to update my yaml to help me visualise it better?

regevbr commented 5 months ago

I can't don't know the values you have. You have examples in the docs

V3L commented 5 months ago

What values can I provide you to pin this down, I’m confident that if I can get it working then the rest of the docs will make more sense

regevbr commented 5 months ago
type: custom:mini-climate
name: YYYY's Office
entity: climate.office
swap_temperatures: true
icon: mdi:radiator
group: true
secondary_info:
  hide: true
toggle:
  hide: true
hvac_mode:
  state:
    entity: climate.office
    attribute: hvac_action  
  source:
    'off':
      icon: mdi:power
      name: 'off'
    heat:
      icon: mdi:weather-sunny
      name: heat
    auto:
      icon: mdi:cached
      name: auto
    cool:
      icon: mdi:snowflake
      name: cool
    dry:
      icon: mdi:water
      name: dry
    fan_only:
      icon: mdi:fan
      name: fan
V3L commented 5 months ago

That worked great, thanks!

How do I set the colour now, as looks to be getting from the main hvac_mode still. Can I set that against each of my sources, or do I have to do it at the top with logic, if off then x if heat then y etc?

regevbr commented 5 months ago

in example you have the style function

V3L commented 5 months ago

Does the below logic make sense, it doesn’t seem to update the colour as I would expect, current hvac_action value is heat, and the colour is showing as orange.

hvac_mode:
  style: >-
    (value, entity) => ({ color: entity.attributes.hvac_action !== 'idle' ?
    'orange !important' : 'grey' })
regevbr commented 5 months ago

sure