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.

Revisions

  1. christophengelmayer revised this gist Dec 4, 2025. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions configuration.yaml
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    #
    # 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:
    @@ -47,7 +46,7 @@ template:
    {
    "start_time": "{{ start.isoformat() }}",
    "end_time": "{{ end.isoformat() }}",
    "price_per_kwh": {{ (item.price + 1.49) * 1.2 | float(0) }}
    "price_per_kwh": {{ item.price * 1.2 | float(0) }}
    }{{ "," if not loop.last else "" }}
    {%- endfor -%}
    ]
  2. christophengelmayer revised this gist Dec 4, 2025. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions configuration.yaml
    Original file line number Diff line number Diff line change
    @@ -9,10 +9,9 @@ command_line:
    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}))"
    command: >-
    curl -s 'https://i.spottyenergie.at/api/prices/CONSUMPTION/INSERT_YOUR_CUSTOM_KEY_HERE?timezone=at' |
    jq -c '{data: .}'
    value_template: "OK"
    json_attributes:
    - data
  3. christophengelmayer revised this gist Dec 4, 2025. 1 changed file with 56 additions and 0 deletions.
    56 changes: 56 additions & 0 deletions horizontal-stack-card-configuration.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    type: horizontal-stack
    cards:
    - type: custom:apexcharts-card
    experimental:
    color_threshold: true
    graph_span: 2day
    update_interval: 2m
    now:
    show: true
    label: Jetzt
    color: gray
    span:
    offset: +0day
    start: day
    yaxis:
    - id: primary
    decimals: 1
    min: "|-1|"
    max: "|+1|"
    header:
    show: true
    title: Strompreis
    show_states: true
    colorize_states: true
    all_series_config:
    unit: ct/kWh
    type: line
    stroke_width: 0
    show:
    legend_value: false
    in_header: true
    header_color_threshold: true
    color_threshold:
    - value: 0
    color: "#00c700"
    - value: 5
    color: "#7ddc00"
    - value: 10
    color: "#ffdd00"
    - value: 15
    color: "#ffb700"
    - value: 20
    color: "#ff7f00"
    - value: 25
    color: "#ff4c00"
    - value: 30
    color: "#ff0000"
    series:
    - entity: sensor.energy_spot_price
    name: Electricity Price
    type: column
    extend_to: end
    data_generator: |
    return entity.attributes.data.map((entry) => {
    return [new Date(entry.start_time), entry.price_per_kwh];
    });
  4. christophengelmayer revised this gist Dec 4, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion configuration.yaml
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ command_line:

    template:
    - sensor:
    - name: "Spot Price"
    - name: "Energy Spot Price"
    unique_id: energy_spot_price
    state_class: measurement
    unit_of_measurement: "ct/kWh"
  5. christophengelmayer created this gist Dec 4, 2025.
    54 changes: 54 additions & 0 deletions configuration.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    #
    # 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 -%}
    ]