ha-aws-cost

Home assistant component for AWS Cost

MIT License

Stars
0
Committers
2

💰 AWS Cost for Home Assistant

The ha-aws-cost custom component interacts with AWS to get the month to date cost and forecast cost and make it available on Home Assistant. It adds two new entities:

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

It was created to give you easy access to the current cost of your AWS account.

Pre-requirements

  1. You'll need an 'Access Key ID' and a 'Secret Access Key' to set the integration up. I strongly recommend you to create a new IAM user and policy with the following permissions:

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "VisualEditor0",
                "Effect": "Allow",
                "Action": [
                    "ce:GetCostAndUsage",
                    "ce:GetCostForecast"
                ],
                "Resource": "*"
            }
        ]
    }
    

In case you don't know how to generate the credentials, please read the following documentation: Managing access keys for IAM users

Installation

Option 1: HACS

First, install the custom integration using HACS.

  1. Add the integration using HACS
  2. Restart Home Assistant

Option 2: Manual installation

  1. Download and copy the custom_components/aws_cost directory into the custom_components folder on your home assistant installation.

  2. Restart Home Assistant

Setup

Once installed, go to Settings > Devices & services > + Add integration > AWS Cost. The setup will request 4 inputs:

  1. AWS Access Key ID: Access key generated for the IAM user.
  2. AWS Secret Access key: Access Secret key generated for the IAM User.
  3. AWS Region: Your default region. As Cost Explorer is a global resource, the region will only be used to adquire the token.
  4. Update Frequency: How many times you want your data to be updated a day. The options are: Daily, Every 12 hours and Every 6 hours.

Considerations

  • AWS charges $0.01 for any request done to AWS Cost Explorer API. For more information: AWS Cost Explorer Pricing

    NOTE: Each pooling to update the entity state makes two requests to AWS CostExplorer API, using the GetCostandUsage and GetCostForecast operations.

  • 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."

    Reference: Analyzing your costs with AWS Cost Explorer

Example cards

type: horizontal-stack
cards:
  - type: custom:mini-graph-card
    name: AWS Cost
    entities:
      - entity: sensor.month_to_date_cost
        name: Cost
    icon: mdi:aws
    hours_to_show: 72
    show:
      icon: true
      name: true
      state: true
      legend: false
  - type: custom:mini-graph-card
    name: AWS Forecasted Cost
    entities:
      - entity: sensor.forecasted_month_costs
        name: Forecast
    icon: mdi:aws
    hours_to_show: 72
    show:
      icon: true
      name: true
      state: true
      legend: false
type: custom:mushroom-chips-card
chips:
- type: entity
  entity: sensor.month_to_date_cost
  icon_color: orange
  icon: mdi:aws

Cards used:

Badges
Extracted from project README
Related Projects