Skip to content

Instantly share code, notes, and snippets.

@christophengelmayer
Last active December 4, 2025 22:01
Show Gist options
  • Select an option

  • Save christophengelmayer/93512a78b9134627360a40562785d276 to your computer and use it in GitHub Desktop.

Select an option

Save christophengelmayer/93512a78b9134627360a40562785d276 to your computer and use it in GitHub Desktop.
Native Home Assistant spottyenergie.at Spot Prices that work with ha_epex_spot_sensor
#
# Replace INSERT_YOUR_CUSTOM_KEY_HERE with your API Information from https://i.spottyenergie.at/#/dashboard
# Optional: adapt "price_per_kwh": {{ (item.price + 1.49) * 1.2 | float(0) }}
#
command_line:
- sensor:
name: "Energy Spot Price Raw"
unique_id: energy_spot_price_raw
scan_interval: 900
command_timeout: 30
command: |-
python3 -c "import requests, json; \
r = requests.get('https://i.spottyenergie.at/api/prices/CONSUMPTION/INSERT_YOUR_CUSTOM_KEY_HERE?timezone=at').json(); \
print(json.dumps({'data': r}))"
value_template: "OK"
json_attributes:
- data
template:
- sensor:
- name: "Spot Price"
unique_id: energy_spot_price
state_class: measurement
unit_of_measurement: "ct/kWh"
icon: mdi:currency-eur
state: >-
{% set prices = state_attr('sensor.energy_spot_price_raw', 'data') %}
{% if not prices %}
unknown
{% else %}
{% set now_ts = as_timestamp(now()) %}
{% for item in prices %}
{% set start = as_timestamp(item['from']) %}
{% set end = start + 15*60 %}
{% if now_ts >= start and now_ts < end %}
{{ item['price'] }}
{% endif %}
{% endfor %}
{% endif %}
attributes:
data: >-
{%- set items = state_attr('sensor.energy_spot_price_raw', 'data') or [] -%}
[
{%- for item in items %}
{%- set start = as_datetime(item.from) %}
{%- set end = as_datetime(items[loop.index].from) if not loop.last else (start + timedelta(minutes=15)) %}
{
"start_time": "{{ start.isoformat() }}",
"end_time": "{{ end.isoformat() }}",
"price_per_kwh": {{ (item.price + 1.49) * 1.2 | float(0) }}
}{{ "," if not loop.last else "" }}
{%- endfor -%}
]
@christophengelmayer
Copy link
Copy Markdown
Author

Drop in replacement for EPEX Spot integration.

Works with EPEX Spot Sensor and ApexCharts Card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment