micw / tibber-pulse-reader

A tool to read data directly from tibber pulse and publish it locally
43 stars 7 forks source link

Exit if Mqtt broker is unavailable #18

Closed Papst closed 9 months ago

Papst commented 1 year ago

First: Great work. It works like a charm with one exception:

If my mqtt broker is offline (Restart,...) the timber pulse reader exits with a disconnected message. Is it possible to continue and just try again to send the mqtt message with the next reading?

micw commented 1 year ago

That's mainly because I run it in docker/kubernetes. So when it's terminating, it is auto-restarted and I get a metric for it.

I do plan local persistence + auto-reconnect. But not directly within this project. I hav started to consolidate several of my projects for processing meter data into one project so that I have all new features available on all sources/destinations.

Have a look at https://github.com/micw/homedatabroker. Tibber is not yet integrated but when I find some time, I'll do it (currently the new project has only modbus/tcp ad source).

Papst commented 1 year ago

Ok, thanks. I will follow the development of your homedatabroker.

micw commented 1 year ago

Hello. I re-open this for discussion because I'm about to implement mqtt in homedatabroker these days. I will also port the tibber pulse reader code to it, so that users can switch over.

You wrote:

Is it possible to continue and just try again to send the mqtt message with the next reading?

I will definitively implement re-connect. But what would be appropriate for metrics that are read while mqtt is offline. Since these mqtt messages usually have no timestamp, does it make sense to cache it and send it later? or should we just drop it until mqtt is available again?

Clanchef commented 1 year ago

Hello, I also appreciate this project and I use it since several months now. Recently mosquitto got updated automatically and tibber pulse reader lost connection ... in this case it would be better to drop the messages and wait until mqtt is back online again. I use the data for evcc and it just needs current data and no history.

micw commented 1 year ago

Hello,

nice, I also use it for EVCC (as well as for a dashboard). I will implement reconnect handling first and skip the history stuff on MQTT unless I have a use-case for it.

I write back here, as soon as I have MQTT and Tibber-Pulse integrated in homedatabroker.

Papst commented 1 year ago

I would also prefer to drop the messages until the mqtt broker is back online.

micw commented 1 year ago

@Papst @Clanchef I have integrated the pulse http reader into HomeDataBroker today. It works for me ;-) Please give it a try. Feel free to open issues/discussions there if you have any questions. Documentation needs some work but there is an example config with a lot of examples.