Use icon as a switch

At this moment I only want to know if the A/C is cooling or heating when I turn it on. So as soon as I use the switch it turns on in the last state. The icon shows me if this is heating or cooling. Every other state turns the icon white…that’s no problem as heating/cooling are the only two states I use at the moment.

So the switch should turn the airco on/off (which is working fine) and the icon shows me the state it’s in. Does this make any sense? :slight_smile:

1 Like

if you go to Developer-Tools, under “States”, what does your template-sensor shows there ?
I think what you actually want is to CSS-Style your Icon, based on the current State … your template switch/sensor don’t shows that, so you must have another sensor( or Attribute ) that shows the current State ?

Im not familiar with your A/C, and which entities you get from it, or how/whether you have a specific Sensor that shows the State (might be a sensor (on/off) with Attributes, then it’s the attributes you need to get into the equation :slight_smile:

Just use button-card from romraider. It is exactly what you’re looking for:

1 Like

Thou still he needs to find out from(which sensor or Attribute ) where he gets the current “State” whether it’s Heat or Cool, and based on that , Change the color of the Icon, in his card

The entry under “climate” domain should give the actual state like heat or cool. :slight_smile: That’s how climate entities work. :slight_smile:

With button-card you can do exactly what he wants. You can set the “main” entity to climate.livingroom_ac and get the state like cool or heat. But you can set the icon(s) or other things to other sensors or switches.

Ok, well he has/using a “template-sensor”, for some reason, that turns on/off his AC ( A Switch ) Not a climate-entity … And he want to use these Banner-Cards, in general, on this Tablet-Dashboard
So the only way(or one way) to change the Icon-Color, to “even” show what State the climate-entity is in, he need “template/card-mod” on this “Switch.entity” i.e ( is_state_attr or is_state …OF the climate-entry(entity) that shows this.
His Template-sensor don’t or his switch, based on the template-sensor, don’t shows the climate state, but you can show the Climate-State where ever you want, if you know where to get it :slight_smile:

You’re missing the point here. :slight_smile: Or I am, let’s see.

What he wants is to show an icon based on the state of the climate entity and to turn on/off a switch (no matter what entity). That is exactly what button-card does, and it does it very well.

The climate entity is shown in the first post, climate.air_conditioning_air_care, as well as the switch ac_switch.

I don’t see a problem in setting this up.

And it doesn’t matter where you use the button-card, it works even in a banner-card. Not that I’d recommend that, but it is possible. I’d suggest changing the overall design to button-card, as it makes future changes much easier, but that’s for the user to decide. :slight_smile:

I’m not going into a debate with you, i have Custom.Button-cards my self … beside that, i don’t really see why I or you is “missing the point” We are talking about 2 different things, And neither of us knows what his A/C delivers, whether it has 1 or several entities etc. , so basically you just jump in and tell him to ditch his work, because that’s what you would have done, because you use a different solution … not saying it’s wrong, but you haven’t told me either whether how many “sensors” you get from your A/C, whether the states is per sensor, or the States actually are “Attributes”, maybe because you actually don’t know. Or you have never considered “modding” , maybe you are right that it’s all in the climate.air_conditioning_air_care In that case this is where he get’s the “state” from, But this could actually be Entity-Attributes-States, Not entity-state

Ok, let’s make this clear…we got several discussions going on here about multiple topics.

These are the attributes (including the states) of my A/C sensor:

The ‘map-state’ I’m using in my banner-card works great at this moment. When I turn on the A/C, either with the remote, or the switch within HA, the icon shows if it’s on ‘cool’ or ‘heat’.

The only issue I still have which remains unresolved is that I want to turn on the A/C by tapping on the icon, instead of tapping on the title ‘Airco’ which opens another pop-up window. That’s it.

I do know, because it is a climate entity, and therefor will have some states like cool, heat and so on. The fact that climate. is used, gives us only a few options, the state cool/heat will def. be one of them, otherwise he wouldn’t be able to select either of these.

And I’m not telling anyone to use my suggestion or recommendation, I’m simply stating that there is a card for exactly the use case wanted.

Nope, as stated above, if it is a climate entity, it will have states like cool, heat and so on. Not from attributes, it is the state of that entity, that is how climate entities work. Simple as that.

As you can see in the post from @UniPer, there are exactly these hvac-modes, that will return as the state of that entity.

@UniPer
So back to the problem. As far as I can see, there is no mention in banner-card to use it like a “button”, in this case to switch an entity directly. This is what other custom_components do, for example button-card. To sum it up, with banner-card there is no way to achieve what you want, at least I can’t see it according to the documentation of banner-card.

I do know how “un-funny” it is, to design and setup things, just to see it not working like one wants it, but that is sometimes the case. And if that is the case, the only thing you could do is change the whole thing, or live with its limitations. :slight_smile:

I’m “afraid” paddy is right, so back to my initial “thoughts” that i thought was a pity with all the work you had put into this card,sad but true. … Yes, Button-Card is easy to setup, with highly customized options… Maybe if place inside Layout-Card or similar, you will never noticed a different ( after few days work ) :slight_smile:

If that’s indeed true (it would be bummer), can you at least explain to me why the light.group can be turned on and off tapping the bulb icon?

  - entity: group.kantoor
    name: Verlichting
    value: mdi:lightbulb-multiple
    action:
      service: light.toggle
    map_state:
      'on':
        color: yellow

On:
image
Off
image

Besides this, if I use the code below (climate service) it does work by tapping the icon, the only problem is, I only can turn it on and not off again, that’s why I created the custom switch:

  - entity: climate.air_conditioning_air_care
    name: Airco
    value: mdi:air-conditioner
    action: 
      service: climate.turn_on
    map_state:
      'off':
        color: white
      cool:
        color: lightblue
      heat:
        color: darkred

Another “test” , try to add

domain: sensor

under the entity in your initial working example

EDIT: this is why you can click your light’s, you call the “Toggle service”

    action:
      service: light.toggle

… i think :slight_smile:

So we’re back to the template i think …

Unfortunately this doesn’t work either. The only difference is, when I add ‘tap-action’, the icon doesn’t disappear anymore now I’ve defined ‘domain: sensor’. But when I tap the icon, a pop-up appears instead of it turning on or off. This is the current code:

  - entity: switch.ac_switch
    domain: sensor
    name: Airco
    value: mdi:air-conditioner
    tap-action: 
      action: toggle
    map_state:
      off:
        color: white
      cool:
        color: lightblue
      heat:
        color: darkred

When I tap the icon now, the following pop-up appears:
image

True, I think that this makes the difference. And I don’t have a ‘toggle’ service for the A/C.

So this one works as intended ?, but ofcause it wont turn_of

So somehow, this should call a “service or template” that checks whether( is_state( ```
climate.air_conditioning_air_care

That’s what I was thinking to but…can’t figure it out yet :frowning:

I’m trying to do something like:

  - entity: climate.air_conditioning_air_care
    domain: switch
    name: Airco
    value: mdi:air-conditioner
    tap_action:
      action: call-service
      service: |
        {% if is_state('climate.air_conditioning_air_care', 'off') %}
          climate.turn_on
        {% else %}
          climate.turn_off
        {% endif %}
    map_state:
      off:
        color: white
      cool:
        color: lightblue
      heat:
        color: darkred

and your initial value template don’t work with ‘off’ instead of 'on" ?

No, the only thing that value template is doing, is setting the value of the switch. When you leave this template away from the switch it assumes that all commands are successful. But that won’t change the behavior of the code/switch.

yes, thou i was thinking about the fact that the “climate.air_conditioning_air_care” sensor dont have a state named “on” … and “conditional” template have to use “states” the sensor actual reports i.e “off”

So a script/template/automation shouldn’t go from a state “on” as it don’t exist , only available states is the hvac_modes, as i understand it

That’s true so what I’m trying to accomplish I can use the icon on the banner-card to tap the switch I’ve created. The switch will then simply send the command ‘climate.turn_on’ or ‘climate.turn_off’. Right?