Home Automation - Smart home

Track Norway’s Fixed Electricity Price in Home Assistant with the “Norgespris Universal” Sensor

Managing electricity usage efficiently is becoming increasingly important, especially for households with electric vehicles or smart home setups. Dynamic spot prices like Nord Pool are great. However, some users prefer the simplicity of a fixed electricity price. They find it easier to manage alongside the additional network fees from their provider.

Advertisements

In this post, we’ll introduce the “Norgespris Universal” sensor for Home Assistant – a single sensor that provides:

  • A fixed electricity price for Norway (including VAT)
  • Automatic day/night network fees from your electricity provider (in this example, Tensio)
  • Full compatibility with EV Smart Charging for smart EV charging schedules
  • Dashboards similar to Nord Pool, with hourly prices for today and tomorrow

Why a Fixed Price Sensor?

Not everyone wants to calculate spot prices every hour. A fixed price sensor provides:

  1. Predictable electricity costs – you always know how much each kWh will cost
  2. Integration with smart devices – EV chargers, smart plugs, and automations can use this value directly
  3. Ease of use in Home Assistant – one sensor provides current price, today’s hourly prices, and tomorrow’s hourly prices

In our example, the day network fee is 36.04 øre/kWh and the night fee (22:00–06:00) is 22.92 øre/kWh. Combined with a fixed base price, this sensor gives you the total cost per kWh including VAT.

How It Works

The Norgespris Universal sensor calculates:

  1. The current price based on the hour of the day (day/night)
  2. Two sets of attributes for smart integrations:
  • prices_today → list of 24 dictionaries for today, each containing time and price
  • prices_tomorrow → list of 24 dictionaries for tomorrow, same format

These attributes are fully compatible with EV Smart Charging. This compatibility allows you to schedule charging for the cheapest hours. In this case, it’s the fixed price hours.

Additionally, for dashboards, the sensor includes:

  • today_dict / tomorrow_dict → lists with start/end timestamps and price values, ideal for graphing hourly costs

Extra attributes like current_price, min_price, and max_price allow for easy automations, notifications, and Lovelace cards.

Implementation in Home Assistant

Add the following sensor to your templates.yaml file. Once loaded, it will automatically update the current price and generate hourly price lists for today and tomorrow.

- sensor:
    - name: "Norgespris Universal"
      unique_id: norgespris_universal
      unit_of_measurement: "NOK/kWh"
      device_class: monetary

      state: >
        {% set norgespris = 0.50 %}
        {% set hour = now().hour %}
        {% set energiledd = 0.2292 if hour >= 22 or hour < 6 else 0.3604 %}
        {{ (norgespris + energiledd) | round(4) }}

      attributes:

        # EV Smart Charging compatible prices
        prices_today: >
          [
          {% set norgespris = 0.50 %}
          {% set today = now().replace(hour=0, minute=0, second=0, microsecond=0) %}
          {% for h in range(24) %}
            {% set t = today + timedelta(hours=h) %}
            {% set energiledd = 0.2292 if h >= 22 or h < 6 else 0.3604 %}
            { "time": "{{ t.strftime('%Y-%m-%d %H:%M:%S%z') }}", "price": {{ (norgespris + energiledd) | round(4) }} }{{ "," if not loop.last else "" }}
          {% endfor %}
          ]

        prices_tomorrow: >
          [
          {% set norgespris = 0.50 %}
          {% set tomorrow = (now() + timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0) %}
          {% for h in range(24) %}
            {% set t = tomorrow + timedelta(hours=h) %}
            {% set energiledd = 0.2292 if h >= 22 or h < 6 else 0.3604 %}
            { "time": "{{ t.strftime('%Y-%m-%d %H:%M:%S%z') }}", "price": {{ (norgespris + energiledd) | round(4) }} }{{ "," if not loop.last else "" }}
          {% endfor %}
          ]

        # NordPool-style dashboard attributes
        today_dict: >
          {% set ns = namespace(prices=[]) %}
          {% set base = now().replace(hour=0, minute=0, second=0, microsecond=0) %}
          {% for h in range(24) %}
            {% set start = base + timedelta(hours=h) %}
            {% set end = start + timedelta(hours=1) %}
            {% set value = (0.50 + (0.2292 if h >= 22 or h < 6 else 0.3604)) | round(4) %}
            {% set ns.prices = ns.prices + [{"start": start.isoformat(), "end": end.isoformat(), "value": value}] %}
          {% endfor %}
          {{ ns.prices }}

        tomorrow_dict: >
          {% set ns = namespace(prices=[]) %}
          {% set base = (now() + timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0) %}
          {% for h in range(24) %}
            {% set start = base + timedelta(hours=h) %}
            {% set end = start + timedelta(hours=1) %}
            {% set value = (0.50 + (0.2292 if h >= 22 or h < 6 else 0.3604)) | round(4) %}
            {% set ns.prices = ns.prices + [{"start": start.isoformat(), "end": end.isoformat(), "value": value}] %}
          {% endfor %}
          {{ ns.prices }}

        # Extra useful attributes
        current_price: >
          {{ states('sensor.norgespris_universal') | float(0) }}

        min_price: >
          {% set t = state_attr('sensor.norgespris_universal', 'prices_today') | map(attribute='price') | list %}
          {{ (t | min) if t | length > 0 else 0 }}

        max_price: >
          {% set t = state_attr('sensor.norgespris_universal', 'prices_today') | map(attribute='price') | list %}
          {{ (t | max) if t | length > 0 else 0 }}

Benefits of the Norgespris Universal Sensor

  • Predictable electricity costs – you know exactly how much each kWh costs
  • EV Smart Charging ready – automatically schedule EV charging based on day/night rates
  • Dashboards – visualize hourly electricity costs like Nord Pool
  • Automation friendly – use current_price, min_price, and max_price for notifications and logic

The Norgespris Universal sensor simplifies smart home energy management. It does this by combining a fixed electricity price with your provider’s network fee. This makes it simple, predictable, and flexible.


Some of the links in this article are "affiliate links", a link with a special tracking code. This means if you click on an affiliate link and purchase the item, we will receive an affiliate commission. The price of the item is the same whether it is an affiliate link or not. Regardless, we only recommend products or services we believe will add value to our readers. By using the affiliate links, you are helping support our Website, and we genuinely appreciate your support.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.