linsvensson / sensor.greenely Goto Github PK
View Code? Open in Web Editor NEWCustom component to get usage data and prices from Greenely for Home Assistant
License: Apache License 2.0
Custom component to get usage data and prices from Greenely for Home Assistant
License: Apache License 2.0
Funktionen GreenelyAPI.get_usage returnerar inte hur mycket man använt - den returnerar hur mycket man köpt. Eftersom jag även har egen produktion av solel så ger interfacet mig inte vad jag vill ha (jag vill veta hur mycket jag förbrukat oavsett om det var egenproducerat eller köpt).
I greenelys app kan jag se hur mycket jag själv procuderat, använt, sålt och köpt. Har man tillgång till tre av de fyra så kan ju den sista enkelt beräknas från de andra, men som det är nu får jag bara köpt och sålt.
Antagligen finns det fler typer av data man kan läsa ut via Greenelys API, men jag hittar inte API-specen någonstans så jag kan inte dubbelkolla att det jag behöver är tillgängligt via API:et.
Har du tillgång till specen, eller har du möjlighet att lägga till ytterligare stöd för att läsa ut åtminstone en till av de fyra parametrarna?
Greenely just updated their app with electricity produced and sold, is it possible to also add the sold feature into the custom sensor?
BR Roman M
Jag är inte kund hos Greenely, men jag har gett dom fullmakt att inhämta min förbrukning från ediel.
Detta gör att all min data i appen (och i HA) släpar efter 2 dagar.
Detta gör att jag har svårt att göra en sån snygg apex chart då sensorn "sensor.greenely_prices" inte innehåller någon data från 2 dagar bakåt i tiden.
Finns det någon möjlighet att få med en dags prishistorik till i den sensorn?
Det hade varit kul att kunna ha en apex chart även om den inte visar nyare data än den från 2 dagar tillbaka.
(Någon kanske känner till något annat sätt att få in nyare data från vattenfall eller sin elleverantör, föreningen jag bor i har fått nya elmätare från vattenfall som ska läsas av regelbundet vad jag förstår, men mätarna sitter så klart inte tillgängligt för oss boende så det går inte att koppla någon egen lösning till dem.)
@linsvensson Just installed this integration according to the documentation:
I get the sensors after a reboot of HAOS, but no values. Looking at the commit history, and also the issues here, I start to wonder if this integration is maintained?
I'm willing to donate to get this up and running, would be super!
The price sensor "sensor.greenely_prices" that shows the current price is updating 4 min and 15 secs after the hour has changed. Shouldn't this update on the hour so that it can be used in Energy tab to calculate the actual cost of the electricity? Now 4 mins on every hour is calculated with the wrong price
2022-06-23 11:43:08 ERROR (SyncWorker_8) [custom_components.greenely.api] Failed to get price data,
Happens on both the accounts I have. Tried setting debug log level but it didn't give any feedback.
usage, prices och sold har enligt dokumentationen default värden där usage och prices är satt till true.
Koden saknar däremot defaultvärden, vilket gör att de defaultas till false, och man får inga sensorer alls
Hi I also use Apex but I have some problem regarding Greenly and your code. I get this error "/// apexcharts-card version 1.10.0 /// value.header is not a ChartCardHeaderExternalConfig; value.header.graph_span is extraneous" .
My lovelace code is in the attached file.
Thanks in advance
Lovelacecode.txt
.
Säkert ett rookie fel..
2022-11-20 21:01:58.739 ERROR (SyncWorker_4) [custom_components.greenely.api] {"title": "Fel användarnamn eller lösenord", "description": "Inmatat användarnamn eller lösenord är felaktigt"}
2022-11-20 21:01:58.742 ERROR (SyncWorker_4) [custom_components.greenely.sensor] Unable to log in!
Jag har angett samma epost / Lösen som jag använder i appen, la sensorn i configuration.yml precis så som i exemplet.
Har i vanliga fall en "secrets.yml" jag lägger in i, har testat både med och utan den.. blir inte direkt klok på vad som failar.
Med secret
sensor:
utan
sensor:
Appen funkar..
Hi,
To begin with, thanks for all good work on this component.
suddenly _price sensor missing in HA, have logged into Greenly mobile app and there I still see prices.
Sensor _usage I'll still see. Could you help me to understand what´s the issue?
sensor:
2022-01-25 00:56:35 DEBUG (SyncWorker_1) [custom_components.greenely.sensor] jwt is valid!
2022-01-25 00:56:35 DEBUG (SyncWorker_1) [custom_components.greenely.sensor] Fetching usage data...
2022-01-25 00:56:36 DEBUG (SyncWorker_2) [custom_components.greenely.sensor] Checking jwt validity...
2022-01-25 00:56:36 DEBUG (SyncWorker_2) [custom_components.greenely.sensor] jwt is valid!
Thanks in advance
Patric
Hi,
Im getting the message from Apexcharts-card:
Entity not avaible: sensor.greenely_prices
Any ideas where it could be failing?
Hi
I have two houses which Greenely supplies energy, I have had one of the houses getting figures from Greenely without providing
facility_id and that worked fine. When I now tried to set up both houses (different zones) and use facility_id to differentiate I get zero output probably because I state the facility_id in wron format but I cant see info regardin that at you github.
This is how i tried now (I exchanged the 8 last figures with x in this text for security reason)
facility_id: 7359991021xxxxxxxx
How should it look like?
Thanks for you good work in HA
Matz
Is it possible to use this data in mini-graph-card for example to better visualize the trend?
Im not able to get the values in a graph.
Anyway, great work!
I can’t get to work anymore
Unexpected unit of measurement
Translation Error: The intl string context variable "currency" was not provided to the string "The following entities do not have the expected units of measurement ''{currency}/kWh'' or ''{currency}/Wh'':"
sensor.greenely_usage (kWh)
running
Home Assistant OS 6.5
Update Channel | beta
Supervisor Version supervisor-2021.10.0
Hi Lin, thanks for your work.
I would very much appreciate if you could make it possible to get hour level resolution of the usage data. It would be interesting to see how the usage changes during the day.
It would also be great if the returned data could be in format that was easy to plot in for example history-graph. Look for example at a temperature sensor that has one value and the rest in history. Easily plotted.
Thanks!
Is it possible to add the json data of historical data for more than 10 days? I’d like to create a monthly graph like the one that exists in the greenley app.
Thanks!
Hi,
Getting the following warning message when starting up the integration, I assume it is related to some general update of sensors.
"Entity sensor.greenely_usage (<class 'custom_components.greenely.sensor.GreenelyUsageSensor'>) implements device_state_attributes. Please report it to the custom component author."
Följande felmeddelande kastas när jag försöker hämta ut usage.
När jag testar anropet via postman till https://api2.greenely.com/v3/data/2022/05/30/usage fungerar det, men med tom data.
Det kan vara relaterat till att jag har 2 hem i greenely, där det gamla jag flyttat från för över ett år sedan ligger kvar som "primär".
`greenely: Error on device update!
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 72, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/lib/python3.9/socket.py", line 954, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
self.sock = conn = self._new_conn()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fec890416a0>: Failed to establish a new connection: [Errno -2] Name does not resolve
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 440, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api2.greenely.com', port=443): Max retries exceeded with url: /v3/data/2022/5/30/usage (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fec890416a0>: Failed to establish a new connection: [Errno -2] Name does not resolve'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update
await task
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/greenely/sensor.py", line 244, in update
response = self._api.get_usage(str(previous_day.year), str(previous_day.month), str(previous_day.day))
File "/config/custom_components/greenely/api.py", line 55, in get_usage
response = requests.get(url, headers = self._headers)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api2.greenely.com', port=443): Max retries exceeded with url: /v3/data/2022/5/30/usage (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fec890416a0>: Failed to establish a new connection: [Errno -2] Name does not resolve'))`
if you configure sold=true, the sensors will stop working as the _api does not have the called function (anymore)
Har du några planer på att lägga till "Elkostnader". Där man i appen kan se kostnaden hittills (x dagar) samt den estimerade fakturan för hela månaden?
This is a feature request. I've tried doing this via scripting in Home Assistant, but it became too complicated.
A feature that would be very useful is to show todays price high's and low's as well as the median.
Also, add boolean methods like "is this hour in the top 5 cheapest", useful for setting up automations (heating, car charging etc.) or notifications to user.
Hi, I get this error when trying to load the Greenely sensor. Taken from the Core log:
2021-08-06 11:04:08 ERROR (MainThread) [homeassistant.components.sensor] greenely: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 646, in async_device_update await task File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/greenely/sensor.py", line 319, in update response = self._api.get_sold(self._sold_measure, self._sold_daily) File "/config/custom_components/greenely/sensor.py", line 417, in get_sold _LOGGER.error('Failed to fetch sold data from %s, %s', first_month.strftime("%d/%m/%Y"), response.text) UnboundLocalError: local variable 'first_month' referenced before assignment
I'm a newbie in using Home Assistant, so it is quite possible that I have done something wrong. I put the example code (with my own e-mail and password) for the integration in configuration.yaml.
Hey,
I can see data coming in from greenely in devtools but I can't get it to show in Energy Grid Dashboard?
Could someone please explain how to fix it if it is possible to do?
So, I made the classic mistake when opening my Greenely account - I logged in directly with my Google account. And now I can't login with this addon as I don't actually have a Greenely username and password. Is there a way around this or do I have to go through the process with deleting my account, creating a new one, and then again wait the three months to get my data from e.on? :(
Min sensor ger bara 0 värden för timmarna. Priset och 2 dagar gammal förbrukning visas i sensorerna.
Jag ser i dokumentationen att sensorn ska visa gårdagens data men jag får bara 2 dagar gammal data i sensorn. Även i Greenelys app får jag bara två dagar gammal data ( jag använder iPhone ). Går det ändra så att sensorn hämtar två dagar gammal data?
Hejsan! Tack för detta, är rätt ny på HA men detta är något jag gärna hade önskat ha i min HA.
Men om jag fattar det hela rätt så ska man kopiera filerna till custom_components > greenely. Dom har jag där.
Sen så ändrade jag i configuration.yaml och la till under default_config:
template:
sensor:
Och jag kan lägga till kortet i min overview men där står det bara Greenely Usage 0 kWh.
Är det något jag gör fel? :)
Tack!
Jag har ett problem. Jag får inte in några värden under Greenely. Den visar bara noll på både daglig förbrukning och timförbrukning. Har installerat via HACS och inte lagt till något särskilt (mer än användarnamn, lösenord och att den ska visa just timförbrukning) i konfigurationen. Varför blir det såhär?
Hello again! How do I get this to work with Grafana? Via InfluxDB?
Hi, i cant find to get any sensors going.
I have added it to the logger, but theres no information about the component, other than that it's found.
anyone got any tips? I tried the custom config, thinking it had the bug of default being all false.
I tried using knowingly false login details, to see if the logger would spit something out: but nothing. (even lowered the default logging to "info")
Hi!
I get this error in HA with the recorder:
[homeassistant.components.sensor.recorder] The unit of sensor.greenely_hourly_usage (None) cannot be converted to the unit of previously compiled statistics (kWh). Generation of long term statistics will be suppressed unless the unit changes back to kWh or a compatible unit. Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
It seems we need to provide a currency when getting the price to be able to store it.
Jag undrar om det går att ändra tillbaka till det gamla priset som det visade, tex priset nu i appen är 3,28 och den visar 0,0328. Jag använder sensorn i apples hem app och den har lite problem med decimaler.
Edit:
Löste mitt egna problem genom att göra en template sensor som ändrade så den blir Homekit vänlig :)
sensor:
- platform: template
sensors:
sensor:
friendly_name: "Greenely Pris"
value_template: "{{ ((states.sensor.greenely_prices.state) |float*100)|round(3) }}"
unit_of_measurement: '°C'
In the the last update information it said that it could be used in the HA energy. I added the sensors but it shows no data.
Did this component stop working with newer Hass versions or something?
Logger: homeassistant.components.hassio
Source: components/hassio/init.py:486
Integration: Home Assistant Supervisor (documentation, issues)
First occurred: 21:15:19 (1 occurrences)
Last logged: 21:15:19
Platform error sensor.greenely - Integration 'greenely' not found.
Files in place:
\config\custom_components\greenely_init_.py
\config\custom_components\greenely\manifest.json
\config\custom_components\greenely\sensor.py
All with the correct permissions.
Supervisor
Version
supervisor-2021.04.0
Operativsystem
Home Assistant OS 5.13
Home Assistant 2021.4.6
Hello,
Just checking if the config examples for custom:apexcharts-card are up to date?
Unable to get it working so far although I have both the sensors from this code and the apexcharts all working on their own.
I get an error when trying to test the example config to get going:
"No card type configured".
Any chance of a comment or a check? Many thanks.
Below is the code from your example git below that I am using in a manual card.
- type: custom:apexcharts-card
header:
title: Förbrukning/timme & elpris
show: true
graph_span: 24h
span:
start: day
offset: '-1d'
yaxis:
- id: first
apex_config:
tickAmount: 10
min: 0
max: 2
- id: second
opposite: true
apex_config:
tickAmount: 5
min: 0
decimals: 0
apex_config:
dataLabels:
enabled: false
stroke:
width: 4
series:
- entity: sensor.greenely_hourly_usage
name: Förbrukning
yaxis_id: first
type: column
color: red
show:
legend_value: false
data_generator: |
return entity.attributes.data.map((entry) => {
return [new Date(entry.localtime), entry.usage];
});
- entity: sensor.greenely_prices
data_generator: |
return entity.attributes.previous_day.map((entry) => {
return [new Date(entry.date + 'T' + entry.time), entry.price];
});
yaxis_id: second
type: line
color: blue
name: Elpris
show:
legend_value: false
Trying to add this custom component in HA 0.112.2.
Have downloaded the files and added them to: "\config\custom_components\greenely"
(init.py
manifest.json
sensor.py)
After restart, no error so started to add the sensor in my sensor.yaml like:
When saved and checking config I get the error:
"Error loading /config/configuration.yaml: while scanning for the next token
found character '%' that cannot start any token
in "/config/sensor.yaml", line 13, column 16"
Removed date_format line getting this error:
Invalid config for [sensor.greenely]: [show_usage] is an invalid option for [sensor.greenely]. Check: sensor.greenely->show_usage. (See ?, line ?).
Removed all lines exept:
Any idea how to solve this?
Or am I doing something wrong?
BR
Christoffer
Thanks for the integration :)
I get the wrong hour for the hourly usage. The problem is most likely related to summer/winter time.
The hourly data for 16:00 in Greenely apps shows up as 17:00 in Home Assistant.
Hi,
Is it possible to make the sensor work with this?
Default (first registered Greenely home) has its power turned off, hence no readings.
Using Greenely 1.0.6 I see this error message in the HomeAssistant logs:
State attributes for sensor.greenely_hourly_usage exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
Jag får ingen sensor för såld el. Eller det ska man inte kanske? Jag har detta i configuration.yaml
Just updated Homeassistant to 2021.8,2 and about to setup the new energy funtions:
https://www.home-assistant.io/docs/energy/electricity-grid/
Unable to use sensor.greenely_usage
https://www.home-assistant.io/more-info/statistics/
https://developers.home-assistant.io/docs/core/entity/sensor#long-term-statistics.
Hi Lin, Great work you have done. I am new in this exciting area and probably a bit stupid. I have read your installation guide but it dosent work for me.
I download three files from your custom_components/greenely/ into my custom_components/greenely/. I set up the sensor code in my /config/configuration.yaml as you say but it doesn't work.
You also say this:
_"Using your HA configuration directory (folder) as a starting point you should now also have this:
custom_components/greenely/init.py
custom_components/greenely/sensor.py
custom_components/greenely/manifest.json"_
Shall I put these three rows into my /config/configuration.yaml or what don't I understand or do wrong?
Thanks in advance.
Anders
Not a bug! But an enhancement request. In order to make the sensors more useful is to have as part of the main sensor for prices or to have it as separate sensors, the min, max and mean price for the day and next day.
Hey. I've been working on a node-red version of this and got it working. Have yet to put it online however.
Your code was a great start. Thanks!
I'm curious how you found out the methods to call as the app now has a bit more features and I'd assume that data would be available too if one knew where to look. Any suggestions on how to find the URLs?
Followed the install guide. But when i check the config in HA, I got the error message
Platform error sensor.greenely - Integration 'greenely' not found.
And I can´t restart due to the error messages.
HA 2023.3.8 on Home assistant OS.
Tripple checked everything but obviously missing something.
Pris sensorn hämtar värdet i öre från Greenely.
Men standardenheten för en prissensor är SEK (om man inte valt annat) vilket gör att priset resulterar i 199.4 kr istället för 1.99Kr.
Sensorn borde ta värdet från Greenely och omvandla det, innan det presenteras till sensorn, så att sensorn kan användas som den är.
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.