Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Budgets as negative numbers #40

Open
giuseppebaldi opened this issue Nov 20, 2024 · 9 comments
Open

Budgets as negative numbers #40

giuseppebaldi opened this issue Nov 20, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@giuseppebaldi
Copy link

Question: I noticed that the budget entity states are brought in as negative numbers but the budget limit attribute is a positive number, is there a reason for this? I am trying to use the Bar Card to set up some budget visuals in HA but the negative/positive numbers are making it difficult (I wanted to use the budget limit as the max limit so I wouldn't have to manually enter these). Do you have any suggestions a workaround? Or can the budget and budget limit both be positive numbers (or both negative would work also)?

Also, would it be possible to bring the total budget & total spent from Firefly?

@soloam
Copy link
Owner

soloam commented Nov 20, 2024

Hello @giuseppebaldi!

The first idea for the budget sensor was to show the amount you would need to get to your objective... or if you are past it! So if you have somting on the budget, you will need to "add" money to make it full. Ate the moment I'm working on the next release, I'll probably add a checkbox to the config to make the budgets positive and not negative.

Regarding you next question, I'm adding the stats form the main page to sensors, and will be out in the next release! Is that it?

Thank you

@soloam soloam added the enhancement New feature or request label Nov 20, 2024
@giuseppebaldi
Copy link
Author

I see, that makes sense. A checkbox would be a great solution. The stats from the main page would be terrific to but I was referring to the total budget and total spent from the Budgets page, see the attached screenshot.

Thank you so much!
Screenshot 2024-11-20 180058

@soloam
Copy link
Owner

soloam commented Nov 21, 2024

That information isn't already on the attributes of the sensor? If not probably I'm looking at the in dev release! I'll try to get it out as quickly as possible!

@giuseppebaldi
Copy link
Author

I'm sorry, what I meant is the total of all the budgets added up into one sensor, along with all the limits added up and what has been spent. I have a sensor for each budget item (groceries, utilities, etc) but would like one for the total budget. I hope that make sense. Thank you!

@soloam
Copy link
Owner

soloam commented Nov 22, 2024

Oh I see now! I'll see what I can do about that, but that is something you can do with sensor template! A sum of all the values form the budgets!

@giuseppebaldi
Copy link
Author

Yes, I considered that but would have to remember to update it if I remove or add any budgets (which really wouldn't be a big deal).

@soloam
Copy link
Owner

soloam commented Nov 27, 2024

You don't need to! You could create a sensor with a Jinja mapping. Something like this:

{{ states.sensor|selectattr('attributes.fireflyiii_type', 'eq', 'budgets')|map(attribute='state')|map('float')|sum }} 

You are selecting all sensors with the "fireflyiii_type" equal to "budgets" and mapping it's state to a float and in the end making a sum!

@giuseppebaldi
Copy link
Author

Wow, I just learned something new! I've been on Home Assistant for a month or so and still learning but this is awesome, thank you!

I think I was misunderstanding how this integration worked. I thought the entities created for budget items was showing the budget I set for the month but it appears it's actually creating entities for what I've actually spent in those budgets so far, that's why they're negative numbers. I'm just realizing this because after creating the template you suggested it matched the total in Firefly III for what I've spent.

You have been very kind and helpful and I greatly appreciate it!
Screenshot 2024-11-27 143829
Screenshot 2024-11-27 143531

@giuseppebaldi
Copy link
Author

Can you possibly give me some insight into why this doesn't work (based of your previous example)?

{{ states.sensor|selectattr('attributes.fireflyiii_account_type', 'eq', 'asset_accounts')|map(attribute='state')|map('float')|sum }}

I am trying to create a sensor that would sum all asset accounts similar to the budgets you helped me with before.

TIA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants