Skip to main content

A power driver for HTTP enabled PDUs or smart sockets, like the Shelly splug

Project description

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:

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

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 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

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()

Notes

  • The power reading response parsing is not yet implemented. The driver currently returns dummy values (0.0V, 0.0A).
  • Authentication is optional and currently supports HTTP Basic Auth only.
  • All HTTP requests will raise exceptions on HTTP error status codes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jumpstarter_driver_http_power-0.7.4.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jumpstarter_driver_http_power-0.7.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file jumpstarter_driver_http_power-0.7.4.tar.gz.

File metadata

File hashes

Hashes for jumpstarter_driver_http_power-0.7.4.tar.gz
Algorithm Hash digest
SHA256 8eba08bca9826fbb2e6682581a8e4bbc032dfefdd8a9c4e407136e1e2e20b80a
MD5 280ec5e5c213501ba28110a7076400ff
BLAKE2b-256 ebf0361134916edb56669de593e938f4023e6dfe7e715a8bd16e9dc59bb96647

See more details on using hashes here.

File details

Details for the file jumpstarter_driver_http_power-0.7.4-py3-none-any.whl.

File metadata

File hashes

Hashes for jumpstarter_driver_http_power-0.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fd48f7369cf4bac965b2c1e69a79b56f89bc89298a1335460f7683659aae5006
MD5 9b3ae47d434328d954c21bcbb5919ade
BLAKE2b-256 17abf69e7ddd235b8d0f672222b08c183e1b92e084a09ec56ee81b702a6cdaa6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page