Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass changed temperature to set_temperature script #48

Open
Garulf opened this issue Aug 2, 2023 · 3 comments
Open

Can't pass changed temperature to set_temperature script #48

Garulf opened this issue Aug 2, 2023 · 3 comments

Comments

@Garulf
Copy link

Garulf commented Aug 2, 2023

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.

@CDeLeon94
Copy link

Removing the target_temperature_template was necessary for me to get things working. It appears its an either or situation (Reading state from the template or setting & syncing via the set_temperature action)

@devildant
Copy link

devildant commented Oct 19, 2023

I thought of a workaround, with an intermediate input number, and 1 automation

in configuration.yaml:

input_number:
  your_input_name:
    name: your_input_name
    min: 16
    max: 31
    step: 1

inside the set_temperature section inside your impl of climate_template

set_temperature:
      - condition: or
        conditions:
        - condition: numeric_state
          entity_id: climate.your_climate_template_entity_id
          attribute: temperature
          above: input_number.your_input_name
        - condition: numeric_state
          entity_id: climate.your_climate_template_entity_id
          attribute: temperature
          below: input_number.your_input_name
      - your action....

and for automation:
for update the transitive input (input_number.your_input_name) and your climate_template (your_input_name) with reference target temperature (number.target_temperature_template_entityid)

alias: Update-Transitive-Input-And-Climate
description: ""
trigger:
  - platform: state
    entity_id:
      - number.target_temperature_template_entityid
    attribute: raw_state
condition: []
action:
  - service: input_number.set_value
    data:
      value: >-
        {{ states('number.target_temperature_template_entityid')  | int
        / 10 | int }}
    target:
      entity_id: input_number.your_input_name
    enabled: true
  - service: climate.set_temperature
    data:
      temperature: >-
        {{ state_attr('number.target_temperature_template_entityid',
        'raw_state')  |  float }}
    target:
      entity_id: climate.your_climate_template_entity_id
    enabled: true
mode: parallel
max: 10

@scuba75
Copy link
Contributor

scuba75 commented Nov 22, 2023

this all works correctly for me

- platform: climate_template
  name: Virtual AC
  unique_id: test_virtual_ac
  min_temp: 60
  max_temp: 90
  modes:
    - "off"
    - auto
    - cool
    - heat
    - fan_only
  fan_modes:
    - auto
    - low
    - medium
    - high
  current_temperature_template: "{{ int(states('sensor.della_virtual_tempurature'), 77) }}"
  target_temperature_template: "{{ states('input_number.virtual_ac_target_temp') }}"
  hvac_mode_template: >
    {% if is_state('input_boolean.virtual_ac_power_switch', 'on') %}
      {% if is_state('input_select.virtual_ac_mode_switch', 'cold') %}
      cool
      {% elif is_state('input_select.virtual_ac_mode_switch', 'hot') %}
      heat
      {% elif is_state('input_select.virtual_ac_mode_switch', 'fan') %}
      fan_only
      {% elif is_state('input_select.virtual_ac_mode_switch', 'auto') %}
      auto
      {% endif %}
    {% else %}
    "off"
    {% endif %}
  set_temperature:
    - service: input_number.set_value
      data:
        value: "{{ temperature }}"
      target:
        entity_id: input_number.virtual_ac_target_temp

the input_number

virtual_ac_target_temp:
  name: Virtual AC target temp
  min: 60
  max: 90
  step: 1
  unit_of_measurement: F

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants