Passing a variable to a service call in a Blueprint

Tags: #<Tag:0x00007f326cca79c0>

I’m trying to create a blueprint that will respond to a window open event by calling a service to notify the associated heating zone. This will cause the thermostat set temperature to be reduced while the window remains open. The blueprint just asks for the window sensor and the target climate device. I’m then using a template to capture the device id from the thermostat in a variable (climate_id) which is passed to the service call:

      name: Window Sensor
      description: The window sensor that controls the climate entity.
          domain: binary_sensor
          device_class: window

      name: Climate Device
      description: The climate entity that is controlled by the window sensor.
          domain: climate

  climate_target: !input climate_entity
  climate_id: '{{ state_attr( climate_target, "id") }}'

- platform: state
  entity_id: !input 'window_entity'
  to: 'on'

- service: homematic.set_device_value
    address: climate_id
    channel: 1
    param: 'WINDOW_STATE'
    value: 1
- wait_for_trigger:
  - platform: state
    entity_id: !input 'window_entity'
    to: 'off'
  continue_on_timeout: false
- service: homematic.set_device_value
    address: climate_id
    channel: 1
    param: 'WINDOW_STATE'
    value: 0

The template works when I test it, but when I create an automation with the blueprint, the logs just show “CLIMATE_ID not found!”
Any ideas how to debug this, or can anyone spot whatever glaring errors I have made?

You need to put it in cury brackets, otherwise it doesn’t know that it is a template:

address: "{{ climate_id }}"

Also you can change data_template to data, you don’t need the _template part anymore since some versions.

1 Like

I can’t believe it was that simple! Thanks you so much @Burningstone, the blueprint works perfectly now :grinning: :+1: :+1:

Glad that you got it to work :slight_smile: could you please mark my post as the solution then. This way it will be marked as solved and others will find the solution quickly.

I did try to, but when I click on the … I don’t see the tick-box. What have I missed?

I fully understand you probably wanted to create a blueprint but I do the same with a tiny automation. Just turning off the NETATMO valve when the doors/windows are open. What’s the added value here? Do I miss something?

Btw, I found your thread because I want to sent a template value to an entity, I have exact syntax but mine does not work. Service returns “float expected” while I am sending float, have you had a comparable problem? The brackets should solve it, but did not for me

Isn’t there a greyed out tick mark somewhere at the bottom of my post with “Solution” next to it? Just click on it.

Please show your code.

That’s a fair point, but I have a few reasons for doing it this way:

I want to get familiar with Blueprints, so this has been a good exercise.
I have 20+ doors & windows so writing and maintaining automations for these would have been a pain. Using a blueprint keeps them all consistent.
Control of the home heating system (schedule, temperatures, times, etc.) is fully managed by Home Assistant. So, I want to make it as easy as possible for other members of the household to be able to change it when necessary rather than having to rely on me. Using a blueprint is much easier for non-technical users.

I’m afraid I’m still on the bottom end of the learning curve with regard to templates, so I can’t help you with yours - sorry :man_shrugging:


When I click on the three dots under your post, this is what I see: