Git Product home page Git Product logo

rpi-power-monitor-mqtt's Introduction

rpi-power-monitor-mqtt

Publish data from rpi-power-monitor to MQTT

Building on the amazing work at https://github.com/David00/rpi-power-monitor/wiki, this script will export data from influx and send it to an MQTT server. My specific use case for this is to bring the data into Home Assistant, but this could certainly used for many other purposes.

Prerequisites

You'll need to install the InfluxDB and Mosquitto clients that the script uses.

apt-get install influxdb-client mosquitto-clients

Installation

Install The Script

Copy the powermon-mqtt.sh script to /home/pi

Set Up Cron

Edit the cron tab with the command "crontab -e" and enter the example below, substituting your MQTT server and prefix. If your server uses authentication, edit the script and update the variables.

Example cron tab:

* * * * * /home/pi/powermon-mqtt.sh [mqtt-server] [mqtt-prefix]

Add To Home Assistant

This can be added to Home Assistant as an MQTT sensor, such as:

- platform: mqtt
  name: "Powermon CT 0"
  state_topic: "powermon/ct_0/power"
  icon: mdi:electron-framework
  unit_of_measurement: 'W'

- platform: mqtt
  name: "Powermon Power Home"
  state_topic: "powermon/home_load/power"
  icon: mdi:electron-framework
  unit_of_measurement: 'W'

You can also add an integration sensor which will add this power source to the Energy Grid.

- platform: integration
  source: sensor.powermon_power_home
  name: powermon_energy_spent
  unit_prefix: k
  round: 6

rpi-power-monitor-mqtt's People

Contributors

heytensai avatar richie256 avatar

Stargazers

Emerson Corder avatar Bryant Eadon avatar  avatar

Watchers

 avatar James Cloos avatar  avatar Bryant Eadon avatar  avatar

Forkers

emersonsc

rpi-power-monitor-mqtt's Issues

Home Assistant Energy

Question, where you successful to configure it to show up into Home Assistant Electricity Grid consumption?

That would be nice to have.

Installing

I'm a bit confused. After I install the prerequisites, how do I install the script? I'm looking to buy the RPI power monitor and it directs you to here to implement MQTT for home assistant use but I don't get how to install this

Suggestions

Hey mate,

Thank you very much for your work with this script.

Just a few suggestions for improvements to help a novice like me get it working. Firstly maybe just a note in the readme to first install/check installed the two packages required:

  • apt-get install influxdb-client
  • apt-get install mosquitto-clients

Secondly, I have a username and password set for my mosquitto broker, so had to add a -u "username" and -P "password" variable. Would it be possible to declare the variables at the start of the script like you do with the "server" and "prefix"?

Cheers
Jake

Mismatch of metrics using Last Power value

When querying the Influx every second using the Last Power metrics will ends up with discrepancies between Grafana and Home Assistant.

To test it, I've run this mqtt for a while then Process them into Home Assistant.
If a compare yesterday using the Last Power Metric, we got 44.66kWh on HomePower Dashboard vs 44.56kWh on HomeAssistant.
Home Power Dashboard
Home Assistant

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.