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

MQTT Subscribe fail #1

Open KennethEgholm opened 4 years ago

KennethEgholm commented 4 years ago

I have seen a few times now that the PellMonMQTT service stops working in the "Subscribe and resend to PellMon" part - but the "Publish on MQTT" works just fine still. After a restart of the service operation is back to normal.

motoz commented 4 years ago

How do you mean stop working? Does it fail when starting, or does it suddenly stop working while running? Are there any errors?

KennethEgholm commented 4 years ago

It fails after running in several days. I can monitor it the next time it happens. How/where do I look for logs of errors?

KennethEgholm commented 4 years ago

I guess something like this? systemctl status pellmonMQTT -n20

motoz commented 4 years ago

I don't know much about systemd, but I think it can collect things written to stderr and put it somewhere (when used to daemonize something that doesn't know it has been deamonized). Otherwise you could run pellmonMQTT in the foreground (started from a terminal I mean). Then you can see if there is a python exception at least. It's also easy to add print statements here and there to see what happens.

You could verify that pellmon is still working (try changing settings from the pellmon webinterface, and from the pellmoncli command line client). If that works then it must be something with the broker->pellmonmqtt that isn't working anymore.

motoz commented 4 years ago

Doing some googling... The subscription should probably be in the on_connect method, otherwise it doesn't resubscribe when autoconnecting to the broker after a lost connection.

KennethEgholm commented 4 years ago

Yeah, firstæy - it is the MQTT that stops working - as I have tried manipulating the parameters directly from the webinterface - and that worked perfectly.

KennethEgholm commented 4 years ago

And yes- that would fit the bill perfectly - I have had some outages in the wifi connections.

motoz commented 4 years ago

Can you check with the latest master? At least it now tries to resubscribe after reconnected...

KennethEgholm commented 4 years ago

I will try it out today - thanks for your fast action..

KennethEgholm commented 4 years ago

FYI: I ran it in the foreground for a while and it seems to work af before at least :) :) (I saw that you changed the topic to "pellmon2" so I have changed my sensors to listen to that as well :) It is now running as a service, so will let you know how it goes ..

motoz commented 4 years ago

Oh, sorry about the pellmon2... I changed it for debugging on my laptop when I remembered I probably have another instance already running on an raspberry somewhere... Easier to debug on a laptop but I didn't mean to commit that. If this works then maybe it would be a good time soon to try to make this into something real with a config file to control what gets published and subscribed. I suppose it would be good to have encryption also, but I haven't looked into how to enable it.

KennethEgholm commented 4 years ago

No worries at all. If I can help with testing and such, I will be happy to do so. I think it will be solid now. Yes, config would be great, and encryption as an option would also be great. Thanks for your effort!