motoz / pellmonMQTT

Connect to a running pellmon instance over DBUS and publish all data on MQTT
GNU General Public License v2.0
4 stars 2 forks source link

How do I start this? #5

Open StarChildDK opened 1 year ago

StarChildDK commented 1 year ago

When I try to start this I get an error:

Traceback (most recent call last): File "pellmonMQTT.py", line 25, in import paho.mqtt.client as mosquitto ImportError: No module named paho.mqtt.client

How do I start it?

StarChildDK commented 1 year ago

Ok installed a paho.mqtt, bbut now I just gets:

Traceback (most recent call last): File "pellmonMQTT.py", line 194, in dbus.start() File "pellmonMQTT.py", line 41, in start self.bus = Gio.bus_get_sync(self.bustype, None) GLib.Error: g-io-error-quark: Cannot autolaunch D-Bus without X11 $DISPLAY (0)

If this code have requrements why isn't it listed in the readme?

StarChildDK commented 1 year ago

sudo dbus-launch python pellmonMQTT.py works :) How to add password and username? user:password@ip does not work

motoz commented 1 year ago

Pellmon listens on the SYSTEM bus when it is installed. Use the --dbus parameter to switch to it instead of the SESSION bus. And don't run as root.

motoz commented 1 year ago

I never used this myself, just made it for some guy who wanted it and then disappeared without even trying it. But some have found it useful anyway so it was not completely in vain. There is no support for usernames, password nor encryption. Googling seems easy enough https://techoverflow.net/2021/12/27/how-to-set-username-password-in-paho-mqtt/

StarChildDK commented 1 year ago

Ok, thanks, I have already tried the settings in the link, but if I use the settings then the pellmonmqtt doesn't send anything out. As an alternative I have to run the mqtt broker without a password. But if I can get you pellmonmqtt to work it would solve all my wishes, the HA can control the pellet burner, and Pellmon can log everything as always, it would be a perfect win-win.

motoz commented 1 year ago

Well I never tried with username&password, but I should still have a broker running somewhere. Let me try...

python pellmonMQTT.py -H 192.168.0.5 -d SYSTEM
broker connected
 dbus connected
Publish 1019 to pellmon/advanced_data-air_pressure
published
Publish 11.6 to pellmon/advanced_data-auger_pause
published
 Publish 1.4 to pellmon/advanced_data-auger_run
Publish 1.6 to pellmon/advanced_data-boiler_diff
 published
published
 Publish 87.2 to pellmon/advanced_data-boiler_diffsum

seems it's still working

StarChildDK commented 1 year ago

I have found the error, the password function doesn't like special chars like "æ". I can read data now! FANTASTIC! Now I just have to learn how to send data back, but that's on me .) Is there anywhere I can define what data pellmonMQTT will transmit? Like "mode", "burner_on", "burner_off"?

motoz commented 1 year ago

Everything readable is published under pellmon/item and everything writable subscribed to under pellmon/settings/item. Item ids can bee seen from the web interface or from pellmoncli. If you want only a subset you'll have to write some code to filter out that.

StarChildDK commented 1 year ago

Hmm, but in pellmon I can see mode? is that writable? These are the ones that mqtt explorer sees: smoke_temp = 73 oxygen = 16.9 oxygen_desired = 16.7 power = 22 motor_time_perm = 10734361 feeder_time = 10734361 power_kW = 2.9 motor_time = 10734361 time_minutes = 18;48 boiler_temp = 61.6 boiler_return_temp = 45 light = 99 consumptionData7d = {"bardata": [{"color": "#cdcdcd", "bars": {"barWidth": 40073000}, "data": [[1677196800000, 18.973373593192424]], "label": "prediction"}, {"bars": {"barWidth": 40073000}, "data": [[1677196800000, 8.8]], "label": "current"}, {"data": [[1676592000000, 17.8], [1676678400000, 25.27], [1676764800000, 16.47], [1676851200000, 21.49], [1676937600000, 17.02], [1677024000000, 13.56], [1677110400000, 18.67]],… consumptionData24h = {"bardata": [{"color": "#cdcdcd", "bars": {"barWidth": 712000}, "data": [[1677236400000, 0.6067415730337079]], "label": "prediction"}, {"bars": {"barWidth": 712000}, "data": [[1677236400000, 0.12]], "label": "current"}, {"data": [[1677150000000, 0.57], [1677153600000, 0.61], [1677157200000, 0.96], [1677160800000, 0.88], [1677164400000, 0.87], [1677168000000, 0.73], [1677171600000, 0.79], [16771752… feeder_low = 2.12 consumptionData8w = {"bardata": [{"color": "#cdcdcd", "bars": {"barWidth": 471910000}, "data": [[1676764800000, 123.09770930897841]], "label": "prediction"}, {"bars": {"barWidth": 471910000}, "data": [[1676764800000, 96.05]], "label": "current"}, {"data": [[1671926400000, 131.82], [1672531200000, 131.64], [1673136000000, 136.4], [1673740800000, 145.52], [1674345600000, 209.44], [1674950400000, 141.95], [1675555200000… outside_temp = 5 chute_temp = 20 consumptionData1y = {"bardata": [{"color": "#cdcdcd", "bars": {"barWidth": 2087626000}, "data": [[1675148202000, 530.0149356254425]], "label": "prediction"}, {"bars": {"barWidth": 2087626000}, "data": [[1675148202000, 426.88]], "label": "current"}, {"data": [[1644044202000, 596.23], [1646636202000, 494.14], [1649228202000, 251.57], [1651820202000, 35.28], [1654412202000, 17.35], [1657004202000, 12.07], [1659596202000…

StarChildDK commented 1 year ago

I can't seem to figure out where I can see the pellmon/settings/item items, but I'm also new at mqtt, so I'm learning as I go :)

motoz commented 1 year ago

Don't you have the pellmon webinterface? You can also use pellmoncli:

pellmoncli list

, to see all items. I don't think mqtt explorer can see that some other client has subscribed to some topic on the broker. Anyway, you can stop the burner by writing (publishing) '1' in raw mode to pellmon/settings/misc-stop, starting is pellmon/settings/misc-start image

StarChildDK commented 1 year ago

Thanks, yes I have the web interface, so the boiler set temp is: pellmon/settings/boiler_temp_set then raw and number? I could not find the misc-start, where is that listed? I would still like to check the status of "mode" that I have in the ScotteCom where I have a script that controls the burner and all the motor valves in the house. Is that value available in the mqtt?

motoz commented 1 year ago

As I said, everything pellmon has from your burner is available in mqtt. Oh, you have an old (V4-5-6) model. Kind of assumed you have a V7 or newer since you didn't mention anything. I don't really remember how they worked, but there seems to be a 'burner_on' and 'burner_off' item here: https://github.com/motoz/PellMon/blob/master/src/Scotteprotocol/datamap.py . The range is min:0 and max:0 so probably you should write zero to them then.

StarChildDK commented 1 year ago

cool there was the list, ok. but shouldn't pellmonmqtt list all of these: 'power': { ('0000','zzzz') : data (FrameZ00, 0, 0) }, # Z00 is probably supported on all version 'power_kW': { ('0000','zzzz') : data (FrameZ00, 1, 1) }, 'boiler_temp': { ('0000','zzzz') : data (FrameZ00, 2, 1) }, 'chute_temp': { ('0000','zzzz') : data (FrameZ00, 3, 0) }, 'smoke_temp': { ('0000','zzzz') : data (FrameZ00, 4, 0) }, 'oxygen': { ('0000','zzzz') : data (FrameZ00, 5, 1) }, 'light': { ('0000','zzzz') : data (FrameZ00, 6, 0) }, 'feeder_time': { ('0000','zzzz') : data (FrameZ00, 7, 0) }, 'ignition_time': { ('0000','zzzz') : data (FrameZ00, 8, 0) }, 'alarm': { ('0000','zzzz') : data (FrameZ00, 9, 0) }, 'oxygen_desired': { ('0000','zzzz') : data (FrameZ00, 11, 1) }, 'mode': { ('0000','zzzz') : data (FrameZ00, 16, 0) }, 'model': { ('0000','zzzz') : data (FrameZ00, 17, 0) }, 'motor_time': { ('0000','zzzz') : data (FrameZ02, 0, 0) }, 'el_time': { ('0000','zzzz') : data (FrameZ02, 1, 0) }, 'motor_time_perm': { ('0000','zzzz') : data (FrameZ02, 2, 0) }, 'el_time_perm': { ('0000','zzzz') : data (FrameZ02, 3, 0) }, 'ignition_count': { ('4.99','zzzz') : data (FrameZ03, 8, 0) }, 'boiler_return_temp': { ('6.03','zzzz') : data (FrameZ06, 0, 0) }, 'hotwater_temp': { ('6.03','zzzz') : data (FrameZ06, 1, 0) }, 'outside_temp': { ('6.03','zzzz') : data (FrameZ06, 2, 0) }, 'indoor_temp': { ('6.03','zzzz') : data (FrameZ06, 3, 0) }, 'flow': { ('6.03','zzzz') : data (FrameZ06, 4, 0) }, 'version': { ('4.99','zzzz') : data (FrameZ04, 1, -1) }, # decimals = -1 means that this is a string, not a number

There is the "mode" i asked for :)

StarChildDK commented 1 year ago

Or is it only published when the value changes?

motoz commented 1 year ago

It's published when you start pellmonmqtt and when the value changes. I can't really debug this since I don't have that controller anymore. Anyway pellmoncli and pellmonweb uses the same dbus interface, so if you see them there you should see them in pellmonmqtt also.

StarChildDK commented 1 year ago

I tried publishing pellmon/settings/burner_off = 0000 and it works, and then mode came in the explorer, so everything works! Thank you for all your work and help! I have used pellmon for many years. Do you have a buy me a coffee or something like that? ;)

StarChildDK commented 1 year ago

I'm having issues, when the burner stops, the mode and power values don't update, they are stuck at the "running" value and the last power value, why is that?

motoz commented 1 year ago

No idea, do they show the same in the web interface or pellmoncli?