Setting calculated number value in automation-action

Hi’ all.

I think it’s a simple issue, but I’ve read and tried a lot from posts on the same topic, but cannot get anything to work. So here goes…

I have this Action in an automation, and i would like to set the value to a calculated value from another sensor.

device_id: 6131bef6d3205523983176daf28fe781
domain: number
entity_id: number.danfoss_external_measured_room_sensor
type: set_value
value: sensor.temperature*10

Its the “value” that are bugging me. I have tried a lot with templates and similar, but cannot set the value field to anything other than a number. I’d love to get som pointers…

You are using a Device Action. Device Actions don’t support templates.

Use the number.set_value service call.

service: number.set_value
target:
  entity_id: number.danfoss_external_measured_room_sensor
data:
  value: "{{ states('sensor.temperature') | float(0) * 10 }}"
3 Likes

It works great. Much appreciated, thanks.

@123 Thanks, your answer just solved my problem.

Do you know if there’s a good bit of documentation to read about this and understand?

I’ve read Automation Trigger Variables - Home Assistant & Automation YAML - Home Assistant but not spotted this details.

You’ve read all the obvious places where one would expect to find information about Device Triggers, Conditions and Actions. Based on what I have seen in the documentation, there’s no mention of “Device Actions don’t support templates” (nor for Device Triggers and Device Conditions).

Ideally there probably should be but if there’s one thing I have learned about the documentation is that if something is not mentioned, or there’s no YAML example of it, then that “something” isn’t possible. The documentation is clear about what is possible and doesn’t (normally) delve into what isn’t.

If you look at the documentation for Device Triggers, Conditions and Actions, it’s notably brief and the reason is that they’re designed to be used exclusively via the UI (so there’s not much to write about it). If the UI disallows an operation (like employing a template) then it’s not supported.