cyrils/renogy-bt

Feature Request - Send MQTT message on error

Closed this issue · 5 comments

I have three batteries daisy-chained together to one BT-2 module. As it stands, I have a cron job that runs the equivalent of example.py for each battery on a regular interval. About half the time, an error occurs when pulling one or more of the sets of data. This isn't a huge deal, as it basically means that my data lags by about 15 minutes or so, but it would be good to know if something is actually broken so I can take a look.

What I'd like is to have an MQTT message published every time a read error occurs (to a different topic from the one where data goes on success.) Thanks!

Currently this is designed to exit on error. If you want the error logged, you might want to introduce a new callback on_error to the BaseClient and RoverClient, and have it called from BaseClient.py#L127. I can look into it sometime next week.

Also checkout the bleak port which uses a different bluetooth library and supposed to be more stable.

Can you checkout #72 if it works? It doesn't do any mqtt per se, but in the callback you can do your stuff.

Looks great! I went the rest of the way with it in #74 (into #72.) Thanks!