Setting a target entity (and possibly other issues)

Hello!

I’m trying to create a blueprint that will select a temperature sensor, and use that value to display on a specific thermostat external temperature entity.

I tried

blueprint:
  name: External temp on Sinope
  description: Display the temperature the thermostat
  domain: automation
  input:
    temp_sensor:
      name: Temperature Sensor
      description: The temperature sensor to monitor
      selector:
        entity:
          filter:
            domain: sensor
            device_class: temperature
    thermostat:
      name: Sinope Thermostat
      description: Which thermostat to show
      selector:
        entity:
          filter:
            domain: number

variables:
  temp_sensor: !input temp_sensor
  temperature: "{{ states(temp_sensor) | float(0) | round(1)}}"
  thermostat: !input thermostat

triggers:
  trigger: state
  entity_id: !input temp_sensor

actions:
  - action: number.set_value
    target:
      entity_id: thermostat
    data:
      value: temperature

So first, I get this:

not a valid value for dictionary value @ data[‘actions’][0][‘target’][‘entity_id’]

I’m not sure if it’s saying I’m setting the entity_id incorrectly? (which I thought I was doing properly…)

After searching on my own, I also found this in the MQTT discovery data, which would lead to another issue, as it’s probably expecting a different format for the value

value_template: ‘{{ value_json.thermostat_outdoor_temperature }}’
step: 0.5

Which I have absolutely no clue how to set up (I also will want to use that step value to round the temperature properly, but that I haven’t looked up yet)

Thanks in advance, and sorry for the noobish questions, having a bit of a hard time navigating the doc since basically everything is new to me :smiley:

Hi mathdons.

Your problem is syntax

    target:
      entity_id: !input thermostat
    data:
      value: "{{ temperature }}"

Might work better for you.

Hello!
Still the same error message. But shouldn’t “entity_id: !input thermostat” be the same as “entity_id: thermostat” since I declared a “thermostat” variable to contain the id retrieved for the input?

So “{{ thermostat }}” is a template string, right? It allows to evaluate the value of the variable?
Cause replacing

entity_id: thermostat

with

entity_id: “{{ thermostat }}”

Does work!

And to complete my question, to round to the nearest .5, the template should be:

temperature: “{{ states(temp_sensor) | float(0) | round(1, ‘half’, 0)}}”

https://jinja.palletsprojects.com/en/3.0.x/templates/#jinja-filters.round
Round rules.

1 Like