Skip to main content

HTTP Power Driver

jumpstarter-driver-http-power provides functionality for controlling power via HTTP endpoints and reading power measurements.

Installation

pip3 install --extra-index-url https://pkg.jumpstarter.dev/simple/ jumpstarter-driver-http-power

Configuration

Example configuration:

export:
  http_power:
    type: jumpstarter_driver_http_power.driver.HttpPower
    config:
      name: "device"
      power_on:
        url: "http://power-controller.local/api/power/on"
        method: "POST"
        data: "action=on"
      power_off:
        url: "http://power-controller.local/api/power/off"
        method: "POST"
        data: "action=off"
      power_read:
        url: "http://power-controller.local/api/power/status"
        method: "GET"
      auth:
        basic:
          user: "admin"
          password: "secret"

Example configuration for Shelly Smart Plug (Gen1):

apiVersion: jumpstarter.dev/v1alpha1
kind: ExporterConfig
metadata:
  namespace: default
  name: demo
endpoint: ""
token: ""
export:
  power:
    type: jumpstarter_driver_http_power.driver.HttpPower
    config:
      name: "my-splug"
      power_on:
        url: "http://192.168.1.65/relay/0?turn=on"
      power_off:
        url: "http://192.168.1.65/relay/0?turn=off"
      auth:
        basic:
          user: admin
          password: something

Example configuration for Shelly Smart Plug (Gen2/Gen3):

Gen2/Gen3 plugs (e.g. Plug S G3) use the RPC API and report voltage/current as top-level keys, so read() works with no path configuration:

export:
  power:
    type: jumpstarter_driver_http_power.driver.HttpPower
    config:
      name: "my-splug"
      power_on:
        url: "http://192.168.0.111/rpc/Switch.Set?id=0&on=true"
      power_off:
        url: "http://192.168.0.111/rpc/Switch.Set?id=0&on=false"
      power_read:
        url: "http://192.168.0.111/rpc/Switch.GetStatus?id=0"

Using the examples/exporter-shelly-gen3.yaml config, power on, take 4 measurements one second apart, then power off:

$ jmp shell --exporter-config exporter.yaml -- sh -c 'j power on && j power read -n 4 -i 1 && j power off'
[06/23/26 23:00:26] INFO     [driver.HttpPower] Powering on shellyplugsg3 via
HTTP
voltage=236.6 V  current=0.0 A  apparent_power=0.0 VA
voltage=236.5 V  current=0.09 A  apparent_power=21.285 VA
voltage=236.6 V  current=0.016 A  apparent_power=3.7856 VA
voltage=236.6 V  current=0.0 A  apparent_power=0.0 VA
[06/23/26 23:00:30] INFO     Powering off shellyplugsg3 via HTTP

Config parameters

Parameter Description Type Required Default
name Name of the device, for logging purposes str no "device"
power_on HTTP endpoint config for powering on HttpEndpointConfig yes
power_off HTTP endpoint config for powering off HttpEndpointConfig yes
power_read HTTP endpoint config for reading power measurements. When unset, read() raises rather than returning a fake zero measurement HttpEndpointConfig no None
auth Authentication configuration HttpAuthConfig no None
auth.basic Basic authentication credentials HttpBasicAuth no None

HttpEndpointConfig parameters

Parameter Description Type Required Default
url The HTTP endpoint URL str yes
method HTTP method (GET, POST, PUT, etc.) str no "GET"
data Request body data for POST/PUT/PATCH requests str no None
voltage_path On a power_read endpoint: dotted JSON path to the voltage value (e.g. emeter.voltage, StatusSNS.ENERGY.Voltage) str no top-level voltage
current_path On a power_read endpoint: dotted JSON path to the current value str no top-level current

HttpBasicAuth parameters

Parameter Description Type Required Default
user Username for basic authentication str yes
password Password for basic authentication str yes

API Reference

.. autoclass:: jumpstarter_driver_power.client.PowerClient()
    :members: on, off, read, cycle
    :no-index:

Examples

Basic power control:

# Power on the device
http_power_client.on()

# Power off the device
http_power_client.off()

Reading measurements: read() parses the JSON returned by power_read and pulls voltage and current from voltage_path / current_path (defaulting to top-level voltage and current keys). A field the device doesn't report reads as 0.0; a configured path that isn't found raises an error.

      power_read:
        url: "http://192.168.1.65/cm?cmnd=Status%2010"   # Tasmota
        voltage_path: "StatusSNS.ENERGY.Voltage"
        current_path: "StatusSNS.ENERGY.Current"
Authentication is optional and supports HTTP Basic Auth only.

Release files for jumpstarter-driver-http-power 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jumpstarter-driver-http-power 0.9.0
File Size Uploaded
jumpstarter_driver_http_power-0.9.0.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jumpstarter-driver-http-power 0.9.0
File Interpreter ABI Platform
jumpstarter_driver_http_power-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / jumpstarter_driver_http_power-0.9.0.tar.gz

Download URL jumpstarter_driver_http_power-0.9.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6362b432b6b2825a65e724d7751e11fb8521ffb1f4a2bafbd9485c560008a349
BLAKE2b-256 checksum
How to use checksums
af4f348937b44f48bb254f98621965c3c8d7067cc81102d67a0e15767e3eba2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release files / jumpstarter_driver_http_power-0.9.0-py3-none-any.whl

Download URL jumpstarter_driver_http_power-0.9.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c388ca9fce3763305573408260191b1ef47d9fbd48ec8098a8d652f3b9992129
BLAKE2b-256 checksum
How to use checksums
fbd07813fd13114375be1967f45355c834e9bb4d433c6ef3e3c896af5e40aa84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.1

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page