Git Product home page Git Product logo

energy-usage's Introduction

energy-usage

Realtime energy usage reporting from Bright MQTT feed (SEP) into InfluxDB/VictoriaMetrics. Can be installed and run via pip or docker.

Configuration

Copy config.yaml.example to config.yaml and fill in your MQTT login details, and your influx/vm server details. The config file should be placed into one of the following locations:

  • /etc/energy-usage/config.yaml
  • ~/.config/energy-usage/config.yaml
  • Any dir pointed at by ENERGY-USAGEDIR env var

Local MQTT

Version 0.6 and above supports local MQTT as offered by recent glow CAD firmwares (announcement blog post). The data format is subtly different:

  • The gid label will not be populated
  • unit_rate and standing_charge metrics will be published for each meter type
  • gas_meter_reading_kwh will also be published

To use with a simple local MQTT broker with no authentication, use a config file like:

---
ca_certs: "" # Disables TLS
mqtt:
  server: 10.0.0.1
  port: 1883
  username: "" # Disables auth
  password: "" # Disables auth
  topic: "glow/#"
influx:
  server: 10.0.0.1
  port: 8428

And configure the CAD device with mqtt server 10.0.0.1, port 1883 and topic glow

Pip usage

Installation

pip install energy-usage

Run

energy-usage [--debug] [--noop]
  • --debug enables verbose output about what the script is doing
  • --noop mode will retrieve stats from mqtt, and show you what would be published to influx but does not actually send anything

Docker usage

Build

docker build -t energy-usage:latest .

Run

docker run -v config.yaml:/etc/energy-usage/config.yaml energy-usage:latest

Grafana

Hosted MQTT

grafana.energy-usage.json contains an example Grafana dashboard which consumes this data (using the prometheus query interface of VictoriaMetrics).

Grafana dashboard screenshot

Upon import of the dashboard, you will be prompted to select your datasource, and enter your unit and standing charges. These are used to plot the costs of realtime usage data, and the daily/weekly/monthly consumption using accumulated usage statistics by the meters. The dashboard does not currently use live tarrif data, as this is not provided in the Bright MQTT feed.

Local MQTT

grafana.energy-usage.local-mqtt.json contains a similar dashboard for use with the local mqtt data format.

Upon import of the dashboard, you will be prompted to select your datasource. When using local MQTT, the tariff data is included in the published metrics, and the costs displayed are using the live tariff data.

Tested with:

  • Python 3
  • VictoriaMetrics 1.40
  • Docker 19.03.05
  • Nomad 0.12.4

energy-usage's People

Contributors

optiz0r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mozster

energy-usage's Issues

Replace travis ci with GHA

Travis stopped doing free builds for opensource projects. Need to migrate build+publish to github actions instead.

Windows docker install

Hi,

I have been trying to get this running but having some issues, I have desktop docker installed on windows10.

I have done the docker build successfully and I have copied config.yaml.example to config.yaml and filled in my MQTT login details.

The folder path is set up as below

C:\Users\Mark\energy-usage

with the config.yaml in this location, however I get the error below error,

C:\Users\Mark>docker run -v config.yaml:/energy-usage/config.yaml energy-usage:latest
Traceback (most recent call last):
File "/usr/local/bin/energy-usage", line 33, in
sys.exit(load_entry_point('energy-usage==0.4', 'console_scripts', 'energy-usage')())
File "/usr/local/lib/python3.10/site-packages/energy_usage-0.4-py3.10.egg/energy_usage/main.py", line 72, in main
config = load_config(args)
File "/usr/local/lib/python3.10/site-packages/energy_usage-0.4-py3.10.egg/energy_usage/main.py", line 36, in load_config
validate_config(config)
File "/usr/local/lib/python3.10/site-packages/energy_usage-0.4-py3.10.egg/energy_usage/main.py", line 50, in validate_config
key.get(datatype)
File "/usr/local/lib/python3.10/site-packages/confuse/core.py", line 351, in get
return templates.as_template(template).value(self, template)
File "/usr/local/lib/python3.10/site-packages/confuse/templates.py", line 64, in value
return self.get_default_value(view.name)
File "/usr/local/lib/python3.10/site-packages/confuse/templates.py", line 69, in get_default_value
raise exceptions.NotFoundError(u"{} not found".format(key_name))
confuse.exceptions.NotFoundError: mqtt.username not found

I have tried placing the config.yml file in different locations with no luck,

Please can you help me with the correct location for this file ?

Many thanks

Mark

no PIP3 install?

Hi Ben - thanks for your work on this, but Im having some basic trouble trying to install.

EDIT: In order to progress, I copied the files down to my linux box, maintaining the directory structure.
I ran the PIP3 install with requirements.txt
I then executed the setup.py script; I had to comment out the lines referring to VERSION as this was not defined anywhere, and no import file that was apparent.
This allowed the build to apparently work, but then trying to run the energy-usage module generates errors:

[root@centos8-agnet energyusage]# python3 setup.py install --verbose
running install
running bdist_egg
running egg_info
writing energy_usage.egg-info/PKG-INFO
writing dependency_links to energy_usage.egg-info/dependency_links.txt
writing entry points to energy_usage.egg-info/entry_points.txt
writing top-level names to energy_usage.egg-info/top_level.txt
reading manifest file 'energy_usage.egg-info/SOURCES.txt'
writing manifest file 'energy_usage.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
installing package data to build/bdist.linux-x86_64/egg
running install_data
copying config.yaml.example -> /etc/energy-usage/config.yaml.example
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying energy_usage.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying energy_usage.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying energy_usage.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying energy_usage.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying energy_usage.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying energy_usage.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
creating dist
creating 'dist/energy_usage-0.0.0-py3.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing energy_usage-0.0.0-py3.6.egg
removing '/usr/local/lib/python3.6/site-packages/energy_usage-0.0.0-py3.6.egg' (and everything under it)
creating /usr/local/lib/python3.6/site-packages/energy_usage-0.0.0-py3.6.egg
Extracting energy_usage-0.0.0-py3.6.egg to /usr/local/lib/python3.6/site-packages
energy-usage 0.0.0 is already the active version in easy-install.pth
Installing energy-usage script to /usr/local/bin

Installed /usr/local/lib/python3.6/site-packages/energy_usage-0.0.0-py3.6.egg
Processing dependencies for energy-usage==0.0.0
Finished processing dependencies for energy-usage==0.0.0

[root@centos8-agnet energyusage]# energy-usage
Traceback (most recent call last):
File "/usr/local/bin/energy-usage", line 11, in
load_entry_point('energy-usage==0.0.0', 'console_scripts', 'energy-usage')()
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2700, in load_entry_point
return ep.load()
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2318, in load
return self.resolve()
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2324, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
ModuleNotFoundError: No module named 'energy_usage'

Ensure local mqtt is supportable

Hildebrand have added support to the CAD to support local MQTT brokers instead of their cloud one. Verify that energy-usage can properly fetch data from a local broker when used.

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.