Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Tesla Wall Connector load sharing protocol

Picar

Member
Oct 17, 2018
10
3
Berlin
@Steffen75D Im not used to python codeing but it should look like the following...

Code:
m = re.search(b'^<LL control=\".*LeistungPV/state\".*value=.([0-9]*)', greenEnergyData, re.MULTILINE)
 

Randy Spencer

Active Member
Mar 31, 2016
3,610
3,652
Alameda, CA
I am new to all this. I have been trying to keep up, but I keep getting stymied by all the code examples. My understanding after trying to re-read this thread is that it started with reverse-engineering the communications between a slave and a master TWC and then @CDragon released software that communicates with a Tesla Powerwall and then uses this protocol to change the charge rate of the TWC to reflect the amount of solar energy being generated. I have seen the video showing its use:


My question is, has anyone used this and controlled it from something other than Tesla software. I have the Sense Energy monitor installed and I am in the process of installing my own solar system using Enphase Envoy to track the generation on a panel by panel basis, but the Sense will give the view of how much solar there is vs. how much draw there is. It would be grand if I could connect a TWC to my car to charge from the sun. But since I charge using the UMC I would be happy if I could just tell the car to start charging when there is too much extra solar energy and cut it off when there isn't enough extra.

Just not sure how I am going to do it.
 
  • Like
Reactions: ai4px

davewill

Active Member
Feb 5, 2014
1,828
1,983
San Diego, CA, US
... My question is, has anyone used this and controlled it from something other than Tesla software. I have the Sense Energy monitor installed and I am in the process of installing my own solar system using Enphase Envoy to track the generation on a panel by panel basis, but the Sense will give the view of how much solar there is vs. how much draw there is. It would be grand if I could connect a TWC to my car to charge from the sun. But since I charge using the UMC I would be happy if I could just tell the car to start charging when there is too much extra solar energy and cut it off when there isn't enough extra.

Just not sure how I am going to do it.

You could start here for controlling the car: Tesla API

It would be much simpler than the project in this thread, since you don't have to make any HW connections, just write software. It could run on a PC, or on something like the Raspberry Pi. Any computer with a network connection.
 

Steffen75D

New Member
Jul 13, 2019
3
0
Germany
All was working fine for weeks but recently I got a problem, not really related to the script but more to the serial-to-usb driver it seems:

Code:
[18830.252081] usb 1-1: USB disconnect, device number 3
[18830.252457] ftdi_sio ttyUSB1: error from flowcontrol urb
[18830.252930] ftdi_sio ttyUSB1: FTDI USB Serial Device converter now disconnected from ttyUSB1
[18830.253007] ftdi_sio 1-1:1.0: device disconnected
[18830.451813] Indeed it is in host mode hprt0 = 00021501
[18830.651727] usb 1-1: new full-speed USB device number 4 using dwc_otg
[18830.651963] Indeed it is in host mode hprt0 = 00021501
[18830.887408] usb 1-1: New USB device found, idVendor=0403, idProduct=6001
[18830.887426] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[18830.887433] usb 1-1: Product: USB-RS485 Cable
[18830.887440] usb 1-1: Manufacturer: FTDI
[18830.887446] usb 1-1: SerialNumber: FT2FZ7WG
[18830.909034] ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
[18830.909237] usb 1-1: Detected FT232RL
[18830.909847] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0

Of course the script crashes after this. Is it a faulty hardware or a cable broken or what am I suppost to do now?



I recommend a professional RS485 interface.
For example, this one.

Raspberry Pi RS422 RS485 Shield

Easy to set up and it works perfectly.
But it doesn't fit into the TWC.
 

UlrA

Member
Mar 6, 2016
120
227
Belgium / Ciney
You could start here for controlling the car: Tesla API

It would be much simpler than the project in this thread, since you don't have to make any HW connections, just write software. It could run on a PC, or on something like the Raspberry Pi. Any computer with a network connection.

Tesla API don't allow the AMP control , TBC
 

Hyperdrive

New Member
Jul 30, 2019
3
0
Australia
I am new to all this. I have been trying to keep up, but I keep getting stymied by all the code examples. My understanding after trying to re-read this thread is that it started with reverse-engineering the communications between a slave and a master TWC and then @CDragon released software that communicates with a Tesla Powerwall and then uses this protocol to change the charge rate of the TWC to reflect the amount of solar energy being generated. I have seen the video showing its use:


My question is, has anyone used this and controlled it from something other than Tesla software. I have the Sense Energy monitor installed and I am in the process of installing my own solar system using Enphase Envoy to track the generation on a panel by panel basis, but the Sense will give the view of how much solar there is vs. how much draw there is. It would be grand if I could connect a TWC to my car to charge from the sun. But since I charge using the UMC I would be happy if I could just tell the car to start charging when there is too much extra solar energy and cut it off when there isn't enough extra.

Just not sure how I am going to do it.


Hi, Yes i've used the Pi interface to the wall charger to intergrate with my solar generation.

The easiest way to do it is to have an intermediate script that publishes a file to an internal web server.

The tmc software is written to ask for a file from a web server and i just simulated what it wanted to with the interface script that uses data from the solar generation. Use your parameters on when there's spare power to charge the car.

Works really well and i also use it's off peak feature should i need some extra range for the next day above what
the sun could provide..
 

Hyperdrive

New Member
Jul 30, 2019
3
0
Australia
Hi Everyone,

Has anyone else witnessed some strange behavior on their car with using the pi TMC interface to the wall charger since the 2019.24.4 update ?

Was working perfectly prior.

Today the web interface was reporting 18a available and charging at 17.3 ish (normal) but the car was only accepting 11a / 18a and showed this on the car and the app.

Then later when it was supposed to shutdown from end of sufficient sunshine, it instead just reduced to 5a and kept charging.

Thanks
 

Hyperdrive

New Member
Jul 30, 2019
3
0
Australia
Hi Everyone,

Has anyone else witnessed some strange behavior on their car with using the pi TMC interface to the wall charger since the 2019.24.4 update ?

Was working perfectly prior.

Today the web interface was reporting 18a available and charging at 17.3 ish (normal) but the car was only accepting 11a / 18a and showed this on the car and the app.

Then later when it was supposed to shutdown from end of sufficient sunshine, it instead just reduced to 5a and kept charging.

Thanks

Further investigation showed it did the same thing with the UMC and it's only my car so it's nothing to do with TMCManager - incident logged with Tesla.
 

GreyS

Member
Aug 2, 2019
8
8
UK
Hi, I have TWCManager running with the modified code from SparkyPete to link it with my Powerwall. One thing I would like to change is for the scheduled charging time, I need to have 30 minute increments and not just hours. The reason being that we have an EV electricity tariff from Octopus and their low cost period is from 00:30 to 04:30. At the moment I can only select 00:00 or 01:00 as the start time for example. I'm not a coding expert so can anyone advise which lines to modify? I'm happy making the edits but I can't work out how to modify this myself.
 

GreyS

Member
Aug 2, 2019
8
8
UK
@CDragon sorry I should have started off my post above by saying a big thank you for the code and instructions you provided, super clear! Thanks also to SparkyPete
 

hcsharp

Active Member
Jun 7, 2011
3,412
1,440
Vermont
Rasp with linux, python and lots of interfacing.

Why not just use a Arduino with a RS485 shield ... am i missing something?
That's essentially what I did. I just programmed a uc with a tiny RS 485 chip hanging off of it. Then you don't have to worry about the vampire drain of the rasp, or whether there's enough power coming from the TWC power supply, or whether it will fit. There are some advantages to the rasp but not enough to be worth it IMO.
 

ai4px

Wes
May 2, 2018
455
484
Sumter SC USA
Question... this raspberry PI loadsharing thing.... it emulates the master and tells the slave unit how much current it can draw. What if there’s more than one HPWC? I’m thinking of an application where my solar system would control two HPWCs... the load share would depend on how many cars were plugged in. Anyone tried this?
 

[email protected]

Family, Racing, Karting, MTBing
Sep 25, 2013
918
226
Enschede, NL
Question... this raspberry PI loadsharing thing.... it emulates the master and tells the slave unit how much current it can draw. What if there’s more than one HPWC? I’m thinking of an application where my solar system would control two HPWCs... the load share would depend on how many cars were plugged in. Anyone tried this?
Just finished home install with 2 TWCs on a Pi with TWCManager. Seems to work great. I used Nicer82s fork as I am not looking at solar but at house load and not maxing out my main fuse.

I will report my changes here later and post some pictures.
 
  • Like
Reactions: ai4px

ai4px

Wes
May 2, 2018
455
484
Sumter SC USA
Just finished home install with 2 TWCs on a Pi with TWCManager. Seems to work great. I used Nicer82s fork as I am not looking at solar but at house load and not maxing out my main fuse.

I will report my changes here later and post some pictures.

I’m a total newb at raspberry. Years ago, I programmed PIC 16f84’s for another hobby.... so what do I need to get started? Can you advise me? Point to a tutorial? Where I’m headed: I have SMA Sunny Island inverters which use frequency shift and a Solar Edge inverter that doesn’t taper power output with frequency shift.... what I’m hoping is a raspberry that will 1)glue the SI to the Solar edge by probing the SI serially to find out how much current is needed and commanding SE. 2)provide a website accessible from an iPad or other device to display system status, and 3)actively control load shedding by interlocking the HVAC and controlling the charge current permitted by the Tesla HPWC. Lots of moving parts.... It may end up that I split these tasks into two or three raspberries.
 

Juanmax

Member
Sep 30, 2014
54
1
Germany
I installed all the stuff and the script runs basically well, many thanks @CDragon for your hard work!

Nevertheless, the "trackgreenenergy" part crashes every day or two, prompting the following lines:

--------------------------

14:49:39: SHB 4112: 00 00.00/00.00A 0000 0000 M: 09 00.00/06.00A 0000 0000
{"Id":"cc8dcff0-92a9-4ef3-980a-736f5d5e6b91","Name":"Solarinput","Serial":XXXXXX,"DeviceEnergyType":1,"FamilyType":1,"ActivePower":-0.35355000000000003,"ActivePowerUnit":"kW","CounterReading":-513.953,"CounterReadingUnit":"kWh","CounterReadingT1":-513.953,"CounterReadingImport":-513.953,"SwitchOn":true,"Voltage":234.5,"VoltageL1":234.5,"Current":-1.512,"PowerFactor":0.998,"PowerFactorL1":0.998,"Temperature":16.95,"ValueDate":"2019-03-16T13:48:55.0197151Z"}
14:49:41: Solar generating 353W so limit car charging to:

6.47A + 0.00A = 6.47A. Charge when above 6A (minAmpsPerTWC).

Exception in thread Thread-1:

Traceback (most recent call last):

File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner

self.run()

File "/usr/lib/python3.5/threading.py", line 862, in run

self._target(*self._args, **self._kwargs)

File "/home/pi/TWC/TWCManager.py", line 1246, in background_tasks_thread

check_green_energy()

File "/home/pi/TWC/TWCManager.py", line 1296, in check_green_energy

parsedJson = json.loads(jsonStr)

File "/usr/lib/python3.5/json/__init__.py", line 319, in loads

return _default_decoder.decode(s)

File "/usr/lib/python3.5/json/decoder.py", line 339, in decode

obj, end = self.raw_decode(s, idx=_w(s, 0).end())

File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode

raise JSONDecodeError("Expecting value", s, err.value) from None

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

14:59:39: SHB 4112: 00 00.00/00.00A 0000 0000 M: 09 00.00/06.00A 0000 0000
15:02:59: Web query: 'b'getStatus'', id 1027, time 1552744979, type 2
15:09:40: SHB 4112: 00 00.00/00.00A 0000 0000 M: 09 00.00/06.00A 0000 0000
15:19:41: SHB 4112: 00 00.00/00.00A 0000 0000 M: 09 00.00/06.00A 0000 0000
15:20:39: Web query: 'b'getStatus'', id 41052, time 1552746039, type 2
15:29:42: SHB 4112: 00 00.00/00.00A 0000 0000 M: 09 00.00/06.00A 0000 0000

---------------------------

So at time 14:49:39 was the last successful interrogation of my smart-meter, and then an error encountered. As I'm no IT-crack at all, I'd like to ask you guys out there if you have any clue what's the issue there??
Once this occured, the scipt keeps basically running, but without the "trackgreenenergy" part. It is not recommiting without restarting the script.

Cheers Chris :)

You may need to cover the GreenEnergyTracking line with a try: except: statement
Something like
try:
here comes the line that may give some errors
except:
print("GreenEnergyTracking exception catched")
 

Juanmax

Member
Sep 30, 2014
54
1
Germany
since i have two Tesla Wall Connector installed i found a bug in the code which is responsible to display the TWC on the website (index.php):

i changed three lines (342,343,345) in the code and now it displays the correct values when more than one TWC is connected.
sorry for the pictures. was not able to copy&paste as text right now

Hi Marlan,

I do have as well two TWC and I am still having the same issue as you, both appear with the same name. I wanted to fix it in the code you posted, but I can not find the lines. I installed everything two weeks ago, so maybe @CDragon though he fixed it and change the code but the error is still there?
 

Juanmax

Member
Sep 30, 2014
54
1
Germany
Hi Marlan,

I do have as well two TWC and I am still having the same issue as you, both appear with the same name. I wanted to fix it in the code you posted, but I can not find the lines. I installed everything two weeks ago, so maybe @CDragon though he fixed it and change the code but the error is still there?
Hi, I found the location in the file. I was looking at the wrong file :confused: (it is in /HTML/index.php)
 

Products we're discussing on TMC...

About Us

Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.

Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


SUPPORT TMC
Top