You need to tell to your template sensor where it will read it’s value.
This is the state:
part of the configuration, wich obviously is NOT in your configuration.
I would recommend to read : Template - Home Assistant
Then here is what’s missing from what I’ve understood of your setup :
template:
- sensor:
- name: energy_reading
unit_of_measurement: kWh
device_class: energy
state: >-
{{ states('sensor.energy_reading') | int(default=0) }}
But, if you set an initial value to your input_number
it will go back to this value after every HA restart. You should not set the initial value, wich will lead to the input_number
to get back the last value it has before HA restart.