Custom component to get usage data and prices from Greenely for Home Assistant.
Because Greenely doesn't have an open api yet, we are using the Android user-agent to access data. Data is fetched every hour.
custom_components/greenely
to your <config dir>/custom_components
directory.Is done using the UI, click Add integration and search for Greenely. The initial setup needs your Email and Password for the Greenely account, optionally you could specify the Facility ID.
Options for additional sensors and settings can be found in the configuration of that integration in the UI.
key | type | description |
---|---|---|
Email (Required) | string | Your Greenely username. |
Password (Required) | string | Your Greenely password. |
Facility ID (Optional) | string | If you have more than one facility and know the facility ID you want data from, put it here. Note: The facility ids can be fetch using the service call greenely.fetch_factilites, this will output a notification displaying the facilities for your account. |
key | type | description |
---|---|---|
Prices (Optional) | boolean | Creates a sensor showing price data in kr/kWh. Default true . |
Daily usage sensor (Optional) | boolean | Creates a sensor showing daily usage data. The state of this sensor is yesterday's total usage. Default true . |
Hourly usage sensor (Optional) | boolean | Creates a sensor showing yesterday's hourly usage data. Default false . |
Daily produced electricity sensor (Optional) | boolean | Creates a sensor showing daily produced electricity data. The state of this sensor is the total value. Default false . |
Usage days (Optional) | number | How many days of usage data you want. Default 10 . |
Produced electricity days (Optional) | number | How many days of produced electricity data you want. Default 10 . |
Date format (Optional) | string | Default %b %d %Y , shows up as Jan 18 2020 . References |
Time format (Optional) | string | Default %H:%M , shows up as 10:00 . References |
Hourly offset days (Optional) | number | How many days ago you want the hourly data from. Default 1 (yesterday's data). |
Homekit compatible (Optional) | boolean | If you're using Homekit and need the current price data in the format x.x °C , enable this. Default false . |
Facility ID (Optional) | string | If you have more than one facility and know the facility ID you want data from, put it here. Note: The facility ids can be fetch using the service call greenely.fetch_factilites, this will output a notification displaying the facilities for your account. |
Fetch factilites This service will fetch the facilites data and output it into a formated notification displaying the following. ID, Street, Zip code, City and Primary attributes for each of your facilites.
Field | Type | Description |
---|---|---|
Email (Required) | string | Your Greenely username. |
Password (Required) | string | Your Greenely password. |
Output json (Optional) | boolean | Will output the complete payload from Greenely in json format into an additional notification. Default false . |
Example without json output:
service: greenely.fetch_facilities
data:
email: user@example.com
password: password
Example with json output:
service: greenely.fetch_facilities
data:
email: user@example.com
password: password
output_json: true
Example chart with ApexCharts Card: Use these configurations for the sensor
hourly_usage: true
date_format: '%Y-%m-%d'
- 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
Example usage with flex-table-card:
- type: 'custom:flex-table-card'
title: Greenely Daily Usage
sort_by: date
entities:
include: sensor.greenely_daily_usage
columns:
- name: date
attr_as_list: data
modify: x.localtime
icon: mdi:calendar
- name: kWh
attr_as_list: data
modify: x.usage
icon: mdi:flash
Example prices with flex-table-card:
- type: custom:vertical-stack-in-card
cards:
- type: horizontal-stack
cards:
- type: 'custom:flex-table-card'
title: Today
sort_by: date
entities:
include: sensor.greenely_prices
columns:
- name: time
attr_as_list: current_day
modify: x.time
icon: mdi:clock
- name: price(öre/kWh)
attr_as_list: current_day
modify: Math.round(x.price * 100)
icon: mdi:cash
- type: 'custom:flex-table-card'
title: Tomorrow
sort_by: date
entities:
include: sensor.greenely_prices
columns:
- name: time
attr_as_list: next_day
modify: x.time
icon: mdi:clock
- name: price(öre/kWh)
attr_as_list: next_day
modify: Math.round(x.price * 100)
icon: mdi:cash
Example usage with Node-Red Companion and tts
You can then for example make a script to trigger it through voice commands to Google Assistant!
Add this to your configuration.yaml to debug the component
default: warning
logs:
custom_components.greenely: debug
previous_day, current_day, next_day & current_month
[{ "date": "Jan 18 2020", "time": "13:00", "price": "24.75" }]
days
[{ "localtime": "Jan 12 2020", "usage": "11.0" }]
hourly
[{ "localtime": "Jan 12 2020 10:00", "usage": "1.0" }]
sold_data
[{ "date": "Jan 12 2020", "usage": "11.0", "is_complete": true }]