Giter VIP home page Giter VIP logo

hass-template-climate's Introduction

❄️ Template Climate

HACS Badge License Latest Release Size Code style

The climate_template platform creates climate devices that combine integrations and provides the ability to run scripts or invoke services for each of the set_* commands of a climate entity.

Configuration

All configuration variables are optional. The climate device will work in optimistic mode (assumed state) if a template isn't defined.

If you do not define a template or its corresponding action the climate device will not have that attribute, e.g. either swing_mode_template or set_swing_mode must be defined for the climate to have a swing mode.

Name Type Description Default Value
name string The name of the climate device. "Template Climate"
unique_id string The unique id of the climate entity. None
icon_template template Defines a template for the icon of the sensor.
entity_picture_template template Defines a template for the entity picture of the sensor.
availability_template template Defines a template to get the available state of the component. If the template returns true, the device is available. If the template returns any other value, the device will be unavailable. If availability_template is not configured, the component will always be available. true
current_temperature_template template Defines a template to get the current temperature.
current_humidity_template template Defines a template to get the current humidity.
target_temperature_template template Defines a template to get the target temperature of the climate device.
target_temperature_high_template template Defines a template to get the target temperature high of the climate device.
target_temperature_low_template template Defines a template to get the target temperature low of the climate device.
hvac_mode_template template Defines a template to get the hvac mode of the climate device.
fan_mode_template template Defines a template to get the fan mode of the climate device.
swing_mode_template template Defines a template to get the swing mode of the climate device.
hvac_action_template template Defines a template to get the hvac action of the climate device.
set_temperature action Defines an action to run when the climate device is given the set temperature command. Can use temperature, target_temp_high, target_temp_low and hvac_mode variables.
set_hvac_mode action Defines an action to run when the climate device is given the set hvac mode command. Can use hvac_mode variable.
set_fan_mode action Defines an action to run when the climate device is given the set fan mode command. Can use fan_mode variable.
set_swing_mode action Defines an action to run when the climate device is given the set swing mode command. Can use swing_mode variable.
modes list A list of supported hvac modes. Needs to be a subset of the default values. ["auto", "off", "cool", "heat", "dry", "fan_only"]
fan_modes list A list of supported fan modes. ["auto", "low", "medium", "high"]
swing_modes list A list of supported swing modes. ["on", "off"]
min_temp float Minimum set point available. 7
max_temp float Maximum set point available. 35
precision float The desired precision for this device. 0.1 for Celsius and 1.0 for Fahrenheit.
temp_step float Step size for temperature set point. 1

Example Configuration

climate:
  - platform: climate_template
    name: Bedroom Aircon
    modes:
      - "auto"
      - "dry"
      - "off"
      - "cool"
      - "fan_only"
    min_temp: 16
    max_temp: 30

    # get current temp.
    current_temperature_template: "{{ states('sensor.bedroom_temperature') }}"

    # get current humidity.
    current_humidity_template: "{{ states('sensor.bedroom_humidity') }}"

    # swing mode switch for UI.
    swing_mode_template: "{{ states('input_boolean.bedroom_swing_mode') }}"

    # available based on esphome nodes' availability.
    availability_template: "{{ is_state('binary_sensor.bedroom_node_status', 'on') }}"

    # example action
    set_hvac_mode:
      # allows me to disable sending commands to aircon via UI.
      - condition: state
        entity_id: input_boolean.enable_aircon_controller
        state: "on"

      # send the climates current state to esphome.
      - service: esphome.bedroom_node_aircon_state
        data:
          temperature: "{{ state_attr('climate.bedroom_aircon', 'temperature') | int }}"
          operation_mode: "{{ states('climate.bedroom_aircon') }}"
          fan_mode: "{{ state_attr('climate.bedroom_aircon', 'fan_mode') }}"
          swing_mode: "{{ is_state_attr('climate.bedroom_aircon', 'swing_mode', 'on') }}"
          light: "{{ is_state('light.bedroom_aircon_light', 'on') }}"

      # could also send IR command via broadlink service calls etc.

Example action to control existing Home Assistant devices

climate:
  - platform: climate_template
    # ...
    set_hvac_mode:
      # allows you to control an existing Home Assistant HVAC device
      - service: climate.set_hvac_mode
        data:
          entity_id: climate.bedroom_ac_nottemplate
          hvac_mode: "{{ states('climate.bedroom_ac_template') }}"

Use Cases

  • Merge multiple components into one climate device (just like any template platform).
  • Control optimistic climate devices such as IR aircons via service calls.

hass-template-climate's People

Contributors

dext0r avatar jcwillox avatar johlc avatar laszlojakab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hass-template-climate's Issues

Target Temperature is never displayed and can't be set, also fan modes are not displayed

The problem

Hi,

I was really be thrilled to find your virtual climate package unfortunately it does not work as expects.
this is my config

- platform: climate_template
    name: Klima Wohnzimmer
    unique_id: 8f58e31a-2df2-4399-91f4-8430849fe8c2
    modes:
      - "auto"
      - "heat"
      - "dry"
      - "off"
      - "cool"
      - "fan_only"
    fan_modes:
      - "auto"
      - "low"
      - "medium"
      - "high"
    min_temp: 16
    max_temp: 30

    # get current temp.
    current_temperature_template: "{{ states('sensor.temp_wohnzimmer_temperature') }}"


    # get current humidity.
    current_humidity_template: "{{ states('sensor.temp_wohnzimmer_humidity') }}"

But on my dashboard I only see:

image
image

and if I try to change the temperature I get an error.
In the attributes I only see:
image

I would like to use the component inside another automation that only queries the states of this attributes, but unfortunately it doesn't work.

What version of Template Climate has the issue?

No response

What version of Home Assistant are you running?

No response

What type of installation are you running?

Home Assistant OS

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

[FR]: Make possible to reload entities by reloading yaml

Is your feature request related to a problem? Please describe.

If it is possible, make possible to reload entities by reloading yaml instead of having to restart supervisor every time

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

climate always unavailable

Hi,

I tried to configure my own climate, everything works, except that the climate is always unavailable:
homeassistant_8123_developer-tools_state

I am using HA 2021.8.4

The availability_template is True
homeassistant_8123_developer-tools_template

(maybe there is a typo in you doc, isn't it upper case --> True?)
github com_jcwillox_hass-template-climate

the config:

- platform: climate_template # https://github.com/jcwillox/hass-template-climate
  name: nilan_compact_p
  modes:
    - "auto"
    - "off"
    - "heat"
    - "cool"
  fan_modes:
    - "Stufe0"
    - "Stufe1"
    - "Stufe2"
    - "Stufe3"
    - "Stufe4"
  min_temp: 16
  max_temp: 25
  precision: 0.1
  temp_step: 1
  # get current temp.
  current_temperature_template: "{{ states('sensor.nilan_temperature_controller') }}"  
  # get current humidity.
  current_humidity_template: "{{ states('sensor.nilan_humidity') }}"
  # available based on esphome nodes' availability.
  availability_template: "{{ not is_state('sensor.nilan_air_mode', 'unavailable') }}"
  #Alternative: {% if states('sensor.nilan_air_mode') == 'unavailable' %}false{% else %}True{% endif %}
  #fan_mode_template: "{% if states('sensor.nilan_vent_set') == '0' %}Stufe0{% elif states('sensor.nilan_vent_set') == '1' %}Stufe1{% elif states('sensor.nilan_vent_set') == '2' %}Stufe2{% elif states('sensor.nilan_vent_set') == '3' %}Stufe3{% elif states('sensor.nilan_vent_set') == '4' %}Stufe4{% endif %}"
  # Example Action. /// hier geht es weiter
  icon_template: "{{'mdi:home-thermometer-outline'}}"
  set_hvac_mode:
    # send the climates current state to esphome.
    - service: modbus.write_register
      data:
        hub: nilan
        unit: 30
        address: 1003
        value: >
          {% if fan_mode == 'Stufe0' %}
            [0, 0]
          {% elif fan_mode == 'Stufe1' %}
            [1, 0]
          {% elif fan_mode == 'Stufe2' %}
            [2, 0]
          {% elif fan_mode == 'Stufe3' %}
            [3, 0]
          {% elif fan_mode == 'Stufe4' %}
            [4, 0]
          {% endif %}
  set_temperature:
    - service: modbus.write_register
      data:
        hub: nilan
        unit: 30
        address: 1003
        value: >
          {% if fan_mode == 'Stufe0' %}
            [0, 0]
          {% elif fan_mode == 'Stufe1' %}
            [1, 0]
          {% elif fan_mode == 'Stufe2' %}
            [2, 0]
          {% elif fan_mode == 'Stufe3' %}
            [3, 0]
          {% elif fan_mode == 'Stufe4' %}
            [4, 0]
          {% endif %}
  set_fan_mode:
    - service: modbus.write_register
      data:
        hub: nilan
        unit: 30
        address: 1003
        value: >
          {% if fan_mode == 'Stufe0' %}
            [0, 0]
          {% elif fan_mode == 'Stufe1' %}
            [1, 0]
          {% elif fan_mode == 'Stufe2' %}
            [2, 0]
          {% elif fan_mode == 'Stufe3' %}
            [3, 0]
          {% elif fan_mode == 'Stufe4' %}
            [4, 0]
          {% endif %}

Hint: I did'nt set up the set_temperature & set_hvac_mode so far so I just copied the fan code...
The fan_mode_template doesn't work either, but I will look into that after solving the unavailable issue...

Thanks for any hints,

Sebastian

`None` `hvac_action` should be allowed

The problem

The None value is a valid hvac_action but the integration does not allow it. See the default value of hvac_action in developer docs:

https://developers.home-assistant.io/docs/core/entity/climate/#properties

What version of Template Climate has the issue?

No response

What version of Home Assistant are you running?

No response

What type of installation are you running?

None

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Add support for heat_cool mode

Hello,

I am attempting to use your integration to merge together the HomeKit Controller based integration and the Ecobee integration for my thermostats to work around some issues with the buggy HomeKit implementation in Ecobee thermostats.

One thing I have run into is the lack of support for the heat_cool HVAC mode along with it's associated target_temp_high and target_temp_low attributes.

Any chance these could be added?

Wrong fan mode

Climate template is expecting wrong values for Fan mode. My fan modes are defined as:
fan_modes:
- "auto"
- "low"
- "medium"
- "high"
fan_mode_template: "{{ state_attr('sensor.term3', 'Fan') }}"

fan_mode_template shows a correct value in template editor. However the logs indicate that these are wrong values and it expects off, heat and cool:

[custom_components.climate_template.climate] Received invalid fan mode: High. Expected: ['off', 'cool', 'heat'].

set_fan_mode action does work and changes the fan mode as requested, but it doesn't show the requested value in the card. No matter which mode I press, it changes the mode on the device, but the change is not reflected in the card.

hvac action template

Hi to everyone,

I tried to set the hvac action template in order to have the current status of the entity, but i does not work, thi is the template:

hvac_action_template: "{% set p = states('sensor.fancoil_cucina') | float > 0 %}
                           {% set eu = states('input_select.stagione') == 'Inverno' %}
                           {{  'HVACAction.HEATING' if p == true and eu ==true else  'HVACAction.COOLING' if p == true and eu == false else 'HVACAction.OFF' }}"

thanks for your help

target_temperature not visible

The problem

if target_temperature_template not configured, bat target_temperature_high_template and target_temperature_low_template configured, then target temperature not visible as here

I assumed that the integration would output two values of the target temperature as it is done for the integration of thermostat in ESPHome

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.5.3

What type of installation are you running?

Home Assistant Supervised

Example YAML snippet

climate:
  - platform: climate_template
    name: TRV LR
    availability_template: >
        {{ (is_state('switch.trv_lr_cool_switch', 'on') or is_state('switch.trv_lr_cool_switch', 'off')) and 
          (is_state('switch.trv_kn_cool_switch', 'on') or is_state('switch.trv_kn_cool_switch', 'off')) }}
    current_temperature_template: "{{ states('sensor.livingroom_heatindex') }}"
    current_humidity_template: "{{ states('sensor.filtered_humidity_lr') }}"
    target_temperature_high_template: "{{ states('number.trv_lr_target_temperature_high') }}"
    target_temperature_low_template: "{{ states('number.trv_lr_target_temperature_low') }}"

Anything in the logs that might be useful for us?

No response

Additional information

No response

Template loop detected while rendering hvac_action_template

The problem

I'm setting up IR controlled air conditioner, so I wanted to emulate hvac_action depending on mode and temperature. It works for a while, but when I start changing modes and temperature it stops updating, posting warning in log. After first warning it never updates hvac_ation until restart. On next changes of state/temperature it logs same warning. I'm not sure, but it seems that issue is triggering when accessing climate entity state inside template rendering. May be there is better way to get current hvac_mode and temperature ?

What version of Template Climate has the issue?

just cloned from git 28.03.2023

What version of Home Assistant are you running?

2023.4.0.dev20230328

What type of installation are you running?

Home Assistant Container

Example YAML snippet

Configuration:
climate:
  - platform: climate_template
    unique_id: kitchen_climate
    name: kitchen_climate
    current_temperature_template: "{{ states('sensor.living_room_bme280_temperature') }}"
    current_humidity_template: "{{ states('sensor.living_room_bme280_humidity') }}"
    hvac_action_template: >-
      {% set target_temp = state_attr('climate.kitchen_climate','temperature') | int %}
      {% set current_temp = states('sensor.living_room_bme280_temperature') | int %}
      {% set hvac_mode = states('climate.kitchen_climate') %}
      {% if hvac_mode == 'auto' and target_temp > current_temp %}
        heating
      {% elif hvac_mode == 'auto' and target_temp < current_temp %}
        cooling
      {% elif hvac_mode == 'auto' %}
        idle
      {% elif hvac_mode == 'heat' and target_temp > current_temp %} 
        heating
      {% elif hvac_mode == 'heat' %}
        idle
      {% elif hvac_mode == 'cool' and target_temp < current_temp %} 
        cooling
      {% elif hvac_mode == 'cool' %}
        idle
      {% elif hvac_mode == 'dry' %}
        drying
      {% elif hvac_mode == 'fan_only' %}
        fan
      {% else %} 
        off
      {% endif %}

Anything in the logs that might be useful for us?

Message in log:
WARNING (MainThread) [homeassistant.helpers.template_entity] Template loop detected while processing event: <Event state_changed[L]: entity_id=climate.kitchen_climate, old_state=<state climate.kitchen_climate=heat; hvac_modes=['auto', 'cool', 'heat', 'dry', 'fan_only', 'off'], min_temp=16.0, max_temp=30.0, target_temp_step=1.0, fan_modes=['auto', 'low', 'medium', 'high'], current_temperature=26.9, temperature=25.0, current_humidity=23.0, fan_mode=high, hvac_action=idle, friendly_name=kitchen_climate, supported_features=ClimateEntityFeature.FAN_MODE|TARGET_TEMPERATURE @ 2023-03-28T12:42:27.939280+03:00>, new_state=<state climate.kitchen_climate=heat; hvac_modes=['auto', 'cool', 'heat', 'dry', 'fan_only', 'off'], min_temp=16.0, max_temp=30.0, target_temp_step=1.0, fan_modes=['auto', 'low', 'medium', 'high'], current_temperature=26.9, temperature=27.0, current_humidity=23.0, fan_mode=high, hvac_action=idle, friendly_name=kitchen_climate, supported_features=ClimateEntityFeature.FAN_MODE|TARGET_TEMPERATURE @ 2023-03-28T12:42:27.939280+03:00>>, skipping template render for Template[...]

where [...] is copy of template from configuration.

Additional information

No response

[FR]: Units?

Is your feature request related to a problem? Please describe.

Is there a way to choose the unit of the climate template? I'd like to be able to switch out of Fahrenheit, to Celsius but even to a unitless variable.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

error message when updating target temperature

Hi!

I have an heat-pump which I can control via modbus. I have the following configuration:

  - platform: climate_template
    name: Circuit1
    modes:
      - "auto"
      - "heat"
      - "off"
      - "cool"
    min_temp: 20
    max_temp: 35
    # get current temp.
    current_temperature_template: "{{ states('sensor.room_air_temp_circuit1') }}"
    target_temperature_template: "{{ states('sensor.target_temp_circuit1') }}"
    set_temperature:
        - service: modbus.write_register
          data_template:
            address: 2
            slave: 1
            hub: lg_modbus
            value: "{{ state_attr('climate.circuit1', 'temperature') | int * 10 }}"

The value that I need to write to the register is an integer with the temperature times 10. So 23.0 would be 230. This works.

When I adjust the target temperature I get this error message:

Logger: homeassistant.helpers.script.circuit1
Source: helpers/script.py:1428
First occurred: 11:22:40 (1 occurrences)
Last logged: 11:22:40

Circuit1: Running script requires passing in a context

Any idea what is going on here?

Moes UFO-R11 Zigbee IR blaster setup

The problem

Does anyone know how to help me set up my air conditioner?
I have a Moes UFO-R11 Zigbee IR blaster.
Through this I learned the codes of the air conditioner remote control.
How do I set this to the smartir configuration?
Do I need to generate my own JSON file? If so how do I do it? What settings do I need to write?

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.2.3

What type of installation are you running?

Home Assistant OS

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

[Feature Request] HVAC action

Can you please add a template for HVAC action (what is the climate doing at the moment, based on the current and the target temperature: heating, cooling, idle). This would be very important for the climate card in UI Lovelace Minimalist, especially my native climate integration is not providing this and I need to use a helper entity. Thank you.

Open a Topic on Community Forum

Please, open a topic related to this integration on hte Community Forum so We can discuss about doubt and ideas with other interested people.

I managed to get it working, but It took about 2 days.

Thank you for your work!

Impossible to Sync the Template entity with the original one

If this integration is used with an already existing Climate Entity, it won't be possible to sync them properly.

For example if I turn on my Daikin AC from the Original Integration, the Templated Entity won't turn on.
Same for tthe target temperature, the fan mode, the swing mode and the hvac mode.

I tried to set those mode template with the attributes of the original Climate:

fan_mode_template: "{{ states.climate.original_entity.attributes.temperature }}"

But doing like the above example, will cause issue when I try to change the temperature itself because it will be fixed to the original entity.

Log Errors: Running script requires passing in a context // Thermostat: Already running

The problem

I am using climate_template to create virtual room thermostat along with a input_number that is the delta set temp between my room and my home (main) thermostat.
For example, home is set at 20 degrees and bedroom at 19.5, delta is -0.5 in heating mode and +0.5 in cooling mode). I can then use that virtual thermostat to open/close Flair vents to control the temperature for each room.

My configuration seems to be working well but I do have log errors on startup and set_temperature that I'd like to understand and fix. Any help is appreciated here, I understand this is most probably a mistake on my side but I cannot figure it out. Thank you!

The log error on startup (on for each climate_template):

Logger: homeassistant.helpers.script.mock_room_thermostat
Source: helpers/script.py:1439
First occurred: 11:40:21 AM (1 occurrences)
Last logged: 11:40:21 AM
Mock Room Thermostat: Running script requires passing in a context

The error on set temperature:

Logger: homeassistant.helpers.script.mock_room_thermostat
Source: helpers/script.py:1453
First occurred: 11:45:38 AM (4 occurrences)
Last logged: 11:45:54 AM
Mock Room Thermostat: Already running

What version of Template Climate has the issue?

0.6.0

What version of Home Assistant are you running?

Home Assistant 2022.11.4 Supervisor 2022.11.2 Operating System 9.3 Frontend 20221108.0 - latest

What type of installation are you running?

Home Assistant OS

Example YAML snippet

input_number:
    # +1 means +1 degree in heat mode and -1 degree in cool mode
    mock_room_flair_temp_delta:
      name: "Mock Room Temperature Delta"
      min: -1.5
      max: +1.5
      step: .5

  sensor:
    - platform: template
      sensors:
        mock_room_flair_target_temperature:
          unique_id: mock_room_flair_target_temperature
          device_class: temperature
          friendly_name: Mock Room target temperature
          unit_of_measurement: '°C'
          value_template: >
            {% set mock_room_main_thermostat_temp = float(state_attr('climate.mock_main_thermostat', 'temperature'), -100) %}
            {% set mock_room_flair_temp_delta_temp = float(states('input_number.mock_room_flair_temp_delta'), -100) %}
            {% if mock_room_main_thermostat_temp == -100 or mock_room_flair_temp_delta_temp == -100  %}
              {{ mock_room_main_thermostat_temp }}
            {% else %}
              {% if states('climate.mock_main_thermostat') == 'heat'  %}
                {{ mock_room_main_thermostat_temp + mock_room_flair_temp_delta_temp }}
              {% elif states('climate.mock_main_thermostat') == 'cool' %}
                {{ mock_room_main_thermostat_temp - mock_room_flair_temp_delta_temp }}
              {% else %}
                {{ mock_room_main_thermostat_temp }}
                {% endif %}
              {% endif %}

  climate:
    - platform: climate_template
      unique_id: mock_room_thermostat
      name: "Mock Room Thermostat"
      modes:
        # - "heat_cool"
        - "heat"
        - "cool" 
        - "off"
      min_temp: 18
      max_temp: 26
      hvac_mode_template: "{{ states('climate.mock_main_thermostat') }}"
      current_temperature_template: "{{ states('sensor.mock_room_flair_current_temperature') }}"
      target_temperature_template: "{{ float(states('sensor.mock_room_flair_target_temperature'), -100) }}"
      availability_template: "{{ 'heat' == states('climate.mock_main_thermostat') or 'cool' == states('climate.mock_main_thermostat') }}"
      hvac_action_template: "{{ state_attr('climate.128_lansdbee', 'hvac_action') }}"
      set_temperature:
        - service: input_number.set_value
          data:
            value: >
              {% set mock_room_main_thermostat_temp = float(state_attr('climate.mock_main_thermostat', 'temperature'), -100) %}
              {% set mock_room_flair_temp_delta = float(states('input_number.mock_room_flair_temp_delta'), -100) %}
              {% if mock_room_main_thermostat_temp == -100 or mock_room_main_thermostat_temp == -100 %}
                {{ mock_room_flair_temp_delta }}
              {% else %}
                {% if 'heat' == states('climate.mock_main_thermostat') %}
                  {{ temperature - mock_room_main_thermostat_temp }}
                {% elif 'cool' == states('climate.mock_main_thermostat') %}
                  {{ mock_room_main_thermostat_temp - temperature }}
                {% else %}
                  {{ mock_room_flair_temp_delta }}
                {% endif %}
              {% endif %}
          target:
            entity_id: input_number.mock_room_flair_temp_delta

Anything in the logs that might be useful for us?

No response

Additional information

No response

[FR]: Add the self referencing this variable to the component

Is your feature request related to a problem? Please describe.

self referencing makes it easier to reuse the template code

Describe the solution you'd like

add this variable

Describe alternatives you've considered

No response

Additional context

