dracoventions / TWCManager

Control power delivered by a Tesla Wall Charger using two wires screwed into its RS-485 terminals.
The Unlicense
182 stars 110 forks source link

Export charging status to other program #19

Open blooby78 opened 4 years ago

blooby78 commented 4 years ago

Hello,

Thanks for your project it work's perfect. I would like to know how simpli get the status off power delivery (not charging/ incharge with x amp / error ...) You use IPC but the anwswer is direcly provide to php who is interpreted. I would like to use bash or python program to get this status. Do you have a suggestion ? Thanks Jerome

juamiso commented 4 years ago

I am using curl and python request lib to communicate with other systems (iobroker = home automation, and influxdb for nice graphs)

Maybe you can get some inspirations from this lines:

    # displaying download stats. -m 60 prevents the whole
    # operation from taking over 60 seconds.
    #greenEnergyData = run_process('curl -s -m 60 "http://192.168.13.58/history/export.csv?T=1&D=0&M=1&C$
    Photovoltaic = 0
    Smartmeter=0
    HouseBatt= 0
    url_string = 'http://<your_server>/write?db=<your_influx_db>'
    data_string = 'TWCMagager.CurrentChargingPower,from=TWCManager value=' + str(total_amps_actual_all_twcs()*225)
    myToken = '<your_influxdb_auth_token>' 
    header_string = {'Authorization': 'Bearer {}'.format(myToken)}
    ip='192.168.0.71' #This is the local ip from your inverter being connected via TCP Modbus
    client = ModbusClient(ip,port=502)
    client.connect()
    try:
      Photovoltaic = int(BinaryPayloadDecoder.fromRegisters(client.read_holding_registers(40092-1,2,unit$
      SmartMeter = int(BinaryPayloadDecoder.fromRegisters(client.read_holding_registers(40098-1,2,unit=2$
      HouseBatt = run_process('curl -s -m 5 "http://<local_iobroker_server_ip>/getPlainValue/vis.0.Batt_Discharge$
      req.post(url_string, data=data_string, headers=header_string)
ngardiner commented 4 years ago

You could take a look at my fork of this, which has modules to talk to multiple external interfaces including HomeAssistant and MQTT

https://github.com/ngardiner/TWCManager