Skip to content

SpringBoot REST Service to provide SML electricity meter reading via usb optical head connection

Notifications You must be signed in to change notification settings

tbet/electricity_meter_rest_service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

electricity_meter_rest_service

SpringBoot REST Service to provide SML electricity meter reading via usb optical head connection

e.g. http://localhost:8080/energy

*{

  • "appliedMethod": "I-INFO",
  • "timestamp": "2020-10-03T15:19:17Z",
  • "v_1_8_0": 2424.3247,
  • "v_1_8_1": 2424.3247,
  • "v_1_8_2": 0.0,
  • "v_2_8_0": null,
  • "power": 2352.0,
  • "serverID": "09 01 ... 3E 5D",
  • "secindex": 17...034 *}

Rest Service for use with OpenHAB

Rest Service can run on other server than OpenHAB server

Configuration for OpenHAB to visualize electricity meter data

openhab config files to visualize electricity meter included in project

Used "Optokopf"

IR Schreib/Lesekopf USB (Optokopf) https://shop.weidmann-elektronik.de/index.php?page=product&info=24

Prerequisites

  1. Install OpenHab on Linux Server A e.g. via docker-compose.yml -> https://github.com/openhab/openhab-docker
  1. Pepare Linux Server B to serve the REST Service
  • sudo apt-get install librxtx-java
  • sudo adduser dialout
  • sudo adduser tty
  1. Build REST Service (tested with java11)
  • Activate separately both pom.xml artifacts (mvn validate) to transfer both jar files to local maven repo
  • maven based SpringBoot Service (mvn clean package)
  1. Transfer build jar file to Server B and start REST Service
  • Start REST Service via "java -jar energy_only-1.0-SNAPSHOT.jar"
  • Crontab restart scenario "@reboot /usr/bin/java -jar /home/USERNAME/electricity_meter_rest_service-1.0-SNAPSHOT.jar > /dev/null 2>&1"

Java

Following parameters are relevant

  • -Djava.library.path=/usr/lib/jni
  • -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0

Related links

  1. General: https://www.heise.de/select/ct/2018/8/1523221532486836
  2. Library jSML: https://www.openmuc.org/sml/download/
  • Behavior changed in version 1.1.x so i used the older 1.0.1 version
  1. Library jrxtx: https://github.com/openmuc/jrxtx
  • Compiled jar with native gnu.io lib included
  1. Other Java Project where both components is on one server: https://github.com/jblu48317/SMLToJSON

About

SpringBoot REST Service to provide SML electricity meter reading via usb optical head connection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages