Target temperature adjustment depending on second temperature sensor

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Moin!

Sets target temperature depending on second temperature sensor. This blueprint is inspired by this blueprint Tado set offset using separate temperature sensor created by @Sanderma . Since not all thermostat devices have an configurable offset, this blueprint sets the target temperature of the thermostat device depending on a given target temperature and a second temperature sensor.

blueprint:
  name: Target temperature adjustment depending on second temperature sensor
  description: >
    Sets target temperature depending on second temperature sensor.
    This blueprint is inspired by this blueprint https://community.home-assistant.io/t/tado-set-offset-using-separate-temperature-sensor/288515
    created by Sanderma. Since not all thermostat devices have an configurable
    offset, this blueprint sets the target temperature of the thermostat device
    depending on a given target temperature and a second temperature sensor.
  domain: automation
  input:
    temperature_sensor:
      name: Temperature sensor
      description: This sensor will be used as the source.
      selector:
        entity:
          domain: sensor
          device_class: temperature
    thermostat:
      name: Thermostat
      description: The thermostat to set target temperature
      selector:
        entity:
          domain: climate
    target_temperature:
      name: Target temperature
      description: Target temperature of the thermostat
      selector:
        number:
          min: 5
          max: 30
          step: 0.5
          unit_of_measurement: "Ā°C"
      default: 21
          
variables:
  thermostat: !input thermostat
  temperature_sensor: !input temperature_sensor
  target_temperature: !input target_temperature
  actual_temperature: "{{ states(temperature_sensor) | float }}"
  calculated_adjustment: "{{ target_temperature - actual_temperature }}"
  calculated_target_temperature: "{{ ( ( ( target_temperature + calculated_adjustment ) * 2 ) | round ) / 2 }}"

trigger:
- platform: state
  entity_id: !input thermostat
  attribute: "{{ current_temperature_attribute }}"
- platform: state
  entity_id: !input temperature_sensor
  
condition: "{{ calculated_adjustment != 0 }}"

action:
- service: system_log.write
  data:
    message: >
      {{ thermostat }} has temp difference of {{ calculated_adjustment }}. Setting target temperature to {{ calculated_target_temperature }}
    level: info
    logger: blueprints.nevesenin.target_temperature_adjustment
- service: system_log.write
  data:
    message: >
      thermostat: {{ thermostat }},
      temperature_sensor: {{ temperature_sensor }},
      target_temperature: {{ target_temperature }},
      actual_temperature: {{ actual_temperature }},
      calculated_adjustment: {{ calculated_adjustment }},
      calculated_target_temperature: {{ calculated_target_temperature }}
    level: debug
    logger: blueprints.nevesenin.target_temperature_adjustment
- service: climate.set_temperature
  data:
    temperature: "{{ calculated_target_temperature }}"
    entity_id: "{{ thermostat }}"
mode: single
6 Likes

awesome thanks! although this will not work with zigbee related trvā€™s right?

Hi!
I use this with https://www.zigbee2mqtt.io/devices/SPZB0001.html#eurotronic-spzb0001 and https://www.zigbee2mqtt.io/devices/TT001ZAV20.html#tuya-tt001zav20 via zigbee2mqtt.

This Blueprint does not work for me, it seems the temperature unit is had coded to Celsius and since my system uses Fahrenheit HA throws errors. Is this something that can be changed?

I need to make some guessings here b/c in theory this should also work for Fahrenheit. I could imagine, that the temperature ranges of your devices are different (not 5-30). Also I donā€™t know if 0.5 steps are possible. If you could provide these information, Iā€™ll try to create a Fahrenheit blueprint when I have time.

Here is the error in the log I get.

Logger: homeassistant.components.automation.target_temperature_adjustment_depending_on_second_temperature_sensor
Source: components/nest/climate_sdm.py:312
Integration: Automation (documentation, issues)
First occurred: 6:00:21 AM (2 occurrences)
Last logged: 6:00:21 AM

Target temperature adjustment depending on second temperature sensor: Error executing script. Unexpected error for call_service at pos 3: Error from API: 400: INVALID_ARGUMENT: Temperature setpoint is out of range [10.000000, 32.222301] in FAHRENHEIT.: Bad Request
While executing automation automation.target_temperature_adjustment_depending_on_second_temperature_sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/auth.py", line 80, in _raise_for_status
    resp.raise_for_status()
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1000, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://smartdevicemanagement.googleapis.com/v1/enterprises/5826d294-f97d-4963-add2-df3c4b3435b5/devices/AVPHwEvbYAV1sT9RiutrVlNGHM2kQN9k8bxq9GWGFkKgRDoOzfyVNpvB0jI1mLGzvLOskm0lfLkyDvElbUg5QPyv-ZcaMw:executeCommand')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 363, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 563, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1481, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1516, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 658, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 726, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 695, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 548, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/nest/climate_sdm.py", line 312, in async_set_temperature
    await trait.set_cool(temp)
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/thermostat_traits.py", line 132, in set_cool
    return await self._cmd.execute(data)
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/traits.py", line 23, in execute
    return await self._auth.post(f"{self._device_id}:executeCommand", json=data)
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/auth.py", line 73, in post
    return await AbstractAuth._raise_for_status(resp)
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/auth.py", line 85, in _raise_for_status
    raise ApiException(": ".join(detail)) from err
google_nest_sdm.exceptions.ApiException: Error from API: 400: INVALID_ARGUMENT: Temperature setpoint is out of range [10.000000, 32.222301] in FAHRENHEIT.: Bad Request

here is the automation trace.

{
  "trace": {
    "last_step": "action/2",
    "run_id": "222",
    "state": "stopped",
    "script_execution": "error",
    "timestamp": {
      "start": "2021-05-02T11:00:20.943854+00:00",
      "finish": "2021-05-02T11:00:21.802982+00:00"
    },
    "domain": "automation",
    "item_id": "1619953140091",
    "error": "Error from API: 400: INVALID_ARGUMENT: Temperature setpoint is out of range [10.000000, 32.222301] in FAHRENHEIT.: Bad Request",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2021-05-02T11:00:20.944524+00:00",
          "changed_variables": {
            "trigger": {
              "platform": null
            },
            "thermostat": "climate.rio_nest",
            "temperature_sensor": "sensor.master_bedroom_sensor_temp",
            "target_temperature": 22,
            "actual_temperature": 77.5,
            "calculated_adjustment": -55.5,
            "calculated_target_temperature": -33.5
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2021-05-02T11:00:20.945673+00:00",
          "changed_variables": {
            "context": {
              "id": "7afcb20eb7ae43751ec7951e501e244c",
              "parent_id": "6e8d93cf2034130befd35a04eacca22d",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "system_log",
              "service": "write",
              "service_data": {
                "message": "climate.rio_nest has temp difference of -55.5. Setting target temperature to -33.5",
                "level": "info",
                "logger": "blueprints.nevesenin.target_temperature_adjustment"
              },
              "target": {}
            },
            "running_script": false,
            "limit": 10
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2021-05-02T11:00:20.951904+00:00",
          "result": {
            "params": {
              "domain": "system_log",
              "service": "write",
              "service_data": {
                "message": "thermostat: climate.rio_nest, temperature_sensor: sensor.master_bedroom_sensor_temp, target_temperature: 22, actual_temperature: 77.5, calculated_adjustment: -55.5, calculated_target_temperature: -33.5",
                "level": "debug",
                "logger": "blueprints.nevesenin.target_temperature_adjustment"
              },
              "target": {}
            },
            "running_script": false,
            "limit": 10
          }
        }
      ],
      "action/2": [
        {
          "path": "action/2",
          "timestamp": "2021-05-02T11:00:20.952812+00:00",
          "error": "Error from API: 400: INVALID_ARGUMENT: Temperature setpoint is out of range [10.000000, 32.222301] in FAHRENHEIT.: Bad Request",
          "result": {
            "params": {
              "domain": "climate",
              "service": "set_temperature",
              "service_data": {
                "temperature": -33.5,
                "entity_id": "climate.rio_nest"
              },
              "target": {}
            },
            "running_script": false,
            "limit": 10
          }
        }
      ]
    },
    "config": {
      "variables": {
        "thermostat": "climate.rio_nest",
        "temperature_sensor": "sensor.master_bedroom_sensor_temp",
        "target_temperature": 22,
        "actual_temperature": "{{ states(temperature_sensor) | float }}",
        "calculated_adjustment": "{{ target_temperature - actual_temperature }}",
        "calculated_target_temperature": "{{ ( ( ( target_temperature + calculated_adjustment ) * 2 ) | round ) / 2 }}"
      },
      "trigger": [
        {
          "platform": "state",
          "entity_id": "climate.rio_nest",
          "attribute": "{{ current_temperature_attribute }}"
        },
        {
          "platform": "state",
          "entity_id": "sensor.master_bedroom_sensor_temp"
        }
      ],
      "condition": "{{ calculated_adjustment != 0 }}",
      "action": [
        {
          "service": "system_log.write",
          "data": {
            "message": "{{ thermostat }} has temp difference of {{ calculated_adjustment }}. Setting target temperature to {{ calculated_target_temperature }}\n",
            "level": "info",
            "logger": "blueprints.nevesenin.target_temperature_adjustment"
          }
        },
        {
          "service": "system_log.write",
          "data": {
            "message": "thermostat: {{ thermostat }}, temperature_sensor: {{ temperature_sensor }}, target_temperature: {{ target_temperature }}, actual_temperature: {{ actual_temperature }}, calculated_adjustment: {{ calculated_adjustment }}, calculated_target_temperature: {{ calculated_target_temperature }}\n",
            "level": "debug",
            "logger": "blueprints.nevesenin.target_temperature_adjustment"
          }
        },
        {
          "service": "climate.set_temperature",
          "data": {
            "temperature": "{{ calculated_target_temperature }}",
            "entity_id": "{{ thermostat }}"
          }
        }
      ],
      "mode": "single",
      "id": "1619953140091",
      "alias": "Target temperature adjustment depending on second temperature sensor",
      "description": ""
    },
    "blueprint_inputs": {
      "id": "1619953140091",
      "alias": "Target temperature adjustment depending on second temperature sensor",
      "description": "",
      "use_blueprint": {
        "path": "nevesenin/target_temperature_adjustment.yaml",
        "input": {
          "temperature_sensor": "sensor.master_bedroom_sensor_temp",
          "thermostat": "climate.rio_nest",
          "target_temperature": 22
        }
      }
    },
    "context": {
      "id": "7afcb20eb7ae43751ec7951e501e244c",
      "parent_id": "6e8d93cf2034130befd35a04eacca22d",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Target temperature adjustment depending on second temperature sensor",
      "message": "has been triggered",
      "source": null,
      "entity_id": "automation.target_temperature_adjustment_depending_on_second_temperature_sensor",
      "context_id": "7afcb20eb7ae43751ec7951e501e244c",
      "when": "2021-05-02T11:00:20.944650+00:00",
      "domain": "automation"
    }
  ]
}

I use a nest 2nd gen

hvac_modes:
  - heat
  - 'off'
  - cool
  - heat_cool
  - fan_only
min_temp: 45
max_temp: 95
fan_modes:
  - 'on'
  - 'off'
preset_modes:
  - none
  - eco
current_temperature: 74
temperature: 77
target_temp_high: null
target_temp_low: null
fan_mode: 'off'
hvac_action: 'off'
preset_mode: none
friendly_name: Rio Nest
supported_features: 27

Hi, could you try this please? target_temperature_adjustment_fahrenheit.yaml Ā· GitHub

1 Like

Thanks for making this, I ended up modifying your original and it seemed to work pretty good but I see there are some differences so I am disabling the one I modified and testing the one you made. I will let you know how it goes!

here is the mods I made

blueprint:
  name: Target temperature adjustment depending on second temperature sensor
  description: 'Sets target temperature depending on second temperature sensor. This
    blueprint is inspired by this blueprint https://community.home-assistant.io/t/tado-set-offset-using-separate-temperature-sensor/288515
    created by Sanderma. Since not all thermostat devices have an configurable offset,
    this blueprint sets the target temperature of the thermostat device depending
    on a given target temperature and a second temperature sensor.

    '
  domain: automation
  input:
    temperature_sensor:
      name: Temperature sensor
      description: This sensor will be used as the source.
      selector:
        entity:
          domain: sensor
          device_class: temperature
    thermostat:
      name: Thermostat
      description: The thermostat to set target temperature
      selector:
        entity:
          domain: climate
    target_temperature:
      name: Target temperature
      description: Target temperature of the thermostat
      selector:
        number:
          min: 45.0
          max: 95.0
          step: 0.5
          unit_of_measurement: Ā°F
          mode: slider
      default: 76
  source_url: https://gist.github.com/nevesenin/86c471e8ea5ab10a2b9ddcbca6dbbccb
variables:
  thermostat: !input 'thermostat'
  temperature_sensor: !input 'temperature_sensor'
  target_temperature: !input 'target_temperature'
  actual_temperature: '{{ states(temperature_sensor) | float }}'
  calculated_adjustment: '{{ target_temperature - actual_temperature }}'
  calculated_target_temperature: '{{ ( ( ( target_temperature + calculated_adjustment
    ) * 2 ) | round ) / 2 }}'
trigger:
- platform: state
  entity_id: !input 'thermostat'
  attribute: '{{ current_temperature_attribute }}'
- platform: state
  entity_id: !input 'temperature_sensor'
condition: '{{ calculated_adjustment != 0 }}'
action:
- service: system_log.write
  data:
    message: '{{ thermostat }} has temp difference of {{ calculated_adjustment }}.
      Setting target temperature to {{ calculated_target_temperature }}

      '
    level: info
    logger: blueprints.nevesenin.target_temperature_adjustment
- service: system_log.write
  data:
    message: 'thermostat: {{ thermostat }}, temperature_sensor: {{ temperature_sensor
      }}, target_temperature: {{ target_temperature }}, actual_temperature: {{ actual_temperature
      }}, calculated_adjustment: {{ calculated_adjustment }}, calculated_target_temperature:
      {{ calculated_target_temperature }}

      '
    level: debug
    logger: blueprints.nevesenin.target_temperature_adjustment
- service: climate.set_temperature
  data:
    temperature: '{{ calculated_target_temperature }}'
    entity_id: '{{ thermostat }}'
mode: single

OK so after letting it run with your config it is raising the temperature? I thought it would only cool to target temp and not run if target temp was matched?

Executed: July 2, 2021, 8:30:59 PM
trigger:
  id: '1'
  idx: '1'
  platform: state
  entity_id: sensor.master_bedroom_sensor_temp
  from_state:
    entity_id: sensor.master_bedroom_sensor_temp
    state: '76.1'
    attributes:
      state_class: measurement
      unit_of_measurement: Ā°F
      friendly_name: Master Bedroom Sensor temp
      device_class: temperature
    last_changed: '2021-07-03T00:27:26.991247+00:00'
    last_updated: '2021-07-03T00:27:26.991247+00:00'
    context:
      id: 06b6e636d288ff2b7f64d00d6a3a7d37
      parent_id: null
      user_id: null
  to_state:
    entity_id: sensor.master_bedroom_sensor_temp
    state: '74.8'
    attributes:
      state_class: measurement
      unit_of_measurement: Ā°F
      friendly_name: Master Bedroom Sensor temp
      device_class: temperature
    last_changed: '2021-07-03T01:30:59.770185+00:00'
    last_updated: '2021-07-03T01:30:59.770185+00:00'
    context:
      id: 6d679961aab71d91ac07c92f8dc7b9db
      parent_id: null
      user_id: null
  for: null
  attribute: null
  description: state of sensor.master_bedroom_sensor_temp
thermostat: climate.rio_nest
temperature_sensor: sensor.master_bedroom_sensor_temp
target_temperature: 76
actual_temperature: 74.8
calculated_adjustment: 1.2000000000000028
calculated_target_temperature: 77

with my modified version it drops the temp.

Executed: July 2, 2021, 8:50:09 PM
trigger:
  id: '1'
  idx: '1'
  platform: state
  entity_id: sensor.master_bedroom_sensor_temp
  from_state:
    entity_id: sensor.master_bedroom_sensor_temp
    state: '74.8'
    attributes:
      state_class: measurement
      unit_of_measurement: Ā°F
      friendly_name: Master Bedroom Sensor temp
      device_class: temperature
    last_changed: '2021-07-03T01:30:59.770185+00:00'
    last_updated: '2021-07-03T01:30:59.770185+00:00'
    context:
      id: 6d679961aab71d91ac07c92f8dc7b9db
      parent_id: null
      user_id: null
  to_state:
    entity_id: sensor.master_bedroom_sensor_temp
    state: '76.1'
    attributes:
      state_class: measurement
      unit_of_measurement: Ā°F
      friendly_name: Master Bedroom Sensor temp
      device_class: temperature
    last_changed: '2021-07-03T01:50:09.708256+00:00'
    last_updated: '2021-07-03T01:50:09.708256+00:00'
    context:
      id: ee340951f3323336576a809e6876d982
      parent_id: null
      user_id: null
  for: null
  attribute: null
  description: state of sensor.master_bedroom_sensor_temp
thermostat: climate.rio_nest
temperature_sensor: sensor.master_bedroom_sensor_temp
target_temperature: 75
actual_temperature: 76.1
calculated_adjustment: -1.0999999999999943
calculated_target_temperature: 74

They are both raising the temperature now, not sure why.

HI, thank you for this great blueprint!
I was wondering if it is possible to modify it to use helper entities to set the target temperature? This would make it possible to adjust the target temperature directly form a Lovelace dashboard instead of having to edit the automation. I testet this but so far I havenā€™t been able to get it to work.

Here is what I tried:

I copied your blueprint and tried defining target_temperature as a sensor:

    target_temperature:
      name: Target temperature
      description: Number helper with the target temperature of the thermostat
      selector:
        entity:
          domain: sensor

Then I created two input_number helpers, because I need two automations, one for night temperature and one for day temperature.

Finally I added two sensor templates to my configuration.yaml. I think this is needed in order to remove decimals from the value set by the input_number helper.

sensor:
  - platform: template
    sensors:
      temperatur_dag:
        value_template: "{{ states('input_number.temperatur_dag')|int }}"
  - platform: template
    sensors:
      temperatur_natt:
        value_template: "{{ states('input_number.temperatur_natt')|int }}"

But when I run the automation, and I use the tracing function to check if it works, I get this error:

Maybe this approach simply doesnā€™t work, but it would be great to be able to adjust the target temperature from Lovelace.

Is there a means to incorporating a card within the lovelace overview to control the temperature should you want to adjust it easily on the fly? Or would you have to go into the settings of the automation to adjust it there?

Iā€™m not sure if this will help (be warned: not an expert with home assistant) but following a near identical post I made on Reddit with a helpful user I got something working. Iā€™ll attempt to share best I can and perhaps you can fill in the blanks for your own setup.

It was suggested that I copy the blueprint file by making a clone (just added ā€œver2ā€ to the end of the name of mine) and then make changes there. I used the fahrenheit variant from some of the comments above. I ended up editing a few areas, namely the block of text under target_temperature (line 24ish) to remove all the numbers and add a domain: input_number there, along with a few variables below that, and lastly a section in message: > towards the bottom (line 51ish). My end yaml looks like this:

blueprint:
  name: Target temperature adjustment depending on second temperature sensor (Fahrenheit) ver2
  description: >
    Sets target temperature depending on second temperature sensor.
    This blueprint is inspired by this blueprint https://community.home-assistant.io/t/tado-set-offset-using-separate-temperature-sensor/288515
    created by Sanderma. Since not all thermostat devices have an configurable
    offset, this blueprint sets the target temperature of the thermostat device
    depending on a given target temperature and a second temperature sensor.
  domain: automation
  input:
    temperature_sensor:
      name: Temperature sensor
      description: This sensor will be used as the source.
      selector:
        entity:
          domain: sensor
          device_class: temperature
    thermostat:
      name: Thermostat
      description: The thermostat to set target temperature
      selector:
        entity:
          domain: climate
    target_temperature:
      name: Target temperature
      description: Target temperature of the thermostat
      selector:
        entity:
          domain: input_number

variables:
  thermostat: !input thermostat
  temperature_sensor: !input temperature_sensor
  target_temperature: !input target_temperature
  actual_temperature: "{{ states(temperature_sensor) | float }}"
  calculated_adjustment: "{{ states(target_temperature) | float - actual_temperature }}"
  calculated_target_temperature: "{{ ( ( ( states(target_temperature) | float + calculated_adjustment ) * 2 ) | round ) / 2 }}"

trigger:
- platform: state
  entity_id: !input thermostat
  attribute: "{{ current_temperature_attribute }}"
- platform: state
  entity_id: !input temperature_sensor
  
condition: "{{ calculated_adjustment != 0 }}"

action:
- service: system_log.write
  data:
    message: >
      {{ thermostat }} has temp difference of {{ calculated_adjustment }}. Setting target temperature to {{ calculated_target_temperature }}
    level: info
    logger: blueprints.nevesenin.target_temperature_adjustment_fahrenheit
- service: system_log.write
  data:
    message: >
      thermostat: {{ thermostat }},
      temperature_sensor: {{ temperature_sensor }},
      target_temperature: {{ states(target_temperature) | float | round(1)}},
      actual_temperature: {{ actual_temperature }},
      calculated_adjustment: {{ calculated_adjustment }},
      calculated_target_temperature: {{ calculated_target_temperature }}
    level: debug
    logger: blueprints.nevesenin.target_temperature_adjustment_fahrenheit
- service: climate.set_temperature
  data:
    temperature: "{{ calculated_target_temperature }}"
    entity_id: "{{ thermostat }}"
mode: single

I then added an ā€œentitiesā€ card and only added one entity underneath. I had better luck with this than just using the singular ā€œentityā€ card. In the end I had the card as seen in the screenshot - specifically the ā€œtarget temperature (full auto)ā€ card. The entity listed within the card is the input_number helper that I added in automations >> helpers (just did number, preferred range, slider, step size 1, etc):

msedge_G4J9oHnXZq

The other two half-sized cards you see under it is an on/off switch for the automation so I can easily toggle it off once we hit cooling season and the ā€œUpdate Temperatureā€ button just runs a trigger of the service so itā€™ll update the temp calculation immediately (like ā€œrun actionā€ does). The idea being I can adjust the temp card slider to what I want, punch ā€œupdate temperatureā€, and off I go. So far in my limited testing this seems to work on my endā€¦ so I felt inclined to follow up and see if what I ran into may help on your end.

Hi, sorry for not contributing here. All notifications for this community end up in my spam folder. Need to fix that. But to be honest, I currently also have not much time to help. But Iā€™d like to mention that I also wanted to have that settings on a dashboard some time ago. Since I didnā€™t manage to put all that into one template (and also using yaml as a ā€œprogramming languageā€ sucks) I created three new ones. I didnā€™t post them here, b/c homeassistant doesnā€™t work well with code repository providers others than github. You can find them here. They also lack a bit of documentation. To use all features you need to create two input_number and two input_datetime entities first. You can find a rough description in this blueprint empunkt/homeassistant-blueprints: Collection of homeassistant blueprints I created - update_thermostat_from_persistence.yaml at main - homeassistant-blueprints - Codeberg.org.
PS.: You do not necessarily need all three temperature blueprints for every usecase.

2 Likes

@nevesenin heh, odd timing - I came back to this post to update some of my own findings after my post a day or two ago (mostly in case anybody here could find what I ran into of use) and was pleasantly surprised to see an update from you. Good to see ya! Iā€™ll have to check out your new options you listed above at some point for sure. Appreciate you sharing.

In other news I ended up tweaking my copied variant of neveseninā€™s original fahrenheit version posted earlier on. Most of this was via the help of other users on reddit (Iā€™m far from an expert and take no credit). With a few changes I adapted it to hit a few goals I was after. First, I created an input_number helper and just named it target_temperature. Then on lines 28/29 it adapts the automation of the blueprint to allow me to select an entity for the target temperature (where previously this was a slider right within the automation). From here within the automation I was able to choose the input.target_temperature helper I made. On the lovelace dashboard itā€™s simply a slider tied to the same input.target_temperature entity, thus in the end giving you a slider on the dashboard that the blueprint works against instead of the slider being a few layers deeper within the automation itself.

On lines 45/46 I added this same input as being a trigger. End result of this is by adjusting the slider on the dashboard it will set the target_temperature and also apply it right away. With this set up I no longer needed to do any sort of run action/trigger step afterwards.

Thereā€™s a few other areas that I think were edited - I believe lines 36, 37, and 62 were mostly it though. Otherwise this is pretty close to the original. Pastebin for the line numbers - blueprint: name: Target temperature adjustment depending on second temperatur - Pastebin.com

So far the gizmo seems to be working spot on. Another thanks to nevesenin for this as it solved a massive problem I was facing in my home hvac setup. Weā€™ll see if any changes I made remain consistent and predictable going forward. On that note, nevesenin - if you spot any problems with what I changed Iā€™d be more than happy to hear any additional insight. Cheers!

blueprint:
  name: Target temperature adjustment depending on second temperature sensor (Fahrenheit)
  description: >
    Sets target temperature depending on second temperature sensor.
    This blueprint is inspired by this blueprint https://community.home-assistant.io/t/tado-set-offset-using-separate-temperature-sensor/288515
    created by Sanderma. Since not all thermostat devices have an configurable
    offset, this blueprint sets the target temperature of the thermostat device
    depending on a given target temperature and a second temperature sensor.
  domain: automation
  input:
    temperature_sensor:
      name: Temperature sensor
      description: This sensor will be used as the source.
      selector:
        entity:
          domain: sensor
          device_class: temperature
    thermostat:
      name: Thermostat
      description: The thermostat to set target temperature
      selector:
        entity:
          domain: climate
    target_temperature:
      name: Target temperature
      description: Target temperature of the thermostat
      selector:
        entity:
          domain: input_number
          
variables:
  thermostat: !input thermostat
  temperature_sensor: !input temperature_sensor
  target_temperature: !input target_temperature
  actual_temperature: "{{ states(temperature_sensor) | float }}"
  calculated_adjustment: "{{ states(target_temperature) | float - actual_temperature }}"
  calculated_target_temperature: "{{ ( ( ( states(target_temperature) | float + calculated_adjustment ) * 2 ) | round ) / 2 }}"

trigger:
- platform: state
  entity_id: !input thermostat
  attribute: "{{ current_temperature_attribute }}"
- platform: state
  entity_id: !input temperature_sensor
- platform: state
  entity_id: !input target_temperature
  
condition: "{{ calculated_adjustment != 0 }}"

action:
- service: system_log.write
  data:
    message: >
      {{ thermostat }} has temp difference of {{ calculated_adjustment }}. Setting target temperature to {{ calculated_target_temperature }}
    level: info
    logger: blueprints.nevesenin.target_temperature_adjustment_fahrenheit
- service: system_log.write
  data:
    message: >
      thermostat: {{ thermostat }},
      temperature_sensor: {{ temperature_sensor }},
      target_temperature: {{ states(target_temperature) | float | round(1)}},
      actual_temperature: {{ actual_temperature }},
      calculated_adjustment: {{ calculated_adjustment }},
      calculated_target_temperature: {{ calculated_target_temperature }}
    level: debug
    logger: blueprints.nevesenin.target_temperature_adjustment_fahrenheit
- service: climate.set_temperature
  data:
    temperature: "{{ calculated_target_temperature }}"
    entity_id: "{{ thermostat }}"
mode: single

PS - I used a custom card entitled ā€œslider-entity-rowā€ which has the option to give you a full width slider bar. I tied that in to the input_number mentioned above within lovelace. In the end the code for that card looks like this:

type: entities
entities:
  - type: custom:slider-entity-row
    entity: input_number.target_temp_automation
    full_row: true
  - entity: climate.centralite_thermostat_fan_thermostat
    name: Thermostat Stats
title: Heating Target Temp (full auto)

with the visuals looking like this:
Screenshot 2022-02-13 233750

Anyway, just wanted to share in case it helps anyone, but again Iā€™m quite the opposite of an adept user soā€¦ good luck. :smiley:

2 Likes

Wow @roasted ā€“ thanks so much for posting that! Works perfectly for my setupā€¦ thermostat for all the bedrooms is in the hallway. Leads to insanely hot bedrooms in the middle of the night. I actually set mine up using the numberbox-card so I could match styles with the simple thermostat card.

Anyway, thanks again!

Totally thanking your both @nevesenin and @roasted - I implemented the fahrenheit version with my T6 Pros and basing it on a combined sensor of multiple BLE sensors for upstairs and downstairs and it just works! Absolutely awesome!

Heyo! Interesting that you went the numberbox-card routeā€¦ causeā€¦ so did I! The more I worked with the slider the more I kept misadjusting it when on mobile. The click+drag action on my iPhone just couldnā€™t quite be as accurate as I was hoping. Figured a tap up/down action would be better suited, so thatā€™s where I ended up as well. Glad it works for you!

Quick visual for others because, well, why not. :smiley:

ha-temp

Rigged up to be a conditional card. If the Full Auto Heat Mode is on, the 2nd card you see appears within the dashboard. If itā€™s off, this card disappears and the regular/normal thermostat card shows up in its place (I need the normal thermostat card for AC mode in summer). This card arrangement gives me a quick glimpse of whatā€™s up. You can see the target is 67.3, current is 70.7, and neveseninā€™s magic is setting the thermostat to 68.5 with the target being 68.0. I donā€™t necessarily ā€œneedā€ all this since the automation does its thing, but itā€™s still kind of nice to really ā€˜knowā€™ and see for myself whatā€™s happening.

I gotta say I think things were much more balanced for this heating season than they ever were. Another shoutout to nevesenin for this work. :smiley:

1 Like