Kwh Countdown/ Subtract from Input Kwh

I`m looking for a template or sensor to countdown a manualy Input number by a user

For instance: I got the Utility meter counting Daily and Monthly Kwh.
Now our Electricity is prepaid and if I buy 100Kwh… I would like to put it in Manualy and let the Daily counter subtract from the Input made.

Any help making this posible ?
Thnx in advance.

Hi, i found something i am using, might not be exactly what you are looking for.
I have a prepaid meter and a esp8266 send the kWh "pulses to HA.

I integrated it using this guy’s firmware.

You can input the actual kWh reading from your meter on the esp8266 web I/F and it will sent it to HA via mqtt