Skip to content

AWS Cost – My First Home Assistant Integration

A few months ago I embarked on the journey of automation my house as much as possible, and as everyone else, I faced the main challenge of it: How can I manage all my smart devices from many brands in a single interface? And that’s how I met Home Assistant, an open-source project that solved my problem and much more.

After moving on from smart devices, I realized that the platform offers thousands of integrations with many services, including some AWS resources such as Lambda and CloudWatch, but no integration with Cost Explorer. And I wondered why.

Think about it: I, as a cloud enthusiast, have a number of resources on AWS for testing, personal services, and even this blog, so keeping track of the costs of my personal AWS account is very important if I don’t want to ruin the family budget. So why not have this information available in a dashboard that I log into several times a day?

This could give me the information quickly, without the necessary bureaucracy of logging into the console, MFA, querying data from billing portal and so on. So I didn’t think twice, and decided to develop the integration myself.

The AWS Cost Integration

The integration adds two new entities to Home Assistant:

  • Month to date cost: The current cost of your AWS account
  • Forecasted month costs: The forecasted cost based in your current consumption

With this two new entities, you are able to have the current cost and also the history of changes, so you can be aware of any spikes (even small ones). This is how I’m using it on my dashboards:

Badge:

The small badge is always on my home screen, so every time I go to Home Assistant, I face this information right the way.

Charts:

If the number on the badge looks weird to me, I jump to my detailed view to see when the peak was. Usually, I either forgot to delete a resource from any experiment or it’s just a late dump from the AWS Cost Explorer.

Would you like to use it? Just click:

Or find it at: https://github.com/diego7marques/ha-aws-cost

You should know:

  • AWS charges $0.01 for any request done to AWS Cost Explorer API and each pooling to get the latest data will do at least 2 API calls (one for each entity).
  • The costs shown may not always be up-to-date, as AWS explains:

“Cost Explorer refreshes your cost data at least once every 24 hours. However, this depends on your upstream data from your billing applications, and some data might be updated later than 24 hours.”

Roadmap

  • Add a new entity for “Last Month Cost”
  • Add support for AssumeRole instead of App Secret and Key
  • Smart notifications for new resources (to avoid forgotten resources) – Maybe using AI.

Feel free to contribute or suggest any new features 🙂


Discover more from contains(cloud)

Subscribe to get the latest posts sent to your email.

Published inAWSHome Assistant

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *