How to set one input number equal to another

I am trying to do something that should be very simple.
That is assigning a new value to an input_number object,
Its a basic electricity twin tariff meter to go with the energy dashboard. I have set up three helpers.

input_number.tariff_now ($/kWh)
input_number.tariff_peak ($/kWh)
input_number.tariff_offpeak ($/kWh)

and set the tariff in the energy dashboard as
input_number.tariff_now ($/kWh)

Then a couple of timers to set peak on and peak off times.
Then we have a simple automation that changes tariff_now to a fixed number, and this works:

alias: Peak tariff OFF
description: ""
triggers:
  - trigger: time
    at: input_datetime.tariff_peak_off
conditions: []
actions:
  - action: input_number.set_value
    metadata: {}
    data:
      value: 0.2532 ***<<<<<<this a fixed number***
    target:
      entity_id: input_number.tariff_now
mode: single

In essence, what I want to do is assign by altering the marked line above to something like:

value: input_number.tariff_offpeak  <<<this is a variable

This doesn’t work, nor do the huge number of other similar modifications. I have looked ad nauseam (over days actually) for a usable example. The explanations never say why they do what they do, none seem to work either.

So, can anyone tell me how to do this amazingly simple thing which is actually nothing more than

a = b (or better a :=b) ??

alias: Peak tariff OFF
description: ""
triggers:
  - trigger: time
    at: input_datetime.tariff_peak_off
conditions: []
actions:
  - action: input_number.set_value
    metadata: {}
    data:
      value: "{{ states('input_number.tariff_offpeak') }}"
    target:
      entity_id: input_number.tariff_now
mode: single
2 Likes

Very many thanks, most hugely appreciated.
I tried several versions of this, but none had quite the right combination of parentheses.
Yes, I did read “Templating” which is probably excellent if you know all about how it works, and is no help if you do not.

OK so now it would be really great to understand what the syntax is doing, so I (really) would be eternally grateful if you could explain.
I am guessing

/value/ 	is a string so 
""             tells the system inside is to be read as a string.
{{ ..		I think implies inside is a bit of python/programming stuff 
/states(/   no real idea what the states of the object is other than a number
'..		I would think was another string conversion.

Can you explain why this exact syntax is needed?
Note this is not actually for this specific item, but to try and get inside the head of the system/language/logic so it’s easier to interpret other examples. It would make quite a difference.

Rule #1 from the docs I linked previously…

HA Docs - Building Templates - States

OK, I have looked at the state object.
The syntax is not entirely clear to me.
I am assuming that input_number.tariff_peak is the state “input_number” of the object “tariff_peak”.
As well as the state state.
It would then have other states such as “units” as well as a timestamp.
Logically, then there should be a units.tariff_peak for example.
It would appear that there is a ‘state’ of the object which here would be a number.
But you used “states”, ah well.
Interestingly, the documentation doesn’t mention the names to call up the states of a state object that I can see.
Most programming languages have the state name following the object name.
I’m sure its perfectly obvious once you explain some of it.

input_number.tariff_peak is the entity ID.

Like all entity IDs, it is composed of two parts; input_number is the domain, and tariff_peak is most often called the object ID.

Glossary - State

As shown in the HA Docs - Building Templates - States linked previously, states() is a function in HA’s Jinja Template implementation that expects an entity ID string as the first argument and returns the value of the state property from the state object of that entity.

The state object of any entity will contain a minimum of 4 properties: state, last_updated, last_changed, and last_reported. Most entities will also contain a property attributes that contains a mapping of secondary information.

You can find the values for the state and attributes for each of your entities in the States tool.