ksheumaker / homeassistant-apsystems_ecur

Home Assistant custom component for local querying of APSystems ECU-R Solar System
Apache License 2.0
166 stars 42 forks source link

Getting empty response from inverter query command #13

Closed tannercollin closed 3 years ago

tannercollin commented 3 years ago

Hi, I am receiving an empty response when I query the ECU's inverters when running query_ecu(). Here's the output with some data I've added:

ecu query: APS1100160001END

raw ecu data: b'APS120110000121620000510001\x00\x00\x05\x06\x00\x00\r\xe9\x00\x00\r\xfd\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\n10015ECU_R_PRO_2.0.0010US/Pacific\x80\x97\x1b\x02\xa1\xdc`\xc5\xa8y\xd1~00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00END\n'                                                                        
ecu id b'216200005100'
current power: 3561
Processing ECU data...
datalen: 110
checksum: 110
inverter data cmd: APS1100280002216200005100END

raw inverter data: b''
Processing inverter data...
datalen: -1
[ERROR] Error getting checksum int from 'Inverter data' data=b''
Sleeping for 60 sec

Sometimes I get "Connection reset by peer":

ecu query: APS1100160001END

raw ecu data: b'APS120110000121620000510001\x00\x00\x05\t\x00\x00\r\xa1\x00\x00\x0e\x1a\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\n10015ECU_R_PRO_2.0.0010US/Pacific\x80\x97\x1b\x02\xa1\xdc`\xc5\xa8y\xd1~00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00END\n'                                                                        
ecu id b'216200005100'
current power: 3489
Processing ECU data...
datalen: 110
checksum: 110
inverter data cmd: APS1100280002216200005100END

[ERROR] [Errno 104] Connection reset by peer
Sleeping for 60 sec

I'm also running APSystems-ECU-proxy-for-cloudless-operation and it believes that it has internet connection. I had to adjust the script a bit to get it working:

offset = 32
date_time_obj = datetime.strptime(str(rec)[offset:offset+14], '%Y%m%d%H%M%S') + timedelta(minutes=-5)                                          

It's sending messages like these every 3 seconds to ecu.apsema.com:

<< ECU: b'APS1300074A182AAA02162000051002021060317185900000000000000010US/PacificEND\n'                                                                        
>> ECU: 10120210603171359
<< ECU: b'APS1300074A182AAA02162000051002021060317190200000000000000010US/PacificEND\n'
>> ECU: 10120210603171402

Any idea what's wrong? Thanks!

tannercollin commented 3 years ago

Update:

If I skip the initial query command and go straight to the inverter query it seems to work:

inverter data cmd: APS1100280002216200005100END

raw inverter data: b'APS11023900020001\x00\n !\x06\x03\x18\x13\x08@\x90\x00\x197\x12\x0101\x02X\x00\x90\x00\x92\x00\xf2\x00\x94\x00\xf2@\x90\x00\x194\x99\x0101\x02X\x00\x97\x00\x8f\x00\xf3\x00\x8f\x00\xf3@\x90\x00\x19@U\x0101\x02X\x00\x90\x00\x8f\x00\xf3\x00\x00\x00\xf3@\x90\x00\x19B\x05\x0101\x02X\x00\x91\x00\x8f\x00\xf2\x00\x8f\x00\xf2@\x90\x00\x19@d\x0101\x02X\x00\x97\x00\x8d\x00\xf3\x00\x8e\x00\xf3@\x90\x00\x10b\x06\x0101\x02X\x00\x97\x00\x91\x00\xf2\x00\x8e\x00\xf2@\x90\x00\x10I\x85\x0101\x02X\x00\x91\x00\x8e\x00\xf3\x00\x8f\x00\xf3@\x90\x00\x10a\x89\x0101\x02X\x00\x95\x00\x91\x00\xf3\x00\x8f\x00\xf3@\x90\x00\x10\x91w\x0101\x02X\x00\x8f\x00\x93\x00\xf2\x00\x90\x00\xf2@\x90\x00\x10\x91y\x0101\x02X\x00\x93\x00\x94\x00\xf2\x00\x91\x00\xf2END\n'

If I close and open the socket before each query, everything seems fine.