Controlling the Attribute for an Entity

Hi,

My Thermostat displays all the available attributes in climate.home but I want to control one attribute without having to display the whole card, is there anyway to do this in lovelace? I specifically want to switch between the attributes available in operation_mode preferably from a dropdown list or toggle button. Please help? I run Hassio in docker if that helps.

This is possible with an input_select and an automation that monitors the input_select and when it changes passes that info to your thermostat.

Would need some more information about the available modes and services for your climate platform to provide an automation though.

Same concept as what I am doing here:

1 Like

Oh wow, thanks for the reply, I will go through it and try.

The attributes available to my climate platform are the following. I want to switch between ‘operation_mode’ for ‘heat’ and ‘off’ or if thats not possible, maybe a dropdown with all modes. I also tried the template switch but not able to understand where to define the ‘heat’ and ‘off’ attributes as well as ‘service’ parameter. My goal is to get a native switch to turn on and off the thermostat without fiddling with the temperature.

current_temperature: 24.6
min_temp: 7
max_temp: 35
temperature: 24
target_temp_high: null
target_temp_low: null
fan_mode: auto
fan_list: auto,on
operation_mode: heat
operation_list: auto,auxHeatOnly,cool,heat,off
hold_mode: null
away_mode: off
aux_heat: off
actual_humidity: 42
fan: off
climate_mode: Home
operation: idle
climate_list: Sleep,Home,Awake,Away
fan_min_on_time: 15
friendly_name: Climate
supported_features: 3575

In the side bar of your front end can you look at the services panel and provide the service options available for your climate component?

A Template switch should be an option if you just prefer to have an on/off for your heat.

How dumb of me to not read the climate platform documentation before trying to reinvent the wheel! I didn’t even know this thing existed.

So my climate has services for climate.set_operation_mode and climate.set_away_mode among the other typical services like set temperature, can I set it up into a binary switch? Or would I need template switch to achieve that?

A template switch would be easy and gets the on/off for heat you are looking for.

I can provide an example when I’m not on my phone or someone else will be around to help.

Basics are to call the set operation mode service and pass the mode as data.

That would be great! Thank you very much!

Try this. The service calls work in my heating automation and I tested the value_template in my setup with the template dev tool. Haven’t testing this all together but it should work. Let me know if you have issues.

switch:
  - platform: template
    switches:
      heat_control:
        value_template: ""{{ is_state_attr('climate.home', 'operation_mode', 'heat') }}""
        turn_on:
          service: climate.set_operation mode
          data:
            entity_id: climate.home
            operation_mode: heat
        turn_off:
          service: climate.set_operation mode
          data:
            entity_id: climate.home
            operation_mode: off

Thanks for that. I tried it and it immediately threw errors for the double double quotes on value_template and I fixed that but now the switch stays on and does not switch off. I can turn it off but it turns back on again. ANy idea?

woops, sorry about the double quotes.

Is your climate named climate.home in the states list? You need to replace climate.downstairs with your climate.XXXXXX to make the template work. And the service calls for that matter.

"{{is_state_attr('climate.downstairs', 'operation_mode', 'heat')}}"

I tested the above again in my template tool. When heat is selected it returns true, when its off it returns false.

Mine is set to the corresponding state attribute and the button does show up as on(since my heat is running) but when i toggle it off, it turns back on in a second or two. I’m lost at this point.

It will turn back on until your climate operation_mode changes to something other than heat.

This is expected.

When you turn the switch off is it turning the operation mode to ‘off’

At the moment, the newly created switch acts as a reflection of the heating status only. I cannot toggle it but when I turn cooling on or switch the thermostat off, the switch toggles to off but would not let me toggle back on, but it turns on when I switch the thermostat back to heat. Any other approaches you can suggest me ?

Anything in your error log after the switch is used?

Ok, really sorry about another typo. Put the switch into my config and found the error. See if you can spot it.

This should do it.

  - platform: template
    switches:
      heat_control:
        value_template: "{{ is_state_attr('climate.home', 'operation_mode', 'heat') }}"
        turn_on:
          service: climate.set_operation_mode
          data:
            entity_id: climate.home
            operation_mode: heat
        turn_off:
          service: climate.set_operation_mode
          data:
            entity_id: climate.home
            operation_mode: off

If it was the set_operation_mode missing the underscore you are talking about, I had it fixed when you provided the first snippet as I couldnt get the config test to pass.

Oh wait, now it started working! Thank you very much!

Post your config, looks like you may have climate_mode specified under data?

The last config I posted works in my setup and is a copy and paste from my config file. I turned it on and off a number of time and watched the thermostat turn from heat to off.

Oh I guess you missed my last edit on the post, Its working perfectly now, thank you very much! Here is my config:

#Ecobee Thermostat Control

  • platform: template
    friendly_name: Climate Control
    icon_template: mdi:fire
    switches:
    heat_control:
    value_template: “{{is_state_attr(‘climate.home’, ‘operation_mode’, ‘heat’)}}”
    turn_on:
    service: climate.set_operation_mode
    data:
    entity_id: climate.home
    operation_mode: ‘heat’
    turn_off:
    service: climate.set_operation_mode
    data:
    entity_id: climate.home
    operation_mode: ‘off’

Great! sorry for all the run around. Lesson learned, test before posting.