carohauta / oma-helen-ha-integration Goto Github PK
View Code? Open in Web Editor NEWHome Assistant integration for Oma Helen data
License: MIT License
Home Assistant integration for Oma Helen data
License: MIT License
Hi there! i was able to add the values to HA energy consumption tab (after struggling for unknown reason; system wouldn't get data from helen and/or calculate with nordpool integrations price but now it at least measures) but i've gotten max 2 values per day, i.e. 9.1. i got two measurements to energy tab; 18:00 and 21:00 (15,67 kWh and 26,18kWh) and by far on 10.1. (at 21:00) i have just one at 18:00 (15,39kWh).... does it work as intended or should I get measurements for every hour of a day (i know helen seems to report data for every hour on their website)? 10.1. was the first day without any struggles with HA or energy tab.
also something is not measured right; for 9.1. energy tab shows 41,85kWh as consumption whereas Helen shows 15,39kWh... Have i done smth wrong or is there a bug?
sensors i have:
consumption: sensor.helen_monthly_consumption
used with entity with current price:
Nordpool_kwh_fi_eur_3_10_024
https://github.com/custom-components/nordpool/
Integration was working ok for a while, but a few weeks ago I started to see this in the home assistant logs:
helen_energy: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 599, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1261, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/helen_energy/sensor.py", line 555, in update
_get_total_consumption_for_current_month(self._api_client)
File "/config/custom_components/helen_energy/sensor.py", line 215, in _get_total_consumption_for_current_month
return _get_total_consumption_between_dates(helen_api_client, start_date, end_date)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/helen_energy/sensor.py", line 190, in _get_total_consumption_between_dates
helen_api_client.get_daily_measurements_between_dates(start_date, end_date)
File "/usr/local/lib/python3.12/site-packages/cachetools/__init__.py", line 641, in wrapper
v = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/helenservice/api_client.py", line 157, in get_daily_measurements_between_dates
response_json_text = get(
^^^^
TypeError: get() takes 1 positional argument but 2 were given
I've updated to the latest version of this integration, updated home assistant, and tried reinstalling the integration but it does not help.
I'm using smart guarantee sensor template.
Pitäskö olla konsistentti raha arvojen kanssa?
merkintä EUR, e ja lukujen tarkkuuden vois tarkistaa että olis aina 2 desimaalia.
pörssisähkö käytössä
helen_energy: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 521, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in async_device_update
await task
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/helen_energy/sensor.py", line 326, in update
self._contract_base_price = self._api_client.get_contract_base_price()
File "/usr/local/lib/python3.10/site-packages/helenservice/api_client.py", line 230, in get_contract_base_price
contract_components = contract_data[0]["products"][0]["components"]
IndexError: list index out of range
My guess without looking at code is that we'd be requesting the previous day of the month from the API on the first day of the month.
Does this implementation take into account that there might be few "zero" days when Helen is getting that info from another electric companies?
At least when comparing with what API return and what comes to HA these values are quite far apart. HA is showing much more negative effect than API.
This is what first came to mind since if counting 1-3 zero days you would get much greater negative effect.
Hi,
One can find info needed to integrate sensors to energy dashboard:
https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics
It is just some additional plugin values passed so that the statistics engine detects sensor type.
Hope it helps! When I have time I can type those in too into code....
I'd like to use this integration to feed my overall electricity consumption into the energy dashboard. However, I buy electricity from another company. Helen delivers the electricity though, so on Oma Helen I'm able to see my consumption. Would it be possible to add support for that?
The API request seems to be this:
https://api.omahelen.fi/v10/measurements/electricity-transfer?begin=2023-04-12T21:00:00.000Z&end=2023-05-13T20:59:59.999Z&resolution=day&delivery_site_id=123456&allow_transfer=true
Example response:
{
"intervals":{
"electricity_transfer":[
{
"start":"2023-04-12T21:00:00+00:00",
"stop":"2023-05-13T20:59:59.999000+00:00",
"resolution_s":86400,
"resolution":"day",
"unit":"kWh",
"measurements":[
{
"value":9.629999999999995,
"status":"valid"
},
{
"value":7.140000000000001,
"status":"valid"
},
{
"value":14.540000000000006,
"status":"valid"
},
{
"value":10.709999999999994,
"status":"valid"
},
{
"value":10.219999999999999,
"status":"valid"
},
{
"value":6.110000000000014,
"status":"valid"
},
{
"value":14.419999999999987,
"status":"valid"
},
{
"value":13.699999999999989,
"status":"valid"
},
{
"value":7.25,
"status":"valid"
},
{
"value":13.660000000000025,
"status":"valid"
},
{
"value":14.109999999999985,
"status":"valid"
},
{
"value":10.909999999999997,
"status":"valid"
},
{
"value":7.189999999999998,
"status":"valid"
},
{
"value":12.659999999999997,
"status":"valid"
},
{
"value":13.730000000000018,
"status":"valid"
},
{
"value":9.730000000000018,
"status":"valid"
},
{
"value":8.029999999999973,
"status":"valid"
},
{
"value":21.94999999999999,
"status":"valid"
},
{
"value":18.08000000000004,
"status":"valid"
},
{
"value":13.369999999999948,
"status":"valid"
},
{
"value":13.689999999999998,
"status":"valid"
},
{
"value":12.650000000000034,
"status":"valid"
},
{
"value":15.5,
"status":"valid"
},
{
"value":14.480000000000018,
"status":"valid"
},
{
"value":15.859999999999957,
"status":"valid"
},
{
"value":10.759999999999991,
"status":"valid"
},
{
"value":8.390000000000043,
"status":"valid"
},
{
"value":10.359999999999957,
"status":"valid"
},
{
"value":16.610000000000014,
"status":"valid"
},
{
"value":0.0,
"status":"invalid"
},
{
"value":0.0,
"status":"invalid"
}
]
}
]
}
}
The delivery_site_id
and transfer prices can be grabbed from this API:
https://api.omahelen.fi/v10/contract/list?include_transfer=true&update=true&include_products=true
Example response (heavily redacted):
{
"contracts":[
{
"delivery_site":{
"grid_company_name":"Helen Sähköverkko",
"id":123456
},
"domain":"electricity-transfer",
"end_date":null,
"products":[
{
"company":"HSV",
"components":[
{
"id":"2011P",
"name":"Perusmaksu",
"localized_name":{
"fi":"Perusmaksu",
"sv":"Grundavgift",
"en":"Basic charge"
},
"price":5.51,
"price_without_vat":4.44,
"price_unit":"eur/kk",
"localized_price_unit":{
"fi":"eur/kk",
"sv":"eur/månad",
"en":"eur/month"
},
"is_base_price":true,
"is_valid_price":true,
"component_description":null
},
{
"id":"2011E",
"name":"Siirtomaksu",
"localized_name":{
"fi":"Siirtomaksu",
"sv":"Överföringsavgift",
"en":"Distribution tariff"
},
"price":4.07,
"price_without_vat":3.28,
"price_unit":"c/kWh",
"localized_price_unit":{
"fi":"c/kWh",
"sv":"c/kWh",
"en":"c/kWh"
},
"is_base_price":false,
"is_valid_price":true,
"component_description":null
},
{
"id":"electricity_tax",
"name":"Sähkövero",
"localized_name":{
"fi":"Sähkövero",
"sv":"Elskatt",
"en":"Electricity tax"
},
"price":2.79372,
"price_without_vat":2.253,
"price_unit":"c/kWh",
"localized_price_unit":{
"fi":"c/kWh",
"sv":"c/kWh",
"en":"c/kWh"
},
"is_base_price":false,
"is_valid_price":true,
"component_description":{
"fi":"Sähkövero peritään kaikesta jakeluverkon kautta asiakkaille jaetusta sähköenergiasta. Sähkön valmistevero ja huoltovarmuusmaksu sisältyvät sähköveromaksuun.",
"sv":"Elskatt uppbärs på all elenergi som distribueras till kunderna via distributionsnätet. Elskatteavgiften består av elaccis och försörjningsberedskapsavgift.",
"en":"Electricity tax is levied on all electric energy distributed to customers through the distribution network. The excise tax on electricity and strategic stockpile fee are included in the electricity tax charge."
}
}
],
"id":"2011",
"name":"Yleissiirto",
"localized_name":{
"fi":"Yleissiirto",
"sv":"Allmän överföring",
"en":"General distribution"
},
"price_list_id":"1",
"is_temporary_product":false,
"product_type":"transfer",
"product_subtypes":[
],
"start_date":"2022-01-01T00:00:00",
"end_date":null,
"product_info_link":null,
"product_description":null,
"components_description":null
}
],
"start_date":"2022-01-01T00:00:00"
}
]
}
Hello,
First of all thanks for implementing an option to chose delivery_site_id!
I have multiply contracts, so after setting the correct delivery_site_id, it looks like
helen_exchange_energy_last_month_total_cost is showing an incorrect value of "18", while OmaHelen shows the consumption for February as follows:
Energy cost: 13,62
Distribution: 8,18
Tax: 5,62
Any idea on what might cause this?
If have multiple contracts look that integration return values from newest. Is there way to way to select contract e.g. using contract number?
Logger: homeassistant.components.sensor
Source: custom_components/helen_energy/sensor.py:320
Integration: Sensor (documentation, issues)
First occurred: 11:39:24 (1 occurrences)
Last logged: 11:39:24
helen_energy: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 503, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 729, in async_device_update
await task
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/helen_energy/sensor.py", line 320, in update
self._api_client.calculate_total_costs_by_spot_prices_between_dates(
File "/usr/local/lib/python3.10/site-packages/helenservice/api_client.py", line 67, in calculate_total_costs_by_spot_prices_between_dates
hourly_consumption_costs = self._get_hourly_consumption_costs(start_date, end_date)
File "/usr/local/lib/python3.10/site-packages/helenservice/api_client.py", line 49, in _get_hourly_consumption_costs
hourly_measurements = self.get_hourly_measurements_between_dates(start_date, end_date).intervals.electricity[0].measurements
IndexError: list index out of range
Home Assistant 2023.1.4 Supervisor 2022.12.1 Operating System 9.4 Frontend 20230110.0 - latest
Helen current month consumption is "unknown"
My contract for Exchange electricity started 15.1 - if that's related I can just wait for the beginning of the next month if needed. I'm happy to gather whatever information you may need to look at this. Thanks!
Is Helen's API at all similar to the Väppi API? https://api.vappi.fi
I'm looking into getting electricity usage to my HA instance and found this. If there is any similarities I could use this add-on as a starting point.
Ensinnäkin iso kiitos tästä integraatiosta, hienoa työtä.
Kuten on tiedossa sähkötiedot päivittyvät välillä usean päivän viiveellä, siksi olisi mukava lisätieto, että kuluvan kuun ennusteen yhteydessä olisi tarjolla myös päivämäärä jonka avulla tietaa mihin asti dataa on olemassa.
Hei!
When I initially set this up it works fine, however if I reboot home assistant I get an error in the log to check my credentials, however if I log into oma helen portal myself before rebooting home assistant it works fine, am I missing something here or is this actually a bug? My home assistant instance gets rebooted semi often and I'll likely forget I need to log in to the portal, so I'd like to avoid that if possible 😅
Home Assistant 2023.7.2
Supervisor 2023.07.1
Operating System 10.3
Frontend 20230705.1 - latest
Hi, i have helen exchange contract, and all works just fine. But i noticed that all energy data is downloaded for the wrong days. In home assistant, it shows yesterdays energy consumption as todays energy consumption.
Käytän HA:ssa sitä default dashboardia, jonka siis HA configuroi eli en käytä myöskään lovelace kortteja.
Aikaisemmin data oli kivasti samassa lattikossa jonka nimi on Helen.
Nyt kun tämä näyttää myös kuukausikulutuksen ja siirto kulut niin nämä tiedot löytyvät Sensors laattikosta HA:ssa. Miten saisin kaiken tämän integraation datan samaan laatikkoon?
Ajattelin kysyä, kun taitaa olla helpompi että integraatioon muuttaa jotain?
Entity not available: sensor.helen_exchange_electricity
Installed the addon yesterday. Using the exchange -model and correct id for the place is used. Also of course the username and password has been set.
However the data looks like this...
My monthly usage is 2000-3000 kWh and when checking the Helen app, or their site the usage is looking right. What I am missing here? Template is the one that is on the instructions page .
the id has been changed to xxxxxxxxxx here, in real conf it is set to my delivery_site_id
sensor:
Saako sieltä tietoa mahdollisesti myös siirtomaksusta?
Not sure if this might be because I'm new customer to Helen and old data not found.
Running:
Home Assistant 2023.8.4
Supervisor 2023.08.3
Frontend 20230802.1 - latest
`Logger: homeassistant.components.sensor
Source: custom_components/helen_energy/sensor.py:153
Integration: Sensor (documentation, issues)
First occurred: 17:13:30 (2 occurrences)
Last logged: 17:13:36
helen_energy: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 576, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 940, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/helen_energy/sensor.py", line 512, in update
_get_total_consumption_for_last_month(self._api_client)
File "/config/custom_components/helen_energy/sensor.py", line 172, in _get_total_consumption_for_last_month
return _get_total_consumption_between_dates(helen_api_client, start_date, end_date)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/helen_energy/sensor.py", line 153, in _get_total_consumption_between_dates
helen_api_client.get_daily_measurements_between_dates(start_date, end_date)
File "/usr/local/lib/python3.11/site-packages/cachetools/init.py", line 641, in wrapper
v = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/helenservice/api_client.py", line 151, in get_daily_measurements_between_dates
daily_measurement: MeasurementResponse = MeasurementResponse(
^^^^^^^^^^^^^^^^^^^^
TypeError: MeasurementResponse.init() got an unexpected keyword argument 'detail'`
2023-09-06 16:51:45.485 ERROR (MainThread) [homeassistant.components.sensor] helen_energy: Error on device update! File "/config/custom_components/helen_energy/sensor.py", line 750, in update File "/config/custom_components/helen_energy/sensor.py", line 178, in _get_total_consumption_for_current_month File "/config/custom_components/helen_energy/sensor.py", line 153, in _get_total_consumption_between_dates
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.