joscha82 / wattpilot

Python library to connect to a Fronius Wattpilot Wallbox
MIT License
40 stars 10 forks source link

cci: how to change conected inverter (surplus) #14

Open thecem opened 2 years ago

thecem commented 2 years ago

For some reason fronius told me (intersolar) they will not provide an API Description. They were amazed that someone is able to use the API and WS. But anyway there are realy not using there one product since there is no idea to change the inverter from one wattpilot to the next if the car is on one of two or three wp full. they will bring a solution for loadsharing for up to three. Anyway, I would like to have a logic to switch the cci to the next wattpilot where is a car connected and after the car is full switch to the next one, which is connected and waiting for surplus. For a start we should have the possibility to change the cci parameter to the surplus inverter. Is there a solution to get the parameter for setting cci to the right one, since if the inverter is not set the web api don´t show anything (cci: null). Once the inverter is set, the parameter to move from on wp to the next are clear, but where get the app these values?

Could we integrate a solution to set the cci value(s) on mqtt? Maybe with a drop down to select inverter(s) ?

To change surplus from one to another wp decoupling and coupling (next wp to the surplus inverter) is nessesary.

joscha82 commented 2 years ago

cci seems to be read-only and does only contain the currently connected inverter. I have not seen a property which contains any/all available inverter nor a command send by the client to WP to couble/decouble the inverter. However, there are ClearInverters and UpdateInverters commands which are send by the WP to the WebSocket Client were i do not know which information or purpose these commands serve. This library currently receives these commands but does not store or process the received data (it simple ignores them at the moment). It might be possible that multiple UpdateInverters commands are send if multiple inverters are detected in the network and that the contained inverter ID is used to couble a inverter with an yet unknown command send by the client. It should be possible to reverse engineer / sniff this commands. Unfortunatly I have no network dump of traffic were i coubled/decoubled an inverter and have only one inverter at hand.

You have one inverter and multiple Wattpilots and want to couble/decouble the inverter to the currently "active" wattpilot dynamically to allow multiple cars to perform eco-charge? Alternatively you could also perform the surplus charge on your own by utilizing HA, reading the data of current load and producion from the inverter and then set the max load parameter on the wattpilots by using the existing mqtt commands. This would also allow to charge two times at the same time when enough surplus is available. (Or two cars with surplus/2).

thecem commented 2 years ago

Yes this is an alternative, but I would to let the active WP control the surplus charging. What for a dump do you need? I could trace the com between app and wp. I will try if I get more details how this works..

joscha82 commented 2 years ago

ah already found it. Fortunately i had my sniffer setup still working:

To pair with an inverter the client sends a Message of Type "pairInverter" to the Wattpilot with the serialnumber of the inverter to pair with as an parameter: {"type":"securedMsg","data":"{\"type\":\"pairInverter\",\"inverterId\":\"240.123456\",\"requestId\":\"2\"}","requestId":"2sm","hmac":"xxxxx"}

Same is done to decouble an inverter, This is done through a "unPairInverter" Command: {"type":"securedMsg","data":"{\"type\":\"unpairInverter\",\"inverterId\":\"240123456\",\"requestId\":\"1\"}","requestId":"1sm","hmac":"xxxxx"}

I assume the UpdateInverter Info from the Wattpilot is send multiple times if multiple inverters are detected.

How is the App reacting if you try to couble a inverter which is already coubled to another wattpilot? Is this inverter "greyed out" in the app or do you receive some kind of error? (Cannot thest this as i, unfortunatly only have one wattpilot and one inverter ;) )

joscha82 commented 2 years ago

I added an UpdateInvert pair|unapir command to the library and to the commandline shell and tested this on my device without problems so far.

inverter ID is the number shown in () in the app and normally in the form 123.456789. I have not added this as an mqtt/ha command yet as i am not deep into the mqtt implementation. Will look into this on the weekend eventually.

INFO:wattpilot.wattpilotshell:Automatically connecting to Wattpilot ...
INFO:wattpilot:Wattpilot None initilized
INFO:wattpilot:Wattpilot connected
INFO:wattpilot:Connected to WattPilot Serial 99999999
INFO:wattpilot:Authentication successful
Wattpilot: Wattpilot_999999999
Serial: 999999999
Connected: True
Car Connected: complete
Charge Status True
Mode: Default
Power: 16
Charge: 0.00kW ---- 232V/232V/231V -- 0.00A/0.00A/0.00A -- 0.00kW/0.00kW/0.00kW

Welcome to the Wattpilot Shell 0.2.   Type help or ? to list commands.

wattpilot> UpdateInverter unpair 240.123456
wattpilot> UpdateInverter pair 240.123456
wattpilot>
thecem commented 2 years ago

I tried to pair & unpair the WP´s. But this is crasy, with FW 36.3 (WP) it is reproducable to pair all WP´s to the GEN24. Question is how this will work, every WP get 1/2 or 1/3 surplus ?