Using a telegram bot to help me manage a solar off-grid setup

As some of my reader might know, I live off-the-grid, using solar power for electricity. My setup is quite small, a 9-panel ~2800W array, with 9.9kWh of battery capacity.

However, we do have a lot of electrical needs, since we cook with an induction cook-top, have a dishwasher and an electrical water heater. Back in 2019 I wrote Hacking my way through off-grid survival, in which, amongst other things, I wrote how I used a Raspberry Pi mini computer to poll my inverter and upload useful data to a public server. That way I could easily monitor my system. (Yes, modern inverters already have included cloud solutions). But that is not all, I then coded a small program to add some rudimentary “smartness” to my setup. Using a WiFi-enabled smart power plug, I could automate turning the water tank on or off, based on the solar production, battery capacity and time of day. This still required a lot of time and energy on my part, because I need to very frequently keep an eye on things (except when we have sunny days).

About a month ago I started playing with the idea of creating a personal assistant telegram bot. I wrote about it recently, if you are curious. I was mostly interested in getting reminders and my calendar commitments using an instant-messaging platform. I added a couple more extra features in the meantime. It’s public, you can go check it out and use it for yourself as well.

Then I started to connect the dots, it would be amazing if I could have this bot actually provide me with useful info when I needed it. That way, I could ignore the solar system completely and let the bot handle all the automation.

Being off-grid and depending on solar with limited power storage capacity, means we need to always keep an eye on “what’s coming”. Today we may be having a bright sunny day, but if we know tomorrow we will have less than 1 hour of sun, then we need to change the way we use power today. All this concerns are now delegated to the bot.

In order to get data we could trust, I chose to use Meteoblue’s amazing weather forecasting service. It’s probably one of the world’s most advance weather forecasting, with a high level of detail, extensive set of parameters and high resolution.

I identified 4 main things the bot should be able to do:

  1. Let me know in advance(2 days) of upcoming cloudy and/or rainy days
  2. Give me a forecast of sun hours for a 3-day period
  3. Give me direct access to raw meteograms with cloud layers, temperatures and precipitation
  4. Warn me and my wife in case there is a malfunction or dangerous state with the solar system

Number 1 is perhaps the most useful, as it is the one that allows me to stop worrying about the weather and let the bot handle it for me. I set it up so that everyday at 7am it checks the sun hours and precipitation forecast, and only sends me a message if there is anything worthwhile knowing. If the forecast is good enough to not worry, I won’t receive any message.

Number 2 and 3 are manual operations that I can request at any time. I use these If I’m a bit more picky about the forecasting and want to take a better look myself.

Last, but not least, Number 4 is used to periodically check if everything is OK with the solar production and the batteries. This basically checks two things:

  • solar production is > 0 during the day
  • battery capacity is > 40% (below these we know we have to be more cautious and monitor the batteries more frequently )

Here’s an example of it working when last week I unplugged the panels to replace a damaged cable

This has been great since now I stopped using my phone so much to refresh a page where I had raw data. I’m also more confident that if I’m away for 2 or 3 days my wife will be able to manage things easily without having to worry, or me having to check on things remotely.

Going Forward

All the recent work on the bot has mostly been dedicated to these private features which only me and my wife can access. I’d like to add more to it, so that the automation of the water tank heater could be done by the bot instead of my previous script. The bot, having detailed forecast available at all times can make much better decisions than anything else I’ve done before.

I’ll also introduce some more manual commands to be able to turn things on/off, and have the bot call certain APIs directly, instead of me having to use different apps on the phone to do so.

Leave a Reply