Templating possible for text.set_value?

Dear community,

I have been struggling for a day to send the current temperature from a sensor to my heating system via an automation.

I am able to read the current temperature with

"{{ states('sensor.shellyhtg3_54320466bc60_temperature') }}"

However, when i try to set_value of a text entity, the template gets sent literally, instead of being evaluated. My template gets evaluated just fine, if I were to send a notification with the current temperature.

Please find below my minimal (non-)working example:

- id: '1737370277520'
  alias: SendTempToElco
  description: ''
  triggers:
  - trigger: time_pattern
    minutes: /5
  conditions: []
  actions:
  - device_id: 09faae33ea8cb89eec1884b8705a50cf
    domain: text
    entity_id: 17f686316c2bfe8a44782e0d07a87022
    type: set_value
    value: "{{ 42/2 }}"
  - action: persistent_notification.create
    metadata: {}
    data:
      message: message test "{{ 42/2 }}"
  mode: single

In above code I use “42/2” instead of my actual sensor to simplify further.

The code produces a correct value for the notification of ‘21’, but pushes literally ‘{{ 42/2 }}’ to the heater, instead of evaluating it as a template.

What am I doing wrong? If templates are not supported on text.set_value, then how to achive the above (otherwise very simple) functionality?

Thanks a lot for your help, sorry for the presumably noob question. Read all the docs I found, i am at the end of my rope.

Best,
Svetko

Possible with an entity action (other actions / perform action), not with a device action. It’s the action that’s not supporting it, not the service. Avoid using device stuff as much as possible.

Here’s the entity equivalent — substitute in your real entity id, which will look like text.something not that hex string nonsense.

actions:
  - action: text.set_value
    target:
      entity_id: text.ENTITY_ID
    data:
      value: "{{ 42 / 2 }}"

Looks like this in the UI, then select Choose Entity:

1 Like

That was it! Thanks a lot.

Here’s the working code, for the sake of completeness:

- id: '1737370277520'
  alias: SendTempToElco
  description: ''
  triggers:
  - trigger: time_pattern
    minutes: /5
  conditions: []
  actions:
  - action: text.set_value
    target:
       entity_id: text.bsb_lan_00_68_user_defined_10001_raumtemperatur_heizkreis_2_degc
    data:
       value: "{{ states('sensor.shellyhtg3_54320466bc60_temperature') }}"
  - action: persistent_notification.create
    metadata: {}
    data:
      message: message test "{{ states('sensor.shellyhtg3_54320466bc60_temperature') }}"
  mode: single

Yes, started from the UI, then moved on to edit the yaml files myself. Thanks for pointing out how to do the entity action from the UI.

thanks once again.

Is there a reason you do this every 5 minutes rather than when a new value arrives? Time patterns are usually a poor design choice.

- id: '1737370277520'
  alias: SendTempToElco
  description: ''
  triggers:
  - trigger: state
    entity_id: sensor.shellyhtg3_54320466bc60_temperature
    not_to:
      - 'unknown'
      - 'unavailable'
  conditions: []
  actions:
  - action: text.set_value
    target:
       entity_id: text.bsb_lan_00_68_user_defined_10001_raumtemperatur_heizkreis_2_degc
    data:
       value: "{{ states('sensor.shellyhtg3_54320466bc60_temperature') }}"
  - action: persistent_notification.create
    metadata: {}
    data:
      message: message test "{{ states('sensor.shellyhtg3_54320466bc60_temperature') }}"
  mode: single
1 Like

Yes. The heater needs a temperature set at least every 15 mins, or it reverts back to estimating room temperature. I have no guarentee that the sensor will update so often.

Thanks for going the extra mile!

I do need to add a condition though, to check for a validity of the sensor temperature, since sending ‘unknown’ to the heater gets translated as 0.0 °C. Sending nothing if the sensor is offline will have the heater estimate the temperature - which is the desired behavior, and imo justifies the need to use time pattern. Will do that next.