Blueprint help!

Hello, help please.
Here’s is my blueprint to calibrate Tado offsets, based on an external zigbee sensor.

blueprint:
  name: Update Entity Offset
  description: Update the offset attribute of an entity based on another sensor's state
  domain: automation
  input:
    sensor_to_monitor:
      name: Zigbee Sensor to Monitor
      description: The sensor whose state will be used to update the "offset" attribute
      selector:
        entity:
          domain: sensor
          device_class: temperature
    entity_to_update:
      name: Tado Entity to Update
      description: The entity whose "offset" attribute will be updated
      selector:
        entity:
            domain: climate
    threshold:
      name: Threshold
      description: The maximum difference between the two sensors to trigger the automation
      selector:
        number:
          min: 0
          max: 10
          step: 0.5
          unit_of_measurement: "°C"

trigger:
  platform: numeric_state
  entity_id:
    - !input 'sensor_to_monitor'
    - !input 'entity_to_update'
  value_template: "{{ (states('sensor_to_monitor')|float - state_attr('entity_to_update', 'current_temperature')|float)|abs }}"  
  above: !input 'threshold'

action:
  - service: tado.set_climate_temperature_offset
    data:
      offset: "{{( state_attr('entity_to_update', 'offset_celsius')|float if state_attr('entity_to_update', 'offset_celsius') is not none else 0 ) + ((states('sensor_to_monitor')|float - state_attr('entity_to_update',  'current_temperature')|float) if states('sensor_to_monitor') is not none and state_attr('entity_to_update', 'current_temperature') is not none else 0 ) | round(1)}}"
    target:
      entity_id: !input 'entity_to_update'

All looks fine but the offset value that should be calulated in the action, just doesn’t get values from the entity and the sensor… It looks like input variables aren’t rewritten with the actual name of the entity/sensor I choose from the automation.

Help please, it’s driving me crazy!

Thanks community!!

Remove the quotes around the variables.
When you add quotes they are handled as strings.

This is the updated blueprint:

blueprint:
  name: Update Entity Offset
  description: Update the offset attribute of an entity based on another sensor's state
  domain: automation
  input:
    sensor_to_monitor:
      name: Zigbee Sensor to Monitor
      description: The sensor whose state will be used to update the "offset" attribute
      selector:
        entity:
          domain: sensor
          device_class: temperature
    entity_to_update:
      name: Tado Entity to Update
      description: The entity whose "offset" attribute will be updated
      selector:
        entity:
            domain: climate
    threshold:
      name: Threshold
      description: The maximum difference between the two sensors to trigger the automation
      selector:
        number:
          min: 0
          max: 10
          step: 0.5
          unit_of_measurement: "°C"

trigger:
  platform: numeric_state
  entity_id:
    - !input sensor_to_monitor
    - !input entity_to_update
  value_template: "{{ (states(sensor_to_monitor)|float - state_attr(entity_to_update, 'current_temperature')|float)|abs }}"  
  above: !input 'threshold'

action:
  - service: tado.set_climate_temperature_offset
    data:
      offset: "{{( state_attr(entity_to_update, 'offset_celsius')|float if state_attr(entity_to_update, 'offset_celsius') is not none else 0 ) + ((states(sensor_to_monitor)|float - state_attr(entity_to_update,  'current_temperature')|float) if states(sensor_to_monitor) is not none and state_attr(entity_to_update, 'current_temperature') is not none else 0 ) | round(1)}}"
    target:
      entity_id: !input entity_to_update

Now I got this as a result from the traces:

It is an input, not a variable.
You need a variables block to access it like that.

blueprint:
  name: Update Entity Offset
  description: Update the offset attribute of an entity based on another sensor's state
  domain: automation
  input:
    sensor_to_monitor:
      name: Zigbee Sensor to Monitor
      description: The sensor whose state will be used to update the "offset" attribute
      selector:
        entity:
          domain: sensor
          device_class: temperature
    entity_to_update:
      name: Tado Entity to Update
      description: The entity whose "offset" attribute will be updated
      selector:
        entity:
            domain: climate
    threshold:
      name: Threshold
      description: The maximum difference between the two sensors to trigger the automation
      selector:
        number:
          min: 0
          max: 10
          step: 0.5
          unit_of_measurement: "°C"
variables:
  entity_to_update: !input entity_to_update
  sensor_to_monitor: !input sensor_to_monitor
trigger:
  platform: numeric_state
  entity_id:
    - !input sensor_to_monitor
    - !input entity_to_update
  value_template: "{{ (states(sensor_to_monitor)|float - state_attr(entity_to_update, 'current_temperature')|float)|abs }}"  
  above: !input 'threshold'

action:
  - service: tado.set_climate_temperature_offset
    data:
      offset: "{{( state_attr(entity_to_update, 'offset_celsius')|float if state_attr(entity_to_update, 'offset_celsius') is not none else 0 ) + ((states(sensor_to_monitor)|float - state_attr(entity_to_update,  'current_temperature')|float) if states(sensor_to_monitor) is not none and state_attr(entity_to_update, 'current_temperature') is not none else 0 ) | round(1)}}"
    target:
      entity_id: !input entity_to_update
1 Like

Wow, that worked but only if I run the automation manually. It ignores the threshold of 0.5°C I set in the automation. There must be something not working within the trigger section. I know you would probably know but the value_template is an absolute number so either the difference is positive or negative the threshold should trigger the automation anyway.

Is the trigger section correct in your eyes?

Im not sure what that does, test the template out in dev tools.

It basically gets the difference between the two sensors, and if the difference is higher than the threshold set it triggers the automation. The value is all wrapped up with an absolute parameter so whether is -0.5 or 0.5 the value is always 0.5. Despite setting a 0.5 value and forcing one of the two sensor’s value to a higher number so the difference is >0.5, the automation won’t run.

If I change the variables with entity/sensor names in the dev tools I get the correct value. It seems like the expression isn’t set in the right way so variables are replaced with real entity/sensor names.

Replacing by hand the names of the entity/sensor I get a correct value:

I still had to use quotes around the entyty/sensor otherwise I couldn’t get any result. I am wondering if something like what you suggested for the action part has to be done also for the trigger part.

@ludeeus Please help! :pray::pray::blush:

Up! Please please…