Insert sensor value into input_number

Is it possile to insert a sensor value into another component with an automation or script? for example sensor.temperature into input_number??

I want an input_number that can show me the temperature in a area what it was 1 hour ago with an automation that runs once every hour.

Like below
service: input_number.set_value

  service: input_number.set_value
  - data:
  entity_id: input_number.hour_ago
  value: {{ states('sensor.utomhus_temperature') }}

Close. Try:

  service: input_number.set_value
  entity_id: input_number.hour_ago
  data_template:
    value: "{{ states('sensor.utomhus_temperature') }}"

Can this automation be done in the gui? What action should I choose? I only got Condition, delay, fire event, call service and wait …hmmmm

I don’t use the GUI to create/edit automations, so can’t really say, but I would guess so. Basically you want to trigger every hour, and the action would be calling a service (i.e., input_number.set_value, with the data as has been discussed.)

If you enter it manually, it should look something like this:

automation:
  - alias: Save temperature once an hour
    trigger:
      platform: time
      minutes: 0
      seconds: 0
    action:
      service: input_number.set_value
      entity_id: input_number.hour_ago
      data_template:
        value: "{{ states('sensor.utomhus_temperature') }}"

The trigger will fire every hour on the hour (because the trigger matches when minutes and seconds are both zero, but the hour is not specified and so will match every hour.)

2 Likes

Now I realised that the GUI sucks for advanced use. I just unlocked a whole new world of automation by doing it the “matrix-way” in the yaml, everything works thanks to you! Many thanks from Sweden! :smiley:

1 Like