This code is heavily based on the work by @skagmo who did the hard work of figuring out how to communicate with the eSmart3 MPPT charger.
I have just written a few scripts to control my Heat Trap Solar hot water system based on the state of charge of my batteries as best it can be judged by the battery voltage and charging current revealed by the charger.
Since my charger and hot water system are not in the same location, I use the script esmart_server.py to accept socket connections and relay data to and from the charger over that connection. The script esmart_fsm.py runs a simply finite state machine to turn the hot water system and and off based on some simple parameters as follows: