Sign inSign up

badsmoke/labpowerui-server

By badsmoke

Updated over 1 year ago

Image
0

317

badsmoke/labpowerui-server repository overview

⚠️ Warning: This project is still in early development. Some features may be incomplete, and breaking changes may occur. Contributions and feedback are welcome!

GIT LabPower - Server

LabPowerUI - Server

LabPowerUI-Server is a RESTful API for controlling and monitoring lab power supplies such as the Owon SPE6103 and SPE3103, as well as Kiprim DC310S and DC605S models. It provides endpoints for adjusting voltage, current, and power limits, retrieving real-time data, and managing storage settings.

Features

  • Control and monitor supported lab power supplies
  • Store power supply data in Redis
  • Adjustable data storage interval and limits
  • Support for fake values for testing purposes
  • Logging system for debugging
  • OpenAPI (Swagger) documentation

Installation & Usage

Docker Compose Setup

To deploy the LabPowerUI-Server along with Redis and the LabPowerUI frontend, use the following docker-compose.yml setup:

version: "3"
services:
  power-supply-server:
    image: badsmoke/labpowerui-server
    ports:
      - "1234:1234"
    environment:
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - REDIS_DB=0
      - USB_DEVICE=/dev/ttyUSB0
      - STORAGE_TASK=true
      - STORAGE_INTERVAL=1
      - STORAGE_LIMIT=10000
      - FAKE_VALUES=false
      - LOGGING=false
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
    restart: always

  redis:
    image: redis:7-alpine
    restart: always
    ports:
      - "6379:6379"

  power-supply-ui:
    image: badsmoke/labpowerui
    ports:
      - "80:80"
Running Without Docker

If you prefer running the server locally without Docker, follow these steps:

git clone https://github.com/badsmoke/LabPowerUI-Server.git
cd LabPowerUI-Server
python -m venv venv
source venv/bin/activate  # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
python src/main.py

API Documentation

The API follows OpenAPI standards and provides a Swagger UI at:

http://localhost:1234/api/docs
Example Endpoints
Get Power Supply Values
GET /api/storage/data?limit=1

Response:

{
  "status": "success",
  "code": 200,
  "message": "Power supply data retrieved successfully",
  "time": "47:57:238633",
  "device": "fake psu",
  "data": {
    "readingVoltage": 1.7,
    "readingCurrent": 0.7,
    "voltage": 19,
    "current": 5,
    "voltageLimit": 30,
    "currentLimit": 8,
    "power": 1.19,
    "output_status": true
  }
}
Set Output State
POST /api/set/output
Content-Type: application/json

{
  "output": true
}
Enable Logging
POST /api/logging
Content-Type: application/json

{
  "logging": true
}

Full API documentation is available in the swagger.yaml file.

Configuration

The following environment variables can be set:

VariableDescriptionDefault Value
REDIS_HOSTRedis server hostnameredis
REDIS_PORTRedis port6379
REDIS_DBRedis database index0
USB_DEVICEUSB device path for PSU/dev/ttyUSB0
STORAGE_TASKEnable data storage (true/false)true
STORAGE_INTERVALInterval for storing data (sec)1
STORAGE_LIMITMax number of stored entries10000
FAKE_VALUESUse fake PSU values (true/false)false
LOGGINGEnable logging (true/false)true

Dependencies

LabPowerUI-Server is built with:

  • owon-psu-control – Python library for communicating with supported power supplies
  • Flask – API framework
  • Redis – Storage for logging and historical data

Frontend

The LabPowerUI-Server is designed to work with the LabPowerUI web frontend. It provides an easy-to-use interface for monitoring and controlling your power supply unit.

License

This project is licensed under the MIT License.

Contributors

  • @badsmoke

Contact

For issues or contributions, open an issue in the repository or reach out via email.

[email protected]

Tag summary

Content type

Image

Digest

sha256:afdbda0d3

Size

49.3 MB

Last updated

over 1 year ago

docker pull badsmoke/labpowerui-server