orlopau / semp

A REST Api for the SMA SEMP protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SEMP2REST

Adapts the SMA SEMP protocol to REST for easier usage.

REST Api

Documentation for the specific functionality of parameters can be found on SMAs Website under SEMP.






Usage

The library can be used in two ways.

1. Docker (preferred)

  1. Install docker.

  2. Clone.

    git clone https://github.com/orlopau/semp.git
    cd semp
    
  3. Run the container

    --net=host is needed because of SSDP device discovery, which uses UDP. This means that port flags will be ignored. To use different ports, specify a build flag AND a environment variable on runtime as shown below.

    The standard ports are 9765 for SEMP and 9766 for the API.

    -t specifies the tag.

    docker build -t semp --build-arg semp=9765 --build-arg api=9766 .
    

    When running the container, the IP Address of the host must be specified.

    If the ports have been changed from the standard configuration, additional env variables have to be added.

    Use the -it flag for testing (interactive mode).

    Every argument except IP is optional.

    docker run -it --net=host \
        -e IP="192.168.188.101" \
        -e SEMP_PORT=9765 \
        -e API_PORT=9766 \
        -e UUID="290B3891-0311-4854-4333-7B10BC802C2D" \
        -e NAME="Semp Gateway" \
        -e MANUFACTURER="Semp2Rest" \
        semp
    

    For deployment remove the -it flag and add --restart=always to restart on boot and error.

2. Module

Download the module from npm.

npm install semp2rest --save

Then use the module as follows:

const Gateway = require('semp2rest');
const gateway = new Gateway("290B3891-0311-4854-4333-7C70BC802C2D", "192.168.188.101", 9089, 9090);
gateway.start();

Typescript works out-of-the-box.

About

A REST Api for the SMA SEMP protocol


Languages

Language:TypeScript 99.6%Language:Dockerfile 0.4%