Help with template please!

Ok so I want to keep track of bills at home and we have a few large bills we’re paying down.

I would like to set an entity or sensor with the total value of the bill say $2000. Then I want a card that will display the total remaining with an input field where we can type in an amount we paid recently and subtract that from the total.

This way I can create cards with the current total still owed and my gf and I can update on the fly whenever we make a payment.

Any thoughts??

You can create two template sensors and one input number - one sensor for the original total, one sensor for the current remaining and one input number for the amount paid.

it depends on if you want to enter the original amount as a hardcoded number in the sensor or want to read it from an input number so you’ll need to decide that.

but set the original amount sensor to whatever value and create an automation triggered by a change in the amount paid input number to subtract that value from the current amount owed.

Or you could create a triggered sensor and do the same thing without an automation if you want (I think).

then just create a card to display all three in the frontend.

Ok so I’m following along so far, but I’m not sure how to set the template sensor to hold the current value (after something is paid to it, etc)

In essence I want the dash to always display the remaining balance after someone has updated it until it reaches 0.

I will start with the input number and one sensor and hope to get a response or figure out how to hold the current value in the other sensor

Thank you!

You can use input_numbers for all three if you want but they have the drawback of being able to be edited from the UI. I don’t think editing the original amount from there is something you might want done. If it doesn’t matter then use input_numbers for all three.

either way you do it you’ll need to use templates to do the math.

use a service call (input_number.set_value) to set the input_number new value to the template value.

the template will be basically:

{{ states('input_number.current_amount') | int - states('input_number.amount_paid') | int }}

Ok so far this is looking good.

I have a template sensor holding the total value. I have an input number that changes the total when the input number changes.

The only issue is I didn’t realize the input number displays as a slider or step counter. This means that it can always be easily reset or screwed up.

I’m hoping for something closer to a text-input where you type in say 100, hit enter and the sensor will update the total on the card and you can’t just change a slider and mess that change up.

Does that make sense? The “Bill Remainder” value should hold on whatever change I make. Right now I can click up to 100 but it’s easy to click that back down which defeats the purpose16632759691475146615935800998119|225x500

You can change the input number to input text and do basically the same thing since the state of the input number isn’t really a number even tho it looks like one which is why you need to do the conversion to the int in the template. just replace the input number with input text and then you can just type in the number.