Closed jmadden91 closed 1 year ago
Hey @jmadden91, no problem! Git is tricky :)
This looks so much better - thanks! Just a couple changes would be to delete the .pyc files and the .gitignore - both of those generally shouldn't be included in the normal git workflow / version control. Here's how I would proceed:
__pycache__
folder: rm -r rpi_power_monitor/__pycache__/
.gitignore
file from git, but keep it locally: git rm --cached .gitignore
(Both of those commands from the top level project folder)
Then, you can do git add rpi_power_monitor/__pycache__
to stage the changes for commit, followed by a commit amend, and finally a force push to overwrite your last commit. (Generally force pushing is not good but it's perfectly fine in this case)
git commit --amend
# (Maybe change the message to read something like "Add MQTT plugin"?)
git push --force
This should take care of removing the un-needed files, and updating the commit message to summarize the work you did.
Thanks mate, I think that should have sorted it. Cheers
Thanks mate, I think that should have sorted it. Cheers
Almost! :)
The .gitignore was gone, but the .pyc files in the pycache directory were still there. I removed them and amended your commit. Since I force pushed the amended commit, your local copy is now out of sync, so you'll need to reset your local copy with:
(Edit: I think this will get rid of any non-git tracked files, like your .gitignore, so use caution!)
git reset --hard origin/develop/v0.3.0-plugins
Thanks mate. I've updated the error handling a bit so it can recover if the mqtt broker disconnects.
Hey @jmadden91, I'm getting ready to merge this PR into master now. Somehow, your local __pycache__/
folder keeps getting added to the source. I just force-pushed to remove it, so you should probably do a git reset --hard origin/develop/v0.3.0-plugins
.
Then, to make sure pycache stays out, you can setup a .gitignore
file in the base project directory. Assuming ~/rpi-power-monitor is your root project folder:
echo "__pycache__/" >> ~/rpi-power-monitor/.gitignore
echo ".gitignore" >> ~/rpi-power-monitor/.gitignore
@jmadden91, I figured it would be a good idea for plugin authors to write their own documentation for their plugin, so I just created a template (and example) for my GPIO Controller example plugin. Can you fill out the template and add it to your mqtt/
plugin folder?
Hey @jmadden91, I just created the README for your plugin so that we can get it added to the list of plugins. Can you review it here and see if there's anything that you want to add or modify?
Once it is good to go, I'll add it to the plugin list in the docs.
Hey mate, sorry I got this working on my system and promptly stopped checking in here.. Yes that sounds fine. Its been working perfectly for the last few months.
FYI, the paho-mqtt
library has a new major release which introduces breaking changes to any current implementations.
See https://eclipse.dev/paho/files/paho.mqtt.python/html/migrations.html for details and a workaround.
For now, I've updated the MQTT plugin README in 7dc78e5dc553fcd1dbc17686592c076598edd004 to specify installing version 1.6.1 until the plugin can be updated to use version 2.x.
Jmadden91, How do I install the mqtt.py plugin? Thanks
Hey @5ft24dave, if your power monitor is relatively up to date with the current master branch, then you'll already have the required files needed. If you see the mqtt.py
file inside ~/rpi_power_monitor/rpi_power_monitor/plugins/mqtt/
, then you're all set.
All that's needed is to enable the plugin via the power monitor's config.toml
Configuration file according to the plugin's README.
Just update the following text with the details from your MQTT system and drop it into config.toml
:
[plugins.mqtt]
enabled = true
host = "192.168.x.x"
username = "username"
password = "password"
prefix = "powermon"
refresh = 5 # Refresh rate in seconds
... and then restart the power monitor with sudo systemctl restart power-monitor.service
.
Also note - there is a MQTT version 2 plugin: https://david00.github.io/rpi-power-monitor/docs/v0.3.0/plugin-list.html#3-mqtt-v2
Ah. I was still pointed at the dev v0.3.0 branch. pointed to master, all is there. HA is seeing data, just need to set up the sensors and I'll be good.
Sorry for the muck around. New to the github workflow. Here is a PR for the mqtt based on the develop/v0.3.0-plugins branch for you to consider.
Let me know if anything needs to be changed.
Cheers