The solutions for the cars became like this:
If they should start at the same time I’ve set an offset on either one or the other state, since it takes a few seconds for the Modbus to write and update.
I’ve also optimized the DISCHARGE a bit. Depending on the price, it now discharges at different power. The loading cost for CHARGING is always below 40 öre (cent), that means either 1 or 2 SEK profit / kwh.
EDIT:
Btw @steffanlm Just implemented your “Rate limit” before writing to Modbus, nice addition!
I’m a bit more cautious and decided to go with 1 message every 5 seconds. NVRAM wear…