Amber Electric Usage custom component

UPDATE JUN 2024: I have left Amber recently due to the market volatility, I might come back to Amber in the future when things get better. But for now, I will no longer be able to support if there are changes in either how Amber APIs work or HA Statistics.

If you live in Australia, joined Amber because of its nice and transparent APIs (like me), and don’t have a whole house energy monitoring device. Hope this custom component gives you a bit of a remedy. GitHub - Tmbao/amberelectric-usages

The main feature is that it fetches the energy usages from Amber API, and populates them retrospectively to HA statistics, so that you can see them easily in your HA energy dashboard.

The setup flow is similar to the component built into HA core. After that, you’ll get some statistics for your electricity usage and cost. It’s subject to the limitation of the usages in Amber app, data will be delayed and only available on the next day. Also a limitation of retro data is that it cannot be more granular than hourly, but Amber data is only per 30 min interval anyway.

Enjoy!

Edit, installation guide:

  1. Make sure that you’ve had HACS installed (see here for instructions)
  2. Once HACS is installed, add the amberelectric-usages github repo as a custom repository, then you should be able to find this integration (amberelectric-usages) via HACS
  3. Once you’ve downloaded the integration, make sure to restart your home assistant,
  4. Come to Devices & Services in your Settings, hit Add Integration and find Amber Electric Usages. You’ll need the API key to use this integration, which can be obtained following this other instruction.
2 Likes

Oh, nice!

Are you saying that the usage stats don’t normally come through the default Amber sensors, so this component makes extra API calls to retrieve the usage information?

Yes that’s correct

Hey thanks for putting this together. I have both the amber integration and now the usage integration installed. And I have usage appearing in the energy dashboard using this integration. I have two questions you may have already solved for ;

(1) When you setup the energy dashboard with the usage sensor, is it possible to also add the amber general price to the energy dashboard associated with that usage? I assume that it is difficult because the usage is delayed and price data is realtime sensors.

(2) I have Home Assistant setup to export sensors to InfluxDB for a longer time view. This includes the amber integration realtime price etc sensors. I dont think the usage data from this integration will go into Influxdb as there are no associated sensors. Do you know any easy / alternate way to direct the usage data from this integration to Influxdb?

Thank you.

Hey, thanks for this.

I am new to Home Assistant. Just wondering, how should I install and use this component for getting the kind of dhasboard that you have shown?

Appreciate all the help.

Cheers.

Update: I figured it out. Thanks for your amazing work

1 Like

Can you please tell me how you did it? I am still trying to work it out. Thanks.

I would like some help too. Thankyou.

Hi at which step are you currently struggling?

Edit: I’ve updated the original thread with some instructions

Hi, when I tried to search for amberelectric-usages in HACS, nothing comes up. Can someone please advise?
thanks

Oh sorry I forgot one step, you’ll need to add the github repo to your HACS custom repositories
image

Thanks I’ve done that now, but when adding as integration, I get a failed setup, will retry message after I enter my Amber API key and select my NMI.

Just another bit of info, when I hover over “failed setup”, as per above screenshot, it says Invalid statistic_id. Not sure if that provides any clues as to why my integration isn’t working. Sorry I’m fairly new to using home assistant, so any help is greatly appreciated!

That’s all good, in your Settings > System > Logs, you should be able to find more details about the issue. Can you share that specific logs that related to amberelectric usages here, I can help diagnose the issue

The only entity I have is “amber usages latest time”. There is no other data?

The integration writes directly to HA statistics so you wouldn’t find them under the entities linked to the integration (due to some limitation of writing historical data in HA).

To find the statistics, go to Developer Tools > Statistics and search for amber. However, these statistics can be used in your energy dashboard :slight_smile:

Thank you .

This is the log. I can’t seem to add the usage in my normal history-graphs cards.

This error originated from a custom integration.

Logger: custom_components.amberelectric_usages
Source: helpers/update_coordinator.py:315
integration: Amber Electric - Usages (documentation, issues)
First occurred: 7:21:32 AM (136 occurrences)
Last logged: 10:26:43 AM

Unexpected error fetching amberelectric_usages data: Invalid statistic_id
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 315, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/config/custom_components/amberelectric_usages/coordinator.py”, line 82, in _async_update_data
await self._insert_usage_statistic(usages_by_hour_by_channel)
File “/config/custom_components/amberelectric_usages/coordinator.py”, line 132, in _insert_usage_statistic
async_add_external_statistics(self._hass, metadata, statistics)
File “/usr/src/homeassistant/homeassistant/components/recorder/statistics.py”, line 2246, in async_add_external_statistics
raise HomeAssistantError(“Invalid statistic_id”)
homeassistant.exceptions.HomeAssistantError: Invalid statistic_id

Maybe it’s similar to Invalid statistic_id · Issue #4 · Tmbao/amberelectric-usages · GitHub.

I think I updated the implementation to work with uppercases, not sure which version you’re in. If it still doesn’t work with uppercase characters, you might try to remove and readd the integration with a lowercase only name

This is also happening to me. Picks up my NMI so I know my API key is working.

tried with lowercase and no spaces and it worked