sindrebroch / ha-elvia Goto Github PK
View Code? Open in Web Editor NEWCustom components for HomeAssistant to fetch grid-rent
Custom components for HomeAssistant to fetch grid-rent
Lurer på om jeg misforstår noe, eller så er forbruksleddet feil. HA viser 0,431 NOK/kWh mens Elvia sier Energileddet er 35,29øre/kWh nå på dagen, eller er ikke de to tingene det samme?
Hi. Is this still being updated? I'm having trouble setting it up. I'm able to enter id and api key, but after that the component seems defunct. I'v enabled debug logging, see below.
Version of HASS: Home Assistant Core 2022.6.7
v0.1.0 installed via HACS.
Error on setup.
I've created an API key for this product: GridTariffApi
2022-07-07 22:55:13 DEBUG (MainThread) [custom_components.elvia] POST-request to url=https://elvia.azure-api.net/grid-tariff/api/1/tariffquery/meteringpointsgridtariffs. data={ "meteringPointIds": [ "707***" ] }. headers={'Content-Type': 'application/json', 'Ocp-Apim-Subscription-Key': '344***'}
2022-07-07 22:55:25 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Elvia for elvia
File "/root/.homeassistant/custom_components/elvia/api.py", line 80, in api_wrapper
File "/root/.homeassistant/custom_components/elvia/api.py", line 99, in api_wrapper
File "/root/.homeassistant/custom_components/elvia/__init__.py", line 26, in async_setup_entry
File "/root/.homeassistant/custom_components/elvia/api.py", line 134, in meteringpoint
File "/root/.homeassistant/custom_components/elvia/api.py", line 54, in post
File "/root/.homeassistant/custom_components/elvia/api.py", line 101, in api_wrapper
custom_components.elvia.api.ApiClientException: Timeout error fetching information from https://elvia.azure-api.net/grid-tariff/api/1/tariffquery/meteringpointsgridtariffs
Hi,
I saw you requested suggestions for values to expose to HA.
Below is a list of values that I fetch from Elvia by rest-sensor and use.
Form:
/customer/metervalues/api/v2/maxhours
Params:
calculateTime:
first day of next month (e.g. if September ,then 2022-10-01)
Used parameters:
state: meteringpoints[0].maxHoursAggregate[0].maxHours[0]
attributes:
- startTime
- endTime
- uom
- verified
state: meteringpoints[0].maxHoursAggregate[0].maxHours[1]
attributes:
- startTime
- endTime
- uom
- verified
-
state: meteringpoints[0].maxHoursAggregate[0].maxHours[3]
attributes:
- startTime
- endTime
- uom
- verified
-
state: meteringpoints[0].maxHoursAggregate[0].averageValue
attributes:
- maxHoursCalculatedTime
- maxHoursFromTime
- maxHoursToTime
- maxHoursAggregate
All the above values are used to graph current cost threshold
Form:
/grid-tariff/digin/api/1/tariffquery/meteringpointsgridtariffs
payload:
{
range: today/tomorrow
meteringPointIds: myId
}
Used parameters:
state: gridTariffCollections[0].gridTariff.tariffPrice.hours[n].total
attributes:
- hours
The state is the current hour value from the today query.
The hours
attribute is the complete array/json
By combining today/tomorrow query, it is possible to make graph trend together with Tibber values, reflecting what you actually pay for the power.
0.3.0
Add your logs here.
The integration is claiming the user is in the 10-15 kWh/h
category even though it shows the average is <10kWh/h and the three current max hours confirm the calculation.
Perhaps there is some sort of rounding that pushes everyone with 9.5+ kWh/h average onto the higher bucket?
Add your logs here.
To make it easier to use this component in automations it would be great to have the current max level of the tariff as a numeric attribute.
Today the sensor.fixed_price_level_info have for example name "Power consumption: 5-10 kWh/h" so what I would like is a sensor/attribute that says "10".
Is your feature request related to a problem? Please describe.
The daily_tariff attribute shows today's price, which is great! Thank you for that. It would be very useful if it could show also tomorrow's tariff. I could then merge that tariff with the Nordpool plugin's tariff, to get total electricity price for the upcoming period.
Describe the solution you'd like
One option is to expand daily_tariff attribute with a "tomorrow_tariff", showing tariff for tomorrow, with the same format as daily_tariff. Or maybe easier, just expand daily_tariff with an additional 24 hours.
Describe alternatives you've considered
I can use a template to calculate the current Elvia price to fetch the current cost of electricity. But I have a graph showing future cost, using data from Nordpool. That cost data does not include the price from Elvia. I could possibly create some manual sensor fetching data create by a Python script somewhere, but that would be very hacky.
Additional context
I did look at the code and I do know some Python, but I have a very hard time figuring out how these plugins work. This is far above my league. So although I'd love to make a PR, I do have to admit I do not have the competence. And it is fully OK if you chose to not prioritise this, for whatever reason.
Thanks for a great plugin!
Hi!
Not sure what logs i can help with. But each time i restart home assistant or the integration itself it generates new sensors and the old one goes unavailable.
Happens to all 4 sensors.
I am using the Nordpool component (https://github.com/custom-components/nordpool) for fetching spot prices. That integration have an array of the price for each hour. It would be simpler to compute total cost of electricity if this component did the same. I find the entire utility meter/tariff/cost tracking in Home Assistant to be poorly designed and not really suited for a price scheme that changes each hour but I have still managed to get energy price per hour. If the "nettleie" was also available in such an array it would be easy to include that as well in my setup.
Realeas v0.1.3
I'm able to install the integration, and metering point and API Key seems to be ok (got a Connection ok message when setting up the integration).
Error setting up entry Elvia for elvia
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/elvia/__init__.py", line 26, in async_setup_entry
data = await api.meteringpoint()
File "/config/custom_components/elvia/api.py", line 148, in meteringpoint
return GridTariffCollection.from_dict(collection)
File "/config/custom_components/elvia/models.py", line 423, in from_dict
gridTariff=(GridTariff.from_dict(data["gridTariff"])),
File "/config/custom_components/elvia/models.py", line 341, in from_dict
tariffType=(TariffType.from_dict(data["tariffType"])),
TypeError: 'NoneType' object is not subscriptable
v0.1.4
Setup using UI, not yaml.
After reboot of HA, the add-on is failing to load at boot. Reloading the add-on solves the problem.
I can reproduce the issue. Maybe allow longer timeout?
Logger: homeassistant.config_entries
Source: custom_components/elvia/api.py:105
Integration: Elvia (documentation, issues)
First occurred: 22:30:41 (1 occurrences)
Last logged: 22:30:41
Error setting up entry Elvia for elvia
Traceback (most recent call last):
File "/config/custom_components/elvia/api.py", line 81, in api_wrapper
response = await self._session.request(
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 559, in _request
await resp.start(conn)
File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 898, in start
message, payload = await protocol.read() # type: ignore[union-attr]
File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 616, in read
await self._waiter
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/config/custom_components/elvia/api.py", line 80, in api_wrapper
async with async_timeout.timeout(10):
File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 129, in __aexit__
self._do_exit(exc_type)
File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 212, in _do_exit
raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/elvia/__init__.py", line 26, in async_setup_entry
data = await api.meteringpoint()
File "/config/custom_components/elvia/api.py", line 143, in meteringpoint
response = await self.post(
File "/config/custom_components/elvia/api.py", line 58, in post
return await self.api_wrapper(
File "/config/custom_components/elvia/api.py", line 105, in api_wrapper
raise ApiClientException(
custom_components.elvia.api.ApiClientException: Timeout error fetching information from https://elvia.azure-api.net/grid-tariff/digin/api/1/tariffquery/meteringpointsgridtariffs
0.3.0
Manually added only logging definition:
logger:
default: info
logs:
custom_components.elvia: debug
After entering information when adding new integration, error message was: "Failed to connect." Debug log is below. Proper Metering point ID and API token are passed (removed for sec.reasons when pasting log).
2023-10-09 13:09:44.436 DEBUG (MainThread) [custom_components.elvia] POST-request to url=https://elvia.azure-api.net/grid-tariff/digin/api/1/tariffquery/meteringpointsgridtariffs. data={ "range": "today", "meteringPointIds": [ "XXX" ] }. headers={'Content-Type': 'application/json', 'Cache-Control': 'no-cache', 'X-API-Key': 'XXX'}
2023-10-09 13:09:44.618 DEBUG (MainThread) [custom_components.elvia] Status 200 OK
2023-10-09 13:09:44.618 DEBUG (MainThread) [custom_components.elvia] GridTariffCollection={'gridTariff': None, 'meteringPointsAndPriceLevels': [{'currentFixedPriceLevel': {'id': None, 'levelId': None}, 'meteringPoints': [{'meteringPointId': 'XXX', 'levelValue': None, 'lastUpdated': '0001-01-01T00:54:00+00:54'}]}]}
2023-10-09 13:09:44.619 DEBUG (MainThread) [custom_components.elvia] GridTariff=None
0.3.0
Add your logs here.
Not loading. Not sure if this happened after upgrading to 2024.1 beta or if this happened before, but from the logs it looks like it does not work in the beginning of the year, in this case January 2nd.
2024-01-02 21:59:54.992 DEBUG (MainThread) [custom_components.elvia] Maxhour not found for day 2 in month
2024-01-02 21:59:54.992 DEBUG (MainThread) [custom_components.elvia] Finished fetching elvia data in 0.199 seconds (success: True)
2024-01-02 21:59:54.994 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up elvia platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/elvia/sensor.py", line 71, in async_setup_entry
ElviaMaxHourAverageSensor(coordinator, True),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/elvia/sensor.py", line 156, in __init__
super().__init__(coordinator, description, "elvia")
File "/config/custom_components/elvia/sensor.py", line 97, in __init__
description.key = f"{key_prefix}_{description.key}"
^^^^^^^^^^^^^^^
File "<string>", line 4, in __setattr__
dataclasses.FrozenInstanceError: cannot assign to field 'key'
2024-01-02 22:00:07.886 DEBUG (MainThread) [custom_components.fresh_intellivent_sky] Finished fetching fresh_intellivent_sky data in 1.847 seconds (success: True)
2024-01-02 22:00:30.145 DEBUG (MainThread) [custom_components.fresh_intellivent_sky] Finished fetching fresh_intellivent_sky data in 2.107 seconds (success: True)
Fra logg:
`Logger: homeassistant.config_entries
Source: custom_components/elvia/models.py:341
Integration: Elvia (documentation, issues)
First occurred: 18:20:54 (2 occurrences)
Last logged: 18:31:16
Error setting up entry Elvia for elvia
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/elvia/init.py", line 27, in async_setup_entry
data = await api.meteringpoint()
File "/config/custom_components/elvia/api.py", line 155, in meteringpoint
return GridTariffCollection.from_dict(collection)
File "/config/custom_components/elvia/models.py", line 423, in from_dict
gridTariff=(GridTariff.from_dict(data["gridTariff"])),
File "/config/custom_components/elvia/models.py", line 341, in from_dict
tariffType=(TariffType.from_dict(data["tariffType"])),
TypeError: 'NoneType' object is not subscriptable`
Hi!
After upgrading to 2024.1 the Elvia integration stopped working. I restored a backup (to version 2023.12.4) and it started working again.
Unfortunately I did not keep the logs from 2024.1, but if you want me to I can reinstall that version and get the error messages in the log for you.
Detected integration that called async_setup_platforms instead of awaiting async_forward_entry_setups; this will fail in version 2023.3.
Please report issue to the custom integration author for elvia using this method at custom_components/elvia/init.py, line 40: hass.config_entries.async_setup_platforms(entry, PLATFORMS)
Hi, thank you for the great work on this. It saved me a lot of time so i did not have to create this myself :-)
What would have been great (if possible, I have not programmed much against Home Assistant before) was if the component updated one minute after each new hour. This would make the "forbruksledd" more accurate since as far as I can tell the data is now updated once every hour after a restart of Home Assistant so the "forbruksledd" is delayed when it is changing.
Hei.
Fikk plutselig denne etter å ha oppdatert til siste core-versjon som 2023.3.0. Også Tibber-integrasjonen gikk ned. Hentet tilbake tidligere versjon, men fortsatt feil. Forsøkt å legge inn integrasjon på nytt. Hjalp ikke. Tibber kom tilbake.
Hi, searching for "elvia" in HACS results in no hits.
Only the exact sting "sindrebroch/ha-elvia" works.
It would be great if you could add an option to show the price in cents (To get Øre/Kwh)
for the 'energy_price' (including the attributes) and 'fixed_price_hourly'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.