httpctrl

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 8 Imported by: 0

README

HTTP controller

Configuration

Example:

controllers:
  http:
    enabled: true
    addr: ":8080"

API

Endpoints
Attribute Method Path Example Payload
Health Check GET /healthz N/A
Full Snapshot GET /v1 N/A
Enabled POST /v1/enabled {"value": true}
Temperature Setpoint POST /v1/temperature_setpoint {"value": 22.5}
Temperature Setpoint Min POST /v1/temperature_setpoint_min {"value": 16.0}
Temperature Setpoint Max POST /v1/temperature_setpoint_max {"value": 28.0}
Mode POST /v1/mode {"value": "cool"}
Fan Speed POST /v1/fan_speed {"value": "high"}
Fault Code POST /v1/fault_code {"value": 0}

GET /v1

  • Description: Retrieve a snapshot with the current attributes of the thermostat.
  • Method: GET
  • Example Request: GET /v1

Snapshot response:

{
  "device_id": "my-thermocktat",
  "enabled": true,
  "temperature_setpoint": 22,
  "temperature_setpoint_min": 16,
  "temperature_setpoint_max": 28,
  "mode": "auto",
  "fan_speed": "auto",
  "ambient_temperature": 21,
  "fault_code": 0
}

POST /v1/:attribute

  • Description: Update a specific attribute of the thermostat.
  • Method: POST
  • Request Body: JSON object with the format {"value": <value>}
  • Example Request: POST /v1/enabled {"value": true}

GET /healthz

Returns "ok" if server is running.

Examples
  • Enable the thermostat:

    POST /v1/enabled
    {
      "value": true
    }
    
  • Set the temperature setpoint:

    POST /v1/setpoint
    {
      "value": 21
    }
    
  • Change the operating mode:

    POST /v1/mode
    {
      "value": "heat"
    }
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(svc thermostat.Service, addr string, deviceID string, logger *slog.Logger) *Server

New returns a runnable server.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL