|
|
machine-readable inverter data Tuesday, April 30 2024
In my dreamlife, I have several different threads that pick up from time to time in subsequent dreams, weaving nearly-coherent alternative pasts. In one of these threads, I have successfully committed murder and concealed this fact from everyone, though I am in constant fear of the truth being revealed. Sometimes in an effort to better hide the evidence, I either revisit the murder scene or where I've disposed of the corpse to improve my concealments or further dilute the evidence. This morning I awoke from such a dream still believing that I had actually committed murder but relieved that my latest botched attempt at hiding the evidence had been "just a dream." In the dream, I'd logged onto a computer system and deleted my victim's information from a database but then immediately regretted having done so for fear that the system had logged my actions, thereby better connecting me to my victim.
Throughout the day today, I periodically revisit the scatter chunks of hard-to-split wood spread out below the woodshed and put the effort in to split them. Usually this required a lot of brutal swinging of the splitting maul and sometimes even the application of wedges. I was finding the old tree of heaven wood easier to split than I'd feared, but the twisted silver maple and even some of the white ash was proving more difficult. I'm used to splitting much easier-to-split wood like , red oak, chestnut oak, and, at the cabin, beech, sugar maple, black cherry, and even more straight-grain white ash. One of the unpleasant things about processing wood that has been in one place for nearly two years is that it's full of creatures, particularly under the bark, which now typically just falls away. There will be lots of pillbugs, centipedes, slugs, earthworms, beetle larvæ, and whole colonies of ants of ants. I don't like destroying their worlds, but since creatures will move into any form of clutter, decluttering often involves such evictions.
A big focus for me today when I found myself sitting in front of my computer was to trying to figure out how to get computer-readable data from the SolArk inverter at the cabin. Doing so would give me a lot of useful information that would allow me to automate other tasks such as switching on and off high-power loads and even doing things like circulating water in a potential solar hot water system. The problem has been that there's no published API for the SolArk inverter and there doesn't seem to be one for the website I use to read the data myself (that is, it only provides data in human-readable form). I started out by looking over the data that I'd captured being sent by the inverter to the WiFi dongle that transmits data to the internet. There wasn't much human-readable data to make sense of in that, though I did learn that the "home" it phones to is iot.e-linter.com, port 51100. Eventually I resorted to googling some of the short byte streams I'd captured, and that led me to a thread about "hacking the SunSynk WiFi dongle." I'd seen mention of SunSynk before in the context of SolArk data collection, but opinions had differed on how similar SunSynk was to SolArk. From reading the thread, though, I could tell that under the hood, the two systems were identical. They even used the same backend url for their respective websites. Reading the thread eventually emboldened me to do something I generally shy away from due to how frustrating it can be: creating a PHP script that can simmulate a human using a web browser to view a website. Closer inspection had revealed an endpoint that would give me most of the actionable data I could use for automation if only I could somehow automate the login process. This required using OAuth, a technology that normally causes my eyes to glaze over. Not wanting to wade into the details, I described the problem to ChatGPT and said I needed a PHP script to do the login. It came back with something using the Guzzle library that didn't work, but I hacked away at it, adding in various headers that might've been required. At first this caused the script to go from obtaining some sort of "media type" error to a 500 error, but after that I was stuck. I kept asking ChatGPT for suggestions, and it would cheerfully come up with them. But none of them worked, and this went on for awhile, making me increasingly pessimistic that I would ever be able to get machine-readable data from the server. But then on closer inspection of the Chrome network log (in the Chrome debugger), I saw that the successful login seemed to be sending the username, password, and other data to the backend in the form of a JSON-encoded string, something I couldn't be sure Guzzle was doing (since it's a black box that conceals its behavior). I mentioned this JSON encoding to ChatGPT, and it came up with a solution, one that completely changed the error message I was getting. Now instead of a 500 error, I was getting an error that some data that should've had a value was null. This suggested the JSON was encoded somewhat wrong. Perhaps the necessary values were too "deep" in the JSON object. So I removed a chunk that contained headers and passed in just the flat JSON of the necessary variables, and, to my delight, it came back with an authentication token, one that worked. In short order, I was able to download computer-readable data showing the solar panel and battery levels for an entire day, right up to the minute. I finally had what I needed to obtain inverter data. Of course, this isn't live data directly from the inverter and to use it the cabin must have access to the internet, but it's better than no data at all.
Sometime in the midst of all that, Gretchen went off to teach her prison poetry class and I took a bath to wash away the accumulated grime from the recent yard work. (The bath water ended up with a distinctly greenish hue.) I also finished up the installation of Gretchen's new desktop computer by removing one of the two SSDs it had in it, connecting up an optical drive, and finally putting on its cover. It's been working reliably for over a week now, dutifully going to sleep like it's supposed to.
For linking purposes this article's URL is: http://asecular.com/blog.php?240430 feedback previous | next |