Ask in the forum Posting needs a Spotprice account with a confirmed email.

Loxone Integration

Primary integration path for SpotpriceAPI: Loxone Miniserver with Virtual Output (HTTPS) + PicoC. The same API endpoints are open for any system (Home Assistant, Python, cURL) — Loxone is just the best-documented path. Community free: 200 requests/day, no credit card.

This section connects SpotpriceAPI to a Loxone Miniserver — the box that runs your smart home. You can show electricity prices, pick cheap hours, or charge a home battery when power is cheapest. The Miniserver still reads the exchange through the Forecast API. The household tariff is on the prices page: a fixed price or time windows are 24 bars, not the exchange chart. The Hours plan follows the plant profile. PicoC still reads the exchange.

No prior Loxone or PicoC experience required. Read this page first, then open the guide that matches your goal.

Storage start

First the portal profile: location and storage size. Then Hours and telemetry. Then PV Forecast on the same host.

What problem are we solving?

Electricity price changes every hour. A battery or heat pump should run more when power is cheap. SpotpriceAPI knows tomorrow’s prices and can say “charge for 3 hours starting at 2 a.m.” Your Loxone must get that answer and switch relays.

Why PicoC cannot call the API directly

PicoC is a small script language inside Loxone Config. It can read sensors, do math, and read/write files on the Miniserver. It cannot:

  • Open HTTPS connections to the internet
  • Send HTTP headers like X-API-Key

So PicoC alone cannot talk to https://api.spotpriceapi.com.

Why Virtual Output holds the API key

Virtual Output (also called Virtual HTTP Output in some versions) is a Loxone block that can call HTTPS. You configure:

  • URL (https://api.spotpriceapi.com/v1/...)
  • Header X-API-Key: sf_live_EXAMPLE_REPLACE_ME. This is an example, not a valid key. Replace it on every command of this host with your own active key from the portal. Do not put the key in the parent address field. That field is only https://api.spotpriceapi.com.
  • Save response to a file, e.g. /user/common/spotprice_hours.json

The key lives only in the Virtual Output settings in Config — not inside PicoC source. PicoC then reads the saved JSON file and turns numbers into outputs for relays and the Spot Price Optimizer.

One host, several commands

Loxone does not share commands — it does share the parent Virtual Output.

Create one Virtual Output as a header (address = host). Hang the HTTP commands underneath (telemetry, PV, forecast, …). That keeps the peripherals list tidy.

Parent (host only)

FieldValue
Namee.g. FetchHeader Spotpriceapi.com
Addresshttps://api.spotpriceapi.com
Close connection after sendingon (typical)
Parent Virtual Output — host address only
Parent Virtual Output — host address only

Commands underneath

One command per API (path, header with key, save path). Example: telemetry SOC/meter + FetchPvForecast under the same parent.

Virtual Outputs: FetchHeader with several commands
Virtual Outputs: FetchHeader with several commands

If Hours (or Forecast) already has the host: do not add a second host VO — only add the missing command. Details: each guide (Virtual Output step).

Max 8 PicoC programs per Miniserver. Recommended: Hours 2 + Flex 1 + Forecast 2 + PV 2 = 7/8. Skip weather (Tmin/Tmax are already on the PV display). Without Flex you stay at 6/8.

When each auto-fetch runs

HTTPS pulses are staggered on purpose:

MinuteWhatPicoC
:00 / :15 / :30 / :45Telemetry (if I7=1; optional + 0,0–45,0 s poll_jitter_s)FetchPlantHours
:01Prices GETDebugSpotpriceFile
:02Hours Decide (if I8=1; fallback :05 and :09; optional + 0,0–45,0 s poll_jitter_s)FetchPlantHours
:03Windows GET Legacy (if I4=1)DebugDecisionWindowsFile
:04Flex Windows POST (if I3=1)SpotpriceFlexWindows
:08PV days GETDebugPvForecast
:10Weather GETDebugPlantWeather

Forecast, PV and Weather also fetch on start (~3 s). Hours Extract reads an existing spotprice_hours.json on start (Demand after reboot). On the server side, SpotpriceAPI refreshes plant weather 5× daily (05:20, 08:20, 11:20, 14:20, 17:20 Vienna; Alpine 0,01° grid), at :40 ahead of scheduled grid-charge hours (with automatic replanning while idle), and replans day-ahead hours from :01:30 (15:01:30–23:01:30 Vienna) — the PicoC blocks pick up updated values on the regular :02 / :08 / :10 fetch.

How the pieces fit together


Battery SOC sensor ──┐
Grid meter ──────────┼──► PicoC Fetch block ──► pulses Virtual Output
Manual button ───────┘         │
                               ▼
                    Virtual Output (HTTPS + API key)
                               │
                               ▼
                    JSON file on Miniserver
                               │
                               ▼
                    PicoC Parse block ──► Spot Price Optimizer / relays / display

Which guide should I open? (after login)

Your goalGuide
Only upload SOC + meter (no charge plan)Telemetry only
Home battery: how many hours to charge, when, at what priceHours & telemetry (full)
I set the window + N myself (wallbox, relay, pool)Flex Windows
Legacy: Count/Days with 2 PicoC blocksDecision Windows v1
Show current price on UI / test the connectionForecast
Show PV daily yield + load/SoC text in the appPV Forecast
Weather room / text displays (HTTP, not license block)Weather

Current PicoC versions

After login, copy the blocks from the detail guides:

BlockVersionGuide
FetchPlantHoursv1.19Telemetry · Hours — optional per-plant stagger poll_jitter_s (0,0–45,0 s in 0,1 s steps when HOURS_POLL_JITTER_ENABLED=1, code default 0) · auto-Decide :02 (:05/:09 fallback, decReqHour/busy queueing) · I7 :00/:15/:30/:45 telemetry only · 5 % SOC bands (up immediately, down 1,01 pp hysteresis) · O7→DebugPv I1
ExtractHoursDemandv1.33Hours — strict O1–O13 · fail-closed boot gridAllow=0/expAllow=0 + grid_export_allowed gate on O6–O8 · prefix + :00 relay bridge (charge_next_hour, 7 min hGrace) + O5 PulseSessionStop + O6–O8 grid sale + sticky Watt > 55 + hEff net-meter loop + 1 s / 3 s debounce + chgPause hysteresis (min_on_s=120, 45 s / 30 s / 8,2 kW when HOURS_EMS_CONTINUITY_V2=1, +2,0 kW/10 s ramp) + O11=0 when gridAllow=0 + live O12 raise via I2 (× 4,0, monotonic 90 s peak latch, unwired fallback dKw≤0→mdKw, I2 self-test log, suppresses O6/O7) + 12 h fallback (fbOn→mdKw)
DebugDecisionWindowsFilev2.2Windows Legacy — auto :03
ParseDecisionWindowsv1.4Windows Legacy
SpotpriceFlexWindowsv0.6.11Flex Windows — O1–O8 on/off, VO flex_pack <v.0>, auto :04, I6=0 = Sparvo, offline boot
DebugSpotpriceFilev5.7Forecast — start + :01, O1=12 offline, O4 released after poll
ParseSpotpriceForecastv18Forecast — boot + hour change
DebugPvForecastv1.6PV Forecast — start + auto :08, pendingFetch, SoC sidecar, O4 released after poll
ExtractPvDailyv2.7PV Forecast — O1…O13 + Txt1 v2.7 soc=…; re-read ~20 s + sidecar/JSON
DebugPlantWeatherv1.3Weather — start + auto :10, O1=12 offline, O4 released after poll
ExtractPlantWeatherv1.1Weather — temp/wind/text; file also on start

Offline fallback (from v5.6 / v1.3 / v0.6.11): JSON under /user/common/ is kept until a valid API fetch; on outage O1=12 (Forecast/PV) or switching from backup (Flex). See each guide for details.

Virtual Inputs — always analog

Wherever the guides mention Virtual Inputs (VI) as inputs (Windows Count/Days, weather display, …): they are numeric values, not switches. Hours needs no VIs — wire SOC/meter directly to Fetch and Analog Memory.

Not for PV Forecast display: values come from ExtractPvDaily O1…O13 / Txt* — directly or via optional Analog Memory, not via VIs.

Setting in Loxone ConfigValue
Use as digital inputoff (otherwise only on/off — e.g. 13,5 kWh is lost)
Input typenot “Switch” — e.g. Analog / Slider
Status display onlyon for pure display inputs (price, Windows outputs); off only if you deliberately change the value from the app (e.g. Windows Count/Days/Mode)
Monitor validationoff — otherwise Min/Max clamp the value (default often 0…100)
Unitas in each guide’s table (kWh, %, °C, ct/kWh, …)

Details are under Step 1 in every guide.

Wiring plan — overview

In Loxone Config you draw lines from an output to an input. Read each row as: “output … of … → input … of …”.


Sensors / buttons → FetchPlantHours v1.19
                      ├─ O4 → VO Telemetry
                      ├─ O5 → VO DecideThin → spotprice_hours.json
                      └─ O1=10 → ExtractHoursDemand v1.33 I1 → Optimizer
                                                optional house load → Extract I2 (10 kW throttle + live O12)
                                                SOC → Extract I3
                                                optional PV surplus → Extract I4
                                                O3 → relay · O6–O8 export · Txt3 hours/kWh

Step-by-step including Analog Memory: Hours & telemetry. SOC/meter only, no plan: Telemetry only.

Without battery math (Windows)


Count / Days / Button  →  DebugDecisionWindowsFile (PicoC)
                              ├─ O4 → VO FetchWindowsGlobal
                              ├─ O5 → VO FetchWindowsDayFirst
                              └─ O1 → ParseDecisionWindows I1
                                         ├─ O6 → Optimizer Demand
                                         └─ O7 → Optimizer Period

Details after login: Windows.

Prices only (Forecast)


Start / :01 (button opt.)  →  DebugSpotpriceFile I1
DebugSpotpriceFile O4  →  VO FetchForecast
DebugSpotpriceFile O1  →  ParseSpotpriceForecast I1
ParseSpotpriceForecast O1 / O2  →  display “price now” / “+1 h”

Details after login: Forecast.

PV daily yield (PV Forecast)


Start / :08 / Hours O7 (button opt.)  →  DebugPvForecast I1
DebugPvForecast O4  →  VO FetchPvForecast
DebugPvForecast O1  →  ExtractPvDaily I1
ExtractPvDaily O1…O13 / Txt2 / Txt3  →  app / memory / logic

One fetch covers PV, load, end-of-day SoC and min/max — no extra weather PicoC for the same room. No Virtual Inputs needed for display. Hours O7 goes to Debug I1 (not onto the VO alone).

Details after login: PV Forecast.

Weather display (HTTP)


Start / :10 (button opt.)  →  DebugPlantWeather I1
DebugPlantWeather O4  →  VO FetchPlantWeather
DebugPlantWeather O1  →  ExtractPlantWeather I1
Extract O1…O4 + Txt  →  displays

Only Tmin/Tmax in PV texts? Skip this guide — that is already in PV Forecast.

Details after login: Weather.

What you need before any Loxone guide

  • Loxone Config on PC/Mac, connection to your Miniserver
  • Free SpotpriceAPI account — Register — key sf_live_EXAMPLE_REPLACE_ME
  • For battery setup: plant profile in portal (capacity, location, PV)
  • Blocks used in all guides: PicoC, Virtual Output, Virtual Inputs

Portal checklist

  • API key: Account → API keys → copy once
  • Plant profile: for Hours/Telemetry (location, kWp, capacity)
  • Code samples: logged-in Code Samples with your key pre-filled

API reference (for humans, not Loxone)

Common mistakes

  • Pasting API key into PicoC source — use Virtual Output header only
  • Virtual Input “Use as digital input” on — off; these are analog numbers, not switches
  • Virtual Input “Monitor validation” on — off; otherwise Min/Max clamp values
  • Expecting PicoC to fetch URLs — it reads files after Virtual Output runs
  • Fetching every few seconds — Community tier is 200 billable calls/day; use hourly auto-fetch in our scripts
  • Skipping plant profile then wondering why incomplete_input appears

Next steps

Register or sign in, then open Hours & telemetry — start with Step 0.

Unlock

Detail guides after login

The overview stays public. Hours, Windows, Forecast, PV Forecast and Weather with PicoC need login and at least Community.

  • Hours & telemetry — battery demand for Spot Price Optimizer
  • Decision Windows — wire a fixed hour count
  • Forecast — price now / +1 h in the app
Start with SpotpriceAPI

Register for Community or code samples with your personal key.

Live API status