this is an example on how I would like to use the "this" variable.


  homeassistant:
    customize:
      package.node_anchors:
        common: &common
          package: template_thermostats
        <<: &config_general
  
          modes:
            - "auto"
            - "heat"
            - "off"
          min_temp: 5
          max_temp: 30

          # get current temp.
          current_temperature_template: >
            {% set entity = this.entity_id | regex_replace('_template', '') %}

            {{ state_attr(entity,'current_temperature')|float(0) }}
            
          # get target temp
          target_temperature_template: >
            {% set entity = this.entity_id | regex_replace('_template', '') %}

            {{ state_attr(entity,'temperature')|float(0) }}

          # set target temp
          set_temperature:
          - service: climate.set_temperature
            data:
              temperature: "{{ temperature | float(0) }}"
            target:
              entity_id: >
                {% set entity = this.entity_id | regex_replace('_template', '') %}
                {{ entity }}

          # set target temp
          set_hvac_mode:
          - variables:
              automation_id: >
                {% set room = this.entity_id | regex_replace('climate.thermostat_|_template', '') %}

                automation.{{room}}_heizung_automatik
              entity_id: >
                {% set entity = this.entity_id | regex_replace('_template', '') %}
                {{ entity }}
          - alias: "choose mode"
            choose:
            - conditions: "{{ hvac_mode == 'auto' }}"
              sequence:
              - service: automation.turn_on
                target:
                  entity_id: "{{ automation_id }}"
              - service: automation.trigger
                target:
                  entity_id: "{{ automation_id }}"
            - conditions: "{{ hvac_mode == 'heat' }}"
              sequence:
              - service: automation.turn_off
                target:
                  entity_id: "{{ automation_id }}"
            default:
              - service: automation.turn_off
                target:
                  entity_id: "{{ automation_id }}"
              - service: climate.set_temperature
                target:
                  entity_id: "{{ entity_id }}"
                data:
                  temperature: 5

          availability_template: >
            {% set entity = this.entity_id | regex_replace('_template', '') %}
            {{ states(entity) not in ['unavailable'] }}

          target_temperature_high_template: >
            {% set entity = this.entity_id | regex_replace('_template', '') %}
            {{ state_attr(entity,'max_temp') }}

          target_temperature_low_template: >
            {% set entity = this.entity_id | regex_replace('_template', '') %}
            {{ state_attr(entity,'min_temp') }}
          
          temp_step: 0.5


  climate:

  - platform: climate_template
    name: Thermostat Flur Oben Template
    unique_id: ad143f13-699d-4f5c-84ce-6fc0c5b9c192
    <<: *config_general

  - platform: climate_template
    name: Thermostat Wohnzimmer Template
    unique_id: fdd7ebd6-8ab6-4c85-bdc1-47efd5149ba7
    <<: *config_general

Cant set Target temp low and Target temp high with thermostat entity when in heat/cool mode

The problem

climate:
  - platform: climate_template
    name: Test Thermostat
    unique_id: 76c49564-3347-4a48-8732-cf88ee6729ff
    modes:
      - "auto"
      - "heat"
      - "cool"
      - "heat_cool"
      - "fan_only"
      - "off"
    min_temp: 60
    max_temp: 80

    current_temperature_template: "{{ states('sensor.living_room_temperature_temperature') }}"
    current_humidity_template: "{{ states('sensor.living_room_temperature_humidity') }}"

    set_temperature:
      - service: input_number.set_value
        data:
          entity_id: input_number.virtual_target_temperature
          value: "{{ state_attr('climate.test_thermostat', 'temperature') | float(0) }}"
      - service: input_number.set_value
        data:
          entity_id: input_number.virtual_target_temp_high
          value: "{{ state_attr('climate.test_thermostat', 'target_temp_high') | float(0) }}"
      - service: input_number.set_value
        data:
          entity_id: input_number.virtual_target_temp_low
          value: "{{ state_attr('climate.test_thermostat', 'target_temp_low') | float(0) }}"

This is currently my code, it will work to set a single target temperature, however it does not show a range to set like it should with heat/cool or auto mode enabled.

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.11.6

What type of installation are you running?

Home Assistant Supervised

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Can't pass changed temperature to set_temperature script

The problem

When climate entity is changed it should pass the changed temperature to the set_temperature script.

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.7.3

What type of installation are you running?

Home Assistant Core

Example YAML snippet

climate:
  - platform: climate_template
    name: Ember Mug White
    modes:
      - heat
    current_temperature_template: "{{ states('sensor.ember_mug_dff1840ca9b3_current_temp') }}"
    target_temperature_template: "{{ states('number.ember_mug_dff1840ca9b3_target_temp') }}"
    min_temp: 120
    max_temp: 145
    set_temperature:
      - service: number.set_value
        data:
          value: "{{ temperature }}"
        target:
          entity_id: number.ember_mug_dff1840ca9b3_target_temp

Anything in the logs that might be useful for us?

N/A

Additional information

image

I assume the "128" would be passed, but instead 145 is passed to the set_temperature script.

[FR]: Example of hvac_action_template

Is your feature request related to a problem? Please describe.

Some more examples could probably help out how the integration is working

Describe the solution you'd like

So I have a floor temperature system that is controlled using a shelly plug and an external temperture sensor. I want to add some more feeling that this is actually a thermostat. I have tried some examples but can't really figure it out so I need some help. So right now I can see the current temp, my target temp. I have even solved that if I switch my shelly plug on the climate control says "heating". What I want now is to be able to control the shelly plug from the climate control and I guess I need to use the hvac_action_template but I can't figure out how to do it. So choosing off in climate I of course want to send switch.off and choosing "heat" a switch command switch.on. Here is my yaml so far, I understand I miss the action part but how to do that?

`- platform: climate_template
name: floortemperature
min_temp: 15
max_temp: 30
temp_step: 1
modes:
- "off"
- "heat"

current_temperature_template: "{{ states('sensor.current_temperature') }}"
target_temperature_template: "{{ states('input_number.target_temperature') }}"
hvac_mode_template: >
{% if is_state('switch.shelly_shplg_s_80646f83b61e', 'on') %}
heat
{% else %}
off
{% endif %}

set_temperature:
service: input_number.set_value
target:
entity_id: input_number.target_temperature
data:
value: "{{ temperature }}"`

Describe alternatives you've considered

No response

Additional context

No response

Error "running script requires passing in a context" | Fancoil Modbus Integration

The problem

Hello,

I have fancoil wired in a modbus rs485 serial network. I want to use hass-template-climate component because i have to do math with some modbus registers and the standard modbus climate component doesn't allow to do that and also lack of the fan_mode functionality.

I have set all as in the .yaml attached. all readings are fine but when I try to execute an action like 'set_temperature', 'set_hvac_mode' or 'set_fan_mode' nothing happen and the value is restored to the original one. I have tried to execute the service 'modbus.write_register' on the 'developer tools' tab and all of them work. In the log I see "running script requires passing in a context"

What's going on? How can I fix this?

Thanks

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.5.4

What type of installation are you running?

Home Assistant OS

Example YAML snippet

# FANCOIL SOGGIORNO - CLIMATE TEMPLATE
# ------------------------------------


- platform: climate_template
  name: Soggiorno
  unique_id: v1_climate_template
  min_temp: 16
  max_temp: 28
  precision: 0.1
  temp_step: 0.5
  swing_modes:
    - "on"
    - "off"
  modes:
    - "heat"
    - "cool"
  fan_modes:
    - "auto"
    - "low"
    - "medium"
    - "high"

  availability_template: "{{is_state('binary_sensor.fc_soggiorno_com_err','off')}}"

  current_temperature_template: "{{states('sensor.fc_soggiorno_t1')}}"
  target_temperature_template: "{{states('sensor.fc_soggiorno_sp')}}"

  swing_mode_template: "{{iif(is_state('binary_sensor.fc_soggiorno_stdby','off'), 'on', 'off')}}"

  hvac_mode_template: "{{iif(is_state('sensor.fc_soggiorno_man','3'), 'heat', 'cool')}}"

  hvac_action_template: >
    {% if is_state('binary_sensor.fc_soggiorno_mod_raff','on') %}
    heating
    {% elif is_state('binary_sensor.fc_soggiorno_mod_risc','on') %}
    cooling
    {% else %}
    idle
    {% endif %}

  fan_mode_template: >
    {% if is_state('binary_sensor.fc_soggiorno_mod_auto','on') %}
    auto
    {% elif is_state('binary_sensor.fc_soggiorno_mod_notte','on') %}
    low
    {% elif is_state('binary_sensor.fc_soggiorno_mod_min','on') %}
    medium
    {% else %}
    max
    {% endif %}


  set_temperature:
    - service: modbus.write_register
      data:
        hub: fancoil_hub
        slave: 2
        address: 231
        value: "{{ state_attr('climate.soggiorno', 'temperature') | int * 10}}"

  set_hvac_mode:
    - service: modbus.write_register
      data:
        hub: fancoil_hub
        slave: 2
        address: 233
        value: "{{iif(is_state('climate.soggiorno','heat'), 3, 5) | int }}"

  set_fan_mode:
    - service: modbus.write_register
      data:
        hub: fancoil_hub
        slave: 2
        address: 201
        value: >
          {% if is_state_attr('climate.soggiorno','fan_mode', 'auto') %}
          {{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65528) }}
          {% elif is_state_attr('climate.soggiorno','fan_mode', 'low') %}
          {{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65530) | bitwise_or(2) }}
          {% elif is_state_attr('climate.soggiorno','fan_mode', 'medium') %}
          {{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65529) | bitwise_or(1) }}
          {% else %}
          {{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65531) | bitwise_or(3) }}
          {% endif %}

  set_swing_mode:
    - service: modbus.write_register
      data:
        hub: fancoil_hub
        slave: 2
        address: 201
        value: >
          {% if is_state_attr('climate.soggiorno','swing_mode', 'on') %}
          {{ states('sensor.fc_soggiorno_prg') | int | bitwise_or(128) }}
          {% else %}
          {{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65407) }}
          {% endif %}

Anything in the logs that might be useful for us?

2023-05-29 01:31:00.709 WARNING (MainThread) [homeassistant.helpers.script.soggiorno] Soggiorno: Running script requires passing in a context

Additional information

No response

set_temperature action does not work

The problem

This is my config:

climate:
  - platform: climate_template
    unique_id: 76c49564-3347-4a48-8732-cf88ee6729ff
    name: Diesel Heater

    min_temp: 5
    max_temp: 30

    # get current temp.
    current_temperature_template: "{{ states('sensor.temperature_inside') }}"

    # get current humidity.
    current_humidity_template: "{{ states('sensor.humidity_inside') }}"

    # get target temperature.
    target_temperature_template: "{{ states('input_number.dieselheatertemperature') }}"

    set_temperature:
      service: input_number.set_value
      data:
        entity_id: input_number.dieselheatertemperature
        value: "{{ temperature }}"

Whenever I change the target temperature in the frontend, I get the following error:

Logger: homeassistant.helpers.script.diesel_heater
Source: helpers/script.py:1783
First occurred: 21:37:59 (17 occurrences)
Last logged: 22:06:45

Diesel Heater: Error executing script. Invalid data for call_service at pos 1: must contain at least one of entity_id, device_id, area_id.

Does anybody know, why? Thanks in advance :)

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.12.3

What type of installation are you running?

Home Assistant OS

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Set_temperature error

The problem

Hi guys,

when i try to call set_temperature home assistant return this error... but to mee seems same code of example... where i wrong?

What version of Template Climate has the issue?

0.6.0

What version of Home Assistant are you running?

2023.1.6

What type of installation are you running?

Home Assistant Container

Example YAML snippet

climate:
  - platform: climate_template
    name: test climate
    modes:
      - "off"
      - "heat_cool"
    min_temp: 16
    max_temp: 30
    temp_step: 0.5
    current_temperature_template: "{{ states('sensor.testairz') }}"
    set_temperature:
      - service: pyscript.hvac_setlocal
        data:
          temperature: "{{ state_attr('climate.test_climate', 'temperature') | int }}"

Anything in the logs that might be useful for us?

Error rendering data template: ValueError: Template error: int got invalid input 'None' when rendering template '{{ state_attr('climate.test_climate', 'temperature') | int }}' but no default was specified

Additional information

This what HA return in developer section:
hvac_modes:

  • 'off'
  • heat_cool
    min_temp: 16
    max_temp: 30
    target_temp_step: 1
    current_temperature: 22
    target_temp_high: null
    target_temp_low: null
    friendly_name: test climate
    supported_features: 2

Seems missing temperature and hvac_mode variables

Setup failed for custom integration climate_template: No setup or config entry setup function defined.

I'm a green hand,how can I fix it ? please someone help me.

here is my config:

# 自定义空调组件
climate_template: 
climate:
  - platform: climate_template
    name: 主卧空调
    icon_template: mdi:air-conditioner
    modes:
      - "off"
      - "cool"
      - "heat"
      - "dry"
      - "fan_only"
      - "auto"
    min_temp: 16
    max_temp: 31
    temp_step: 0.5
    # ----- get ------ #
    # 获取当前室内温度, 示例:current_temperature_template: "{{ states('sensor.bedroom_temperature') }}"
    # current_temperature_template: 28
    # 获取当前室内湿度, 示例:current_humidity_template: "{{ states('sensor.bedroom_humidity') }}"
    # 获取空调设定温度
    target_temperature_template: "{{ states('input_number.zhu_wo_kong_diao_wen_du') }}"
    # target_temperature_high_template: 31
    # target_temperature_low_template: 16
    hvac_mode_template: "{{ states('input_select.zhu_wo_kong_diao_she_ding_mo_shi') }}"
    fan_mode_template: "{{ states('input_select.zhu_wo_kong_diao_she_ding_feng_su') }}"
    # ----- set ------ #
    # 设定模式
    set_hvac_mode:
      - service: input_select.select_option
        data:
          entity_id: input_select.zhu_wo_kong_diao_she_ding_mo_shi
          option: "{{ states('climate.zhu_wo_kong_diao') }}"
    # 设定温度
    set_temperature:
      - service: input_number.set_value
        data:
          entity_id: input_number.zhu_wo_kong_diao_she_ding_wen_du
          value: "{{ state_attr('climate.zhu_wo_kong_diao', 'temperature') | float }}"
    # 设定风速
    set_fan_mode:
      - service: input_select.select_option
        data:
          entity_id: input_select.zhu_wo_kong_diao_she_ding_feng_su
          option: "{{ state_attr('climate.zhu_wo_kong_diao', 'fan_mode') }}"

[FR]: `is_heating_template`

Is your feature request related to a problem? Please describe.

I would like to see if my external thermostat is heating in a nice graph like this:

https://community-assets.home-assistant.io/original/3X/6/b/6b9088b009e10efae7444b7851753d59f7954576.png

Describe the solution you'd like

Implement an is_heating_template so I can tell this template when the thermostat is actually heating

Describe alternatives you've considered

No response

Additional context

I have no interest in controlling the thermostat. I just want the nice graphs for monitoring 🙂

Entity state is always "Off" even though all controls work as expected

The problem

For some reason, the state of the entity is perpetually "Off", even when I successfully turn on the entity and/or change modes via the entity card. It still shows the target temperature as expected, and the currently-running mode too - it simply doesn't change state from "Off" to anything else.

This isn't a dealbreaker by any means, since I still get 90% of the functionality, it just looks v confusing on my dashboard. I'm not sure what I'm doing wrong, would love some guidance!

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.11.2

What type of installation are you running?

Home Assistant OS

Example YAML snippet

# Climate
climate:
  - platform: climate_template
    name: my AC
    unique_id: my_room_ac
    current_temperature_template: >
      {% if is_state('input_boolean.my_ac', 'on') %}
        {% set default_date = '1900-01-01T00:00:00.000000+00:00' %}
        {% set scene1 = states('scene.set_ac_cold_24') if states('scene.set_ac_cold_24') != 'unknown' else default_date %}
        {% set scene2 = states('scene.set_ac_cold_21') if states('scene.set_ac_cold_21') != 'unknown' else default_date %}
        {% set scene3 = states('scene.set_ac_cold_18') if states('scene.set_ac_cold_18') != 'unknown' else default_date %}
        {% if scene1 >= scene2 and scene1 >= scene3 %}
          24
        {% elif scene2 >= scene1 and scene2 >= scene3 %}
          21
        {% else %}
          18
        {% endif %}
      {% else %}
        off
      {% endif %}
    target_temperature_template: >
      {% if is_state('input_boolean.my_ac', 'on') %}
        {% set default_date = '1900-01-01T00:00:00.000000+00:00' %}
        {% set scene1 = states('scene.set_ac_cold_24') if states('scene.set_ac_cold_24') != 'unknown' else default_date %}
        {% set scene2 = states('scene.set_ac_cold_21') if states('scene.set_ac_cold_21') != 'unknown' else default_date %}
        {% set scene3 = states('scene.set_ac_cold_18') if states('scene.set_ac_cold_18') != 'unknown' else default_date %}
        {% if scene1 >= scene2 and scene1 >= scene3 %}
          24
        {% elif scene2 >= scene1 and scene2 >= scene3 %}
          21
        {% else %}
          18
        {% endif %}
      {% endif %}
    hvac_mode_template: >
      {% if is_state('input_boolean.my_ac', 'on') %}
        {% set default_date = '1900-01-01T00:00:00.000000+00:00' %}
        {% set scene1 = states('scene.set_ac_cold_24') if states('scene.set_ac_cold_24') != 'unknown' else default_date %}
        {% set scene2 = states('scene.set_ac_cold_21') if states('scene.set_ac_cold_21') != 'unknown' else default_date %}
        {% set scene3 = states('scene.set_ac_cold_18') if states('scene.set_ac_cold_18') != 'unknown' else default_date %}
        {% if scene1 >= scene2 and scene1 >= scene3 %}
          "fan_only"
        {% elif scene2 >= scene1 and scene2 >= scene3 %}
          "auto"
        {% else %}
          "cool"
        {% endif %}
      {% else %}
        "off"
      {% endif %}

    modes:
      - "off"
      - "cool"
      - "auto"
      - "fan_only"
    min_temp: 18
    max_temp: 24
    set_hvac_mode:
      - choose:
          - conditions:
              - condition: template
                value_template: "{{ hvac_mode == 'cool' }}"
            sequence:
              - service: input_boolean.turn_on
                entity_id: input_boolean.my_ac
              - service: scene.turn_on
                entity_id: scene.set_ac_cold_18
          - conditions:
              - condition: template
                value_template: "{{ hvac_mode == 'auto' }}"
            sequence:
              - service: input_boolean.turn_on
                entity_id: input_boolean.my_ac
              - service: scene.turn_on
                entity_id: scene.set_ac_cold_21
          - conditions:
              - condition: template
                value_template: "{{ hvac_mode == 'fan_only' }}"
            sequence:
              - service: input_boolean.turn_on
                entity_id: input_boolean.my_ac
              - service: scene.turn_on
                entity_id: scene.set_ac_cold_24
          - conditions:
              - condition: template
                value_template: "{{ hvac_mode == 'off' }}"
            sequence:
              - service: input_boolean.turn_off
                entity_id: input_boolean.my_ac
      - service: input_boolean.turn_on
        entity_id: input_boolean.my_ac

Anything in the logs that might be useful for us?

No errors in the logs, since everything except state is triggering successfully.

Additional information

Love this integration! Does a fantastic job helping me consolidate my smart plug & IR controls. I'm able to perfectly control the HVAC modes & power states of my AC via this climate entity template, barring the state issue i mentioned.

[FR]: Add unique_id

Is your feature request related to a problem? Please describe.

It is not possible to set entity_id or change other parameters from UI.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Deleted entities still remain on entity list

When an entity name is changed or deleted, this integration won't provide to erase it from HA:
2022-08-19_12-32-18_177

The entities are not marked as "not used", so it's not possible to erase them from the UI, as per the following example:
2022-08-19_12-33-48_178

[FR]: target_humidity_template and set_humidity

Is your feature request related to a problem? Please describe.

I'd like to use this wonderful template to set an hygrostat, is it possible to add the humidity parameter?
Thanks!!

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Fails after HA upgrade

Thanks for your work on this I have been looking for something like this for sometime! I got it all setup and working yesterday.

Today I updated HA to version 2022.4.0 and got a config error in my configuration.yaml related to climate.climate_template (from memory I think that is what it said). I rolled back the HA update and everything is working fine again. Unfortunately I didn't copy the error message before rolling back 😕. The message said something about 'FAN_HIGH' or maybe it was 'SPEED_HIGH' regarding fan settings either it wasn't recognised in the HA configuration. I don't use fan in my config personally it seemed to be pulling the error from the actual integrations setup.

Please support more "current" templates... :-)

Hi,

I tried your integration and I am very happy with it. I expected this to be in the HA core, but it isn't.
Great, that you made this available!

One thing I am missing are the following templates for UI:

  • target_temperature_template for the current target temperature that the device is using,
  • hvac_mode_template for the current hvac mode that the device is using,
  • hvac_action_template for the current state: heating / cooling / idle / off,
  • fan_mode_template for the current fan mode hat the device is using.

You already got the current swing mode via swing_mode_template, but the others are missing.

Why this request?
I got an device that can be configured via it's own panel and if it is set to off or another mode there or when the target temperature is changed, the HA mode / temperature doesn't reflect that.

new example with the new stuff:

climate:
  - platform: climate_template
    name: Bedroom Aircon
    modes:
      - "auto"
      - "dry"
      - "off"
      - "cool"
      - "fan_only"
    min_temp: 16
    max_temp: 30
    
    # get current temp.
    current_temperature_template: "{{ states('sensor.bedroom_temperature') }}"  
    
    # get current humidity.
    current_humidity_template: "{{ states('sensor.bedroom_humidity') }}"

    # get current target temperature for UI. --> suggested change
    target_temperature_template: "{{ states('sensor.bedroom_target_temperature') }}"

    # get current hvac mode for UI. --> suggested change
    hvac_mode_template: "{{ states('sensor.bedroom_hvac_mode') }}"

    # get current hvac state (idle, cooling, heating, off) for UI. --> suggested change
    hvac_action_template: "{{ states('sensor.bedroom_hvac_state') }}"

    # get current fan mode for UI. --> suggested change
    fan_mode_template: "{{ states('sensor.bedroom_fan_mode') }}"
    
    # swing mode switch for UI.  --> already there!!!!!!!
    swing_mode_template: "{{ states('input_boolean.bedroom_swing_mode') }}"
    
    # available based on esphome nodes' availability.
    availability_template: "{{ is_state('binary_sensor.bedroom_node_status', 'on') }}"

    # Example Action.
    set_hvac_mode:
    
      # allows me to disable sending commands to aircon via UI.
      - condition: state  
        entity_id: input_boolean.enable_aircon_controller
        state: "on"
        
      # send the climates current state to esphome.
      - service: esphome.bedroom_node_aircon_state  
        data_template:
          temperature: "{{ state_attr('climate.bedroom_aircon', 'temperature') | int }}"
          operation_mode: "{{ states('climate.bedroom_aircon') }}"
          fan_mode: "{{ state_attr('climate.bedroom_aircon', 'fan_mode') }}"
          swing_mode: "{{ is_state_attr('climate.bedroom_aircon', 'swing_mode', 'on') }}"
          light: "{{ is_state('light.bedroom_aircon_light', 'on') }}"

Unable to see/set target temperature

The problem

If I add a climate template entity, no target temperature is displayed. Also I am unable to set a temperature via the gui.
image
image

I checked the template state_attr('climate.eg05_heizung_links', 'temperature') and the correct value is returned.

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.03.3

What type of installation are you running?

Home Assistant OS

Example YAML snippet

- platform: climate_template
  name: eg05_heizung_template
  modes:
    - "auto"
    - "heat"
    - "off"
  min_temp: 4.5
  max_temp: 30.5
  temp_step: 0.5

  # get current temp.
  current_temperature_template: "{{ states('sensor.eg05_heizung_links_actual_temperature') }}"
  target_temperature_template: "{{ state_attr('climate.eg05_heizung_links', 'temperature') }}"
  target_temperature_high_template: "{{ state_attr('climate.eg05_heizung_links', 'max_temp') }}"
  target_temperature_low_template: "{{ state_attr('climate.eg05_heizung_links', 'min_temp') }}"

Anything in the logs that might be useful for us?

No response

Additional information

No response

[FR]: set_hvac_action

Is your feature request related to a problem? Please describe.

How about extending the functionality by adding set_hvac_action (Type action), which would allow you to perform some actions within the selected HVAC mode.
For example, for TRV, we would like to be able to perform some actions when the temperature exceeds target_temperature_high_template or falls below target_temperature_low_template.

This will be useful for devices without internal logic.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

How to install this template?

The problem

Help a newbie install this template. Just copying to configuration.yaml does not work(

What version of Template Climate has the issue?

No response

What version of Home Assistant are you running?

No response

What type of installation are you running?

None

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

[ISSUE] unique_id not working, name already use

The problem

When i set name and unique_id, the final value for unique id on home assistant is name with underscore

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.10.3

What type of installation are you running?

Home Assistant OS

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

[Feature Request] Preset modes

I would use this to integrate sleep / eco / normal modes

Ref: https://developers.home-assistant.io/docs/core/entity/climate/#presets

A device can have different presets that it might want to show to the user. Common presets are "Away" or "Eco". There are a couple of built-in presets that will offer translations, but you're also allowed to add custom presets.

Name Description
ECO Device is running an energy-saving mode
AWAY Device is in away mode
BOOST Device turn all valve full up
COMFORT Device is in comfort mode
HOME Device is in home mode
SLEEP Device is prepared for sleep
ACTIVITY Device is reacting to activity (e.g. movement sensors)

How to change the target temperature when controlling the AC with an IR control

The problem

Always sends 21.0 when target temperature changes

AC template:

  - platform: climate_template
    unique_id: bedroom_air_conditioner
    name: Bedroom Air Сonditioner
    modes:
      - "heat"
      - "dry"
      - "off"
      - "cool"
      - "fan_only"
    min_temp: 16
    max_temp: 31
    temp_step: 0.5
    
    availability_template: "{{ is_state('binary_sensor.ir', 'on') }}"
    current_temperature_template: "{{ states('sensor.0x00158d00045c0ced_temperature') }}"
    current_humidity_template: "{{ states('sensor.0x00158d00045c0ced_humidity') }}"
    target_temperature_template: "{{ state_attr('climate.bedroom_air_conditioner', 'temperature') }}"
    target_temperature_low_template: "{{ state_attr('climate.bedroom_air_conditioner', 'min_temp') }}"
    target_temperature_high_template: "{{ state_attr('climate.bedroom_air_conditioner', 'max_temp') }}"
    
    set_temperature:
      - service: script.turn_on
        entity_id: script.bedroom_air_conditioner_temperature
        data:
          variables:
            temperature: "{{ state_attr('climate.bedroom_air_conditioner', 'temperature')|float }}"
    set_hvac_mode:
      - service: script.turn_on
        entity_id: script.bedroom_air_conditioner_hvac_mode
        data:
          variables:
            hvac_mode: "{{ states('climate.bedroom_air_conditioner') }}"

Script:

  bedroom_air_conditioner_temperature:
    alias: bedroom_air_conditioner_temperature
    sequence:
    - if: "{{ temperature == 16.0 }}"
      then:
      - service: remote.send_command
        entity_id: remote.xiaomi_miio_192_168_1_57
        data:
          command: "ac_16"
    - if: "{{ temperature == 16.5 }}"
      then:
      - service: remote.send_command
        entity_id: remote.xiaomi_miio_192_168_1_57
        data:
          command: "ac_16_5"

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

Home Assistant 2023.7.2
Supervisor 2023.07.1

What type of installation are you running?

supervised

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Cannot add to repository

The problem

Hi,

first of all many thanks for creating this. It looks like this would solve a lot of challenges.

Unfortunately, I'm failing to install this via HACS.

When I add the URL https://github.com/jcwillox/hass-template-climate as a custom repository I get the message:

<Theme jcwillox/hass-template-climate> Repository structure for 0.6.0 is not compliant.

What version of Template Climate has the issue?

0.6.0

What version of Home Assistant are you running?

Home Assistant 2022.11.4 Supervisor 2022.11.2 Operating System 9.3 Frontend 20221108.0 - latest

What type of installation are you running?

Home Assistant Supervised

Example YAML snippet

No response

Anything in the logs that might be useful for us?

not found anything in the logs.

Additional information

I also tried to install it manual by copying the files but I get the message that I need to manually add it to configuration.yaml and I don't know what needs to go in there.

[FR]: Target temperature step to 0.5

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

Reduce the target temperature step at 0.5 instead of 1

Describe alternatives you've considered

No response

Additional context

No response

Making a climate element

@jcwillox you wrote in your documentation that IR codes would be possible. However, I'm struggling a bit and hope to get some help.
I have a temperature sensor, a Broadlink device (IR) and an input boolean for the state based on power consumption via a smart plug. Aim is to get a simple climate element which I can see the state, put it on/off and increase or decrease the temperature.

I started making the template, but I'm stuck and need some guidance.

- platform: climate_template
  name: Bedroom Aircon
  modes:
    - "on"
    - "off"
  min_temp: 20
  max_temp: 30

  current_temperature_template: "{{ states('sensor.remote_apt_temperature') }}"

  current_humidity_template: "{{ states('sensor.remote_apt_humidity') }}"

  set_hvac_mode:
    - condition: state
      entity_id: input_boolean.apt_airco

    - service:

[FR]: Add the ability to quick reload the component

Is your feature request related to a problem? Please describe.

Reloading the whole instance for every change takes a lot of time

Describe the solution you'd like

Reload Button in Dev Settings

Describe alternatives you've considered

No response

Additional context

No response

Error while setting up climate_template platform for climate in HA 2022.2.0

Hi,

I noticed an error while setting up the entity after upgrarding HA to 2022.2.0 Here's what it throws in the log:

Logger: homeassistant.components.climate
Source: custom_components/climate_template/climate.py:127
Integration: Klimat ([documentation](https://www.home-assistant.io/integrations/climate), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+climate%22))
First occurred: 12:54:58 (1 occurrences)
Last logged: 12:54:58

Error while setting up climate_template platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/climate_template/climate.py", line 119, in async_setup_platform
    async_add_entities([TemplateClimate(hass, config)])
  File "/config/custom_components/climate_template/climate.py", line 127, in __init__
    super().__init__(
TypeError: __init__() missing 1 required positional argument: 'hass'

[FR]: initial_hvac_mode

Is your feature request related to a problem? Please describe.

When I use the climate.turn_on service, the entity always starts in heat model

Describe the solution you'd like

In my opinion, the best solution is to add the initial_hvac_mode field like the one in generic thermostat, which has perhaps the various modes but also last to reoccur with the last set state

Describe alternatives you've considered

No response

Additional context

No response

Template based on a Daikin Climate

Hello,

I'm trying to use this component in order to replicate my Daikin AC already integrated in Home Assistant.
Why? Because i temporarly need to change how it displays the "Swing Mode" and the "Fan Mode". Currently the integration call those features in a non-standard way, causing an incompatibility with Home Kit.

So, this is my code:

climate:
  - platform: climate_template
    name: Daikin Studio HomeKit
    # available based on esphome nodes' availability.
    availability_template:  >-
      {% if states('climate.daikin_studio') in ['fan_only', 'dry', 'cool', 'heat', 'heat_cool', 'off']  %}
        true
      {% else %}
        false
      {% endif %}

    # get current temp.
    current_temperature_template: "{{ states.climate.daikin_studio.attributes.current_temperature }}"

    # get current humidity.
    current_humidity_template: "{{ states('sensor.cucina_humidity_filtered') }}"

    # hvac mode switch for UI.
    hvac_mode_template: >-
      {% if states('sensor.climate.daikin_studio'), 'off' %}
        off
      {% elif states('sensor.climate.daikin_studio'), 'fan_only' %}
        fan_only
      {% elif states('sensor.climate.daikin_studio'), 'dry' %}
        dry
      {% elif states('sensor.climate.daikin_studio'), 'cool' %}
        cool
      {% elif states('sensor.climate.daikin_studio'), 'heat' %}
        heat
      {% elif states('sensor.climate.daikin_studio'), 'heat_cool' %}
        heat_cool
      {% else %}
      {% endif %}

    # swing mode switch for UI.
    swing_mode_template: >-
      {% if is_state_attr('climate.daikin_studio', 'swing_mode', 'Off') %}
        off
      {% elif is_state_attr('climate.daikin_studio', 'swing_mode', 'Vertical') %}
        on
      {% elif is_state_attr('climate.daikin_studio', 'swing_mode', 'Horizontal') %}
        on
      {% else %}
        on
      {% endif %}

    # fan mode switch for UI.
    fan_mode_template: >-
      {% if is_state_attr('climate.daikin_studio', 'fan_mode', 'Auto') %}
        auto
      {% elif is_state_attr('climate.daikin_studio', 'fan_mode', 'Silence') %}
        low
      {% elif is_state_attr('climate.daikin_studio', 'fan_mode', '1') %}
        low
      {% elif is_state_attr('climate.daikin_studio', 'fan_mode', '2') %}
        medium
      {% elif is_state_attr('climate.daikin_studio', 'fan_mode', '3') %}
        medium
      {% elif is_state_attr('climate.daikin_studio', 'fan_mode', '4') %}
        fan_high
      {% elif is_state_attr('climate.daikin_studio', 'fan_mode', '5') %}
        fan_high
      {% else %}
      {% endif %}

    # temperature select for UI.
    target_temperature_template: "{{ states.climate.daikin_studio.attributes.temperature }}"

    modes:
      - 'fan_only'
      - 'dry'
      - 'cool'
      - 'heat'
      - 'heat_cool'
      - 'off'

    min_temp: 7
    max_temp: 35

    # example action
    set_hvac_mode:

      # send the climates current state to esphome.
      - service: climate.set_hvac_mode
        data:
          entity_id: climate.daikin_studio
          hvac_mode: "{{ states('climate.daikin_studio_homekit') }}"

    set_temperature:
      - service: climate.set_temperature
        target:
          entity_id: climate.daikin_studio
        data:
          temperature: "{{ states.climate.daikin_studio_homekit.attributes.temperature }}"

Probably i'm missing something:
2022-08-17_15-21-39_175

As you can see, the two climate entities are perfectly synced, but I can't do any action.
If I chage the HVAC mode from my Climate Template, nothing happens.

What am I missing?

Thank you.

PS: is there a topic on the community forum? Didn't find it...

[Issue] Error adding entities for domain climate with platform climate_template

Hi,

I'm facing an issue with setting up my climate entity on HA 2022.7.4. The logs say it cannot be setup because of current temperature issue. Even if I setup it to a fixed value it still fails to load:

platform: climate_template
name: Klimatyzacja w pracowni
modes:
- "off"
- "dry"
- "cool"
- "fan_only"
min_temp: 18
max_temp: 32
precision: 1.0
#current_temperature_template: "{{ states('sensor.homematic_pracownia_temperature') }}"
current_temperature_template: 22
swing_mode_template: "{{ states('switch.swing') }}"

This is what Logger throws:

Logger: homeassistant.components.climate
Source: custom_components/climate_template/climate.py:216
Integration: Klimat (documentation, issues)
First occurred: 14:56:20 (2 occurrences)
Last logged: 14:56:20

Error adding entities for domain climate with platform climate_template
Error while setting up climate_template platform for climate
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 397, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 641, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 775, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/climate_template/climate.py", line 216, in async_added_to_hass
self._current_temp = float(
TypeError: float() argument must be a string or a real number, not 'NoneType'

Latest release "broke" some of my scripts. Not sure how to handle changes?

Basically latest version (0.4.1) has:

  • Ensure actions are run when templates update

That makes sense but I (and I think maybe some other user too) use this in conjunction to python scripts to manage an IR conditioner, and have those scripts working as "presets", setting each value and finally calling a service to send the final command. This in addition to that command also set in the various set_hvac, set_fan, set_temperature in this template (in order for it to work in the dashboard UI).
With the latest update it seems that every scripts now triggers a call to the IR manager for every variable set, so for example:

Script "Set cool preset" has:

  • set temperature 24
  • set hvac mode cool
  • set fan auto
  • send call to IR service

Which before latest updated worked correctly, but now sends 3-4 (not sure why it changes) commands/calls everytime.

Was wondering if there's the possibility to have a boolean value being added to the template (even opt-out) to revert to the old logic regarding triggering? Like set_values_on_update: false

I'm pretty new to home assistant and just getting my hands dirty so there might be some basic logic/trick I'm missing in setting this up in the first place.

Platform error climate.climate_template - cannot import name 'ClimateEntityFeature'

The problem

@jcwillox First of all, a special thanks to you for the contribution that you have done to make this component available to the community free of charge!
I would like to use it, and first step was to install it in my hass docker environment, by copying the files from “climate_template” to “custom_components” folder.
/docker/appdata/homeassistant/custom_components/climate_template$ ls -ltr
-rw-rw-r--+ 1 sdpeixoto docker 352 Aug 29 03:49 manifest.json
-rw-rw-r--+ 1 sdpeixoto docker 38 Aug 29 03:49 init.py
-rw-rw-r--+ 1 sdpeixoto docker 20656 Aug 29 03:49 climate.py
drwxrwxr-x+ 2 root root 4096 Oct 23 09:46 pycache

Second, I start defining my first climate device following the examples shared by you and that’s where I got struggle with it.

  • platform: climate_template
    name: "Office Fan"
    icon_template: mdi:air-conditioner
    modes:
    • "auto"
    • "off"
    • "cool"
    • "heat"
      fan_modes:
    • "auto"
    • "low"
    • "medium"
    • "high"
      min_temp: "16"
      max_temp: "24"
      precision: "0.1"
      temp_step: "1"

    get current temp.

    current_temperature_template: "{{ states('sensor.office_current_temperature') }}"

If I validate the configurations, then I’m getting the following error message:
Platform error climate.climate_template - cannot import name 'ClimateEntityFeature' from 'homeassistant.components.climate' (/usr/src/homeassistant/homeassistant/components/climate/init.py)

Do you think that I have missed something? Thanks in advance for all time that this issue may receive attention from you.

What version of Template Climate has the issue?

0.4.1

What version of Home Assistant are you running?

2022.3.7

What type of installation are you running?

Home Assistant Container

Example YAML snippet

- platform: climate_template
  name: "Office Fan"
  icon_template: mdi:air-conditioner
  modes:
    - "auto"
    - "off"
    - "cool"
    - "heat"
  fan_modes:
    - "auto"
    - "low"
    - "medium"
    - "high"
  min_temp: "16"
  max_temp: "24"
  precision: "0.1"
  temp_step: "1"
  # get current temp.
  current_temperature_template: "{{ states('sensor.office_current_temperature') }}"

Anything in the logs that might be useful for us?

Configuration invalid

Platform error climate.climate_template - cannot import name 'ClimateEntityFeature' from 'homeassistant.components.climate' (/usr/src/homeassistant/homeassistant/components/climate/__init__.py)

Additional information

No response

Component failure on recent HA 2022.4

Hi,

it's me again with new issue caused by recent HA update ;) Climate template fails to load due to some changes on built-in fan component, I guess. Take a look at the log below. I hope this will be quick fix as for the previous issue :)

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config.py", line 877, in async_process_component_config
    platform = p_integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 603, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 620, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/config/custom_components/climate_template/climate.py", line 26, in <module>
    from homeassistant.components.fan import SPEED_HIGH, SPEED_LOW, SPEED_MEDIUM
ImportError: cannot import name 'SPEED_HIGH' from 'homeassistant.components.fan' (/usr/src/homeassistant/homeassistant/components/fan/__init__.py)

Thanks
Greg

Error: "Repository structure for 0.6.1 is not compliant"

The problem

In HACS, when trying to add the Custom Repository URL, I get an error complaining that the
"Repository structure for 0.6.1 is not compliant".

Core 2024.2.2
Supervisor 2024.02.0
Operating System 11.5
Frontend 20240207.1

What version of Template Climate has the issue?

No response

What version of Home Assistant are you running?

No response

What type of installation are you running?

None

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

hvac_mode_template

The problem

Hello!

I have a climate with hvac_mode_template like so:
hvac_mode_template: "{% if is_state('sensor.th2_mode_state', 'HOT') -%}heat{%- else -%}cool{%- endif %}"
set_hvac_mode: some actions, which work otherwise

If i change sensor.th2_mode_state by other means, then the UI is updated properly.

The problem is, that if I set the hvac_mode_template template I am no longer able to change the modes on the UI (clicking the flame or snowflake icon doen't do anything)

If I omit the hvac_mode_template, clicking on the icons works again.

Is this the expected behaviour?
If so, how could I use the mode selection while providing its status from an external source?

Thanks,
M

What version of Template Climate has the issue?

0.6.1

What version of Home Assistant are you running?

2023.3.1

What type of installation are you running?

Home Assistant OS

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.