Coder Social home page Coder Social logo

amberelectric-usages's People

Contributors

tmbao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

amberelectric-usages's Issues

Invalid statistic_id

Hi @Tmbao, I'm getting this 'Invalid statistic_id' error after adding it to integration.
I was able to seelct NMI and see it got initialised for a sec, then failed.

Is there any step I have missed?

2024-02-19 09:47:03.288 DEBUG (MainThread) [custom_components.amberelectric_usages] Fetched new Amber data: [{'duration': 30.0, 'spot_per_kwh': 7.44951, 'per_kwh': 14.8836, 'date': datetime.date(2024, 1, 22), 'nem_time': datetime.datetime(2024, 1, 22, 0, 30, tzinfo=tzoffset(None, 36000)), .......
2024-02-19 09:47:03.409 DEBUG (MainThread) [custom_components.amberelectric_usages] Updating amberelectric_usages:HomeAddress_usages_e1
2024-02-19 09:47:03.435 ERROR (MainThread) [custom_components.amberelectric_usages] Unexpected error fetching amberelectric_usages data: Invalid statistic_id
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 313, 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 2239, in async_add_external_statistics
    raise HomeAssistantError("Invalid statistic_id")
homeassistant.exceptions.HomeAssistantError: Invalid statistic_id
2024-02-19 09:47:03.446 DEBUG (MainThread) [custom_components.amberelectric_usages] Finished fetching amberelectric_usages data in 4.235 seconds (success: False)

Version:
HACS Integration version: 1.34.0

Core: 2024.2.2
Supervisor: 2024.01.1
Operating System: 11.5
Frontend: 20240207.1

Save usage data as sensor attribute data instead

Hi @Tmbao, thanks for making this available. My use case is very close, but not the same as yours - I have sensors for power and energy flow which are available in real time and populate my energy dashboard, but I would still like to get the Amber usage information into my home assistant instance for additional analysis (as it is what is actually being billed).

I've tried to access the usage information directly from the API, but unfortunately the structure doesn't work well with the restful sensor because the json is a list (of dictionaries) rather than a dictionary itself.

Is there an easy way to save the usage information from the API as attributes of a sensor, rather than insert them into the home assistant statistics (either directly, or by simplifying your custom_component)? Attributes something like the structure pasted at the end of this post would be useful as it can be graphed directly with apex charts-card and is also easily manipulated in templates or python scripts.

Thanks, Fred

Usage:
  - type: Usage
    duration: 30
    date: "2023-12-08"
    endTime: "2023-12-07T14:30:00Z"
    quality: billable
    kwh: 0.191
    nemTime: "2023-12-08T00:30:00+10:00"
    perKwh: 23.55448
    channelType: general
    channelIdentifier: E1
    cost: 4.4989
    renewables: 6.199000000000001
    spotPerKwh: 7.85292
    startTime: "2023-12-07T14:00:01Z"
    spikeStatus: none
  - type: Usage
    duration: 30
    date: "2023-12-08"
    endTime: "2023-12-07T15:00:00Z"
    quality: billable
    kwh: 0.209
    nemTime: "2023-12-08T01:00:00+10:00"
    perKwh: 23.34667
    channelType: general
    channelIdentifier: E1
    cost: 4.8795
    renewables: 6.45
    spotPerKwh: 7.65591
    startTime: "2023-12-07T14:30:01Z"
    spikeStatus: none
  - type: Usage
    duration: 30
    date: 2023-12-08
    endTime: "2023-12-07T15:30:00Z"
    …

Adjust for time zone?

I assume because I am in NSW which is currently on daylight savings time (so UTC+11), rather than the NEM time at UTC+10. Is there any way to fix to correct for time zone? I assume people in VIC/SA will have the same issue?

Btw, love this add-on

Failing to load intergration

Hi,

I have installed this integration on a newly commissioned amber site and I am getting the following error. The site only has 2 days worth of data, so I am not sure if this is a problem or if it is something else.

This is the error message I am getting.

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: 11 May 2024 at 16:16:27 (944 occurrences)
Last logged: 13:15:57

Unexpected error fetching amberelectric_usages data
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 2251, in async_add_external_statistics
raise HomeAssistantError("Invalid statistic_id")
homeassistant.exceptions.HomeAssistantError: Invalid statistic_id

State class not matching device class error

Having an issue when trying to use this. I've uploaded the amberelectric_usages directory to the custom_components directory. Added the service via Devices & Services > Add Integration, filled in the API Key, selected the NMI, and can see it gets initialised. But no data is ever populated into statistics, the entity never gets any data in it (ie recording the last date time refreshed). I then looked in the logs and I can see the below.

I'm not manually configuring this via the configuration.yaml file, so it can't be that.

Log Output

Entity sensor.[entityid]_usages_latest_time (<class 'custom_components.amberelectric_usages.sensor.AmberUsagesLatestDataSensor'>) is using state class 'measurement' which is impossible considering device class ('timestamp') it is using; expected None; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/Tmbao/amberelectric-usages/issues

Note that I've replaced my actual entityid with [entityid].

Version Info

Core: 2024.1.5
Supervisor: 2023.12.1
Operating System: 11.4
Frontend:20240104.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.