Sorting out some niggles
It’s been a while since I’ve written. This has been because, although I’ve extended my solar panels automations quite significantly1, I’ve been trying to sort out some niggles in some of my automations. I think I’ve finally sorted them so I’ve put together a quick summary about them in case they help anyone else out there who’s had similar issues.
Not all emails are equal
In my last post I described how I’d automated the processing of the Octopus emails that tell me about an imminent free power period. At the time of writing I found my approach was working as expected. However, it then seemed to stop with no obvious cause - after “some time” received emails weren’t being detected. It seemed the IMAP integration would eventually hang for no reason (I use Gmail). After much time wasted, I believe the cure is to ensure the Enable Push-IMAP if the server supports it. Turn off if Push-IMAP updates are unreliable. is not set (the clue is in there isn’t it!).
Anyway, in my desperation to find a fix, I reworked my processing entirely in NodeRed. It’s worth summarising the steps I use to get the subject from the email into the Javascript I described in my last post. This is how it looks:
And this is what is does:
The blue events: all node fires whenever there’s an event of type imap_content and I put the event data in the msg.payload. Everything of interest for me is in msg.payload.event.
The IMAP integration can fire several events for a single email. I therefore filter only those events with msg.payload.event.initial is true so I only see an email once.
I then filter only those emails with msg.payload.event.sender equal to hello@octopus.energy.
Finally, I only accept the free power emails ie msg.payload.event.subject contains Power up for free.
Programmatically changing when my solar battery (dis)charges
One of the things I have started doing with my Growatt solar system is to try and discharge my battery to the grid before an Octopus free power period starts and then charge it fully during the free power period. The idea is to maximise the revenue I get from exporting to the grid.
I have made some good progress on this and will explain more in a future post. However, an absolutely essential component is the ability to change the charging and discharging periods for the Growatt inverter programmatically. It’s not feasible to change these manually using the Growatt website or Shine app.
Unfortunately, the grottserver application I mentioned in an earlier post is too limited for this; it only allows the reading and writing of individual registers. To change the timing of, say, a discharge requires setting three timeslot registers in a single transaction (if you try to set them individually, not only does it not work there’s a real risk registers will be reset to earlier values).
So, building on this, I have developed an enhanced version of grottserver that I use for controlling my Growatt inverter (I now never use the Growatt website or Shine app). This has required me to learn some Python (!). The details are beyond the scope of these posts, you can discover more here. But briefly, my version provides the following additional functionality:
No requirement for libscrc (makes it easier to deploy)
Read all the registers from the inverter and data logger in one url command and display them in a simple web page. The inverter registers are read in a single transaction.
Set a triple of timeslot registers in one transaction using an http PUT
If anyone wants to know more, I’m happy to answer any questions.
I’m now charging my battery to a variable level overnight on the cheapest rate and I discharge my battery to the grid when I get the best export rate. I’ll be writing about this soon. Oh, and I now have a Tesla and I’m starting to automate its charging - stay tuned for more on that soon too!