All that effort to build a connected charging station brought its first victory as we were finally able to regulate charging based on the solar energy available. Since we had issues with our solar installation (panels are installed, but we’re still waiting for the bureaucrats approval and meter installation to activate them), we went to a friends house to experiment with his installation.
Talking to Prism is easy: all the basic stuff can be accessed and controlled via UBUS, OpenWRTs IPC system. From there, you can read and write charging parameters through any programming language, so we built a simple user interface with a backend in PHP to read data from the UBUS:
PHP for the backend, and LUA for our daemon translating the UBUS messages to MQTT to “simulate” an OpenEVSE to take advantage of all the software already developed for the OpenEnergyMonitor. Everything is well described in the OpenEVSE official documentation, and we’re implementing these MQTT messages:
prism/amp Measured current in milliamps prism/wh Calculated wh for the current session prism/pilot Pilot current in Amps (6-80) prism/state EVSE State (1–Ready, 2-Connected, 3-Charging, 4-Error)
Additionally, Prism will send events from the User Interface if no other action is associated with them:
prism/knock A numerical value for knock counts prism/touch Touch button input
After setting up the whole system, we should be able to see a nice graph like this one, where the car charging power (blue) tries to follow the solar panels production (yellow):
The blue line is not curve because by standard charging current should only be controlled at 1A steps. This image taken from the OpenEVSE docs shows that behavior, but we’re doing better as the Tesla can be linearly controlled as you can see in the first image of this post. We didn’t have the chance to test if this is the same with other cars as we only had one day available for testing, but we’ll test this further as soon as we get our solar system going.
But it doesn’t stop here: there are many ways you can play with Prism, and Node Red makes it really easy to create custom scripts to automate boring stuff! Here’s a short video demo where in just 5 minutes I setup a flow to intercept user knocks on the front cover to control the charging limit of a car:
And this was my first time with Node Red! Beside the 5 minutes setting up the demo, it only took me an evening to learn how to use it and implement stuff. I’m sure there are better ways to do it, but it works! I used hjesper’s node-red-contrib-teslams, with a few modifications and improvements. If you don’t have a Tesla, you can use the APIs for BMW, Renault, Nissan and more (just google “node-red [car manufacturer] api”).
Another useful idea is to knock once to open the car charging port. This is as easy as explained in the video, but I wouldn’t want my port to open when I’m far from home and someone touches Prism for whatever reason. A good solution for this is to implement geofencing to run the command only when the car is close to Prism (we have GPS data through the API). I’ll leave this as an exercise for the reader, as it only applies to older cars (new ones have motorized charging ports with an integrated button).
I published the sources for the daemon here. It’s an early demo and there’s a lot to improve, but since they cover most of the basic features, that’s a good starting point to develop your own stuff in LUA with MQTT – UBUS – serial connections.