Giter Site home page Giter Site logo

edwinmat / p1-smartmeter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mosibi/p1-smartmeter

0.0 0.0 0.0 219 KB

Read information from the P1 port on a smartmeter and publish it on a MQTT (Mosquitto) topic

License: Apache License 2.0

Python 90.52% Makefile 9.48%

p1-smartmeter's Introduction

P1 Smartmeter

Read information from the P1 port on a smartmeter and publish it on a MQTT (Mosquitto) topic.

The code is primarly written for a Sagemcom CS 50001 smartmeter, but should be compatible with more (all) smartmeters. The Sagemcom CS 50001 uses the DSMR5/ESMR5 P1 standard, for more information about this standard, see the DSMR 5.0.2 P1 Companion Standard

Installation and configuration

This (python) code uses some libraries that need to be installed. Assuming you are using a Raspberry Pi or another Debian based Linux distribution, the following command's will install the dependencies

$ sudo apt-get install python3-serial python3-pip python3-yaml
$ sudo pip3 install paho-mqtt

After installing the dependencies, clone this repository and modify the configuration file p1_smartmeter.yaml and run sudo make install.

$ git clone https://github.com/Mosibi/p1-smartmeter.git
$ vi p1_smartmeter.yaml
$ sudo make install

If your smartmeter is also DSMR5/ESMR5 based, the changes to the configuration file should be minimal. Probably you only have to change the mqtt_username, mqtt_password and mqtt_host settings.

Advanced configuration

The configuration file uses the yaml syntax, mostly the setting names will be self-explanatory, but some need some more explanation.

debug
Set this to True of False. When is set to True, it will spit out at lot(!) of debugging information. If you want to see all the data your smartmeter can deliver, run it with True for a minute. Use sudo journalctl -f -u p1-smartmeter.service to see the output.

mqtt_topic_base
This setting defines the base for every MQTT message. This will be joined with the mqtt_topic setting that's defined for an OBIS id (Object Identification System)

obis
For every OBIS id (Object Identification System), your smartmeter has data for, there should be an entry in that hash. An OBIS reference support the following:

Setting Description Data type
description Description of the OBIS id. string
publish Should this OBIS published on MQTT. boolean, True or False
average The number of measurements that shoud be averaged before publishing it on MQTT. Can't be used together with count integer
count After this number of measurements the value is published on MQTT. Can't be used together with average integer
mqtt_topic The MQTT topic where this value is published on. The string will be joined with the mqtt_topic_base setting string

Integration with Home-Assistant

In my setup I sent all the smartmeter data to the MQTT server I have installed within Hassio. Within Home-Assistant, I've configured sensors that are pointing to the several MQTT topics. My configuration.yaml contains an include statement to includes/sensors.yaml, where I define the several sensor.

configuration.yaml

sensor: !include includes/sensor.yaml

includes/sensors.yaml

- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/current_power_used_watt"
  name: "Current Power"
  qos: 0
  unit_of_measurement: "Watt"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/l1_current_power_used_watt"
  name: "Current Power L1"
  qos: 0
  unit_of_measurement: "Watt"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/l2_current_power_used_watt"
  name: "Current Power L2"
  qos: 0
  unit_of_measurement: "Watt"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/l3_current_power_used_watt"
  name: "Current Power L3"
  qos: 0
  unit_of_measurement: "Watt"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/t1_used_kWh"
  name: "Energy T1"
  qos: 0
  unit_of_measurement: "Watt"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/t2_used_kWh"
  name: "Energy T2"
  qos: 0
  unit_of_measurement: "Watt"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/gasmeter"
  name: "Energy Gas"
  qos: 0
  unit_of_measurement: "m3"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/l1_voltage"
  name: "L1 Voltage"
  qos: 0
  unit_of_measurement: "Volt"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/l2_voltage"
  name: "L2 Voltage"
  qos: 0
  unit_of_measurement: "Volt"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/l3_voltage"
  name: "L3 Voltage"
  qos: 0
  unit_of_measurement: "Volt"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/l1_amperage"
  name: "L1 Amerage"
  qos: 0
  unit_of_measurement: "Amp"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/l2_amperage"
  name: "L2 Amerage"
  qos: 0
  unit_of_measurement: "Amp"
- platform: mqtt
  state_topic: "house/0/hallway/smartmeter/l3_amperage"
  name: "L3 Amerage"
  qos: 0
  unit_of_measurement: "Amp"

Integration with Grafana

I configured Home-Assistant to sent its data to InfluxDB and Grafana uses InfluxDB as a backend. To get the dashboard (see below), I am using, import grafana.json in Grafana. The gauge needs D3 Gauge

p1-smartmeter's People

Contributors

mosibi avatar edwinmatthijssen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.