mpp-solar
mpp-solar copied to clipboard
jkbms remotesocket unable to connect
Environment:
- python 3.11
- venv (same as HomeAssistant)
- mpp-solar build from source, latest commit on branch master (but other versions same issue)
- BMS connected with JK RS485 adapter to USR-N540 device (but actually doesn!t matter, because of the error appears before communication)
`jkbms --porttype remotesocket -p 192.168.66.63:8801 -n BMS -D
\2023-04-23 23:04:28,483:INFO:__init__:main@214: Solar Device Command Utility, version: 0.15.50
2023-04-23 23:04:28,483:DEBUG:mqttbrokerc:__init__@29: mqttbroker config: {'name': 'localhost', 'port': 1883, 'user': None, 'pass': None}
2023-04-23 23:04:28,483:DEBUG:__init__:main@239: MqttBroker name: localhost, port: 1883, user: None
2023-04-23 23:04:28,483:DEBUG:__init__:main@241: udp port 5555
2023-04-23 23:04:28,483:DEBUG:__init__:main@243: Using Postgres None
2023-04-23 23:04:28,483:DEBUG:__init__:main@246: Using Mongo None with mppsolar
2023-04-23 23:04:28,483:INFO:__init__:main@347: Creating device "BMS" (type: "jkbms") on port "192.168.66.63:8801 (porttype=remotesocket)" using protocol "JK04"
2023-04-23 23:04:28,484:DEBUG:__init__:main@351: device_class <class 'mppsolar.devices.jkbms.jkbms'>
2023-04-23 23:04:28,484:DEBUG:device:__init__@33: __init__ args ()
2023-04-23 23:04:28,484:DEBUG:device:__init__@34: __init__ kwargs {'name': 'BMS', 'port': '192.168.66.63:8801', 'protocol': 'JK04', 'baud': 2400, 'porttype': 'remotesocket', 'mqtt_broker': <mppsolar.libs.mqttbrokerc.MqttBroker object at 0x7f63e0fe6610>, 'udp_port': '5555', 'mongo_url': None, 'mongo_db': 'mppsolar'}
2023-04-23 23:04:28,484:INFO:__init__:get_port@85: Port overide - using port 'remotesocket'
2023-04-23 23:04:28,484:DEBUG:__init__:get_port_type@64: port matches remotesocket
2023-04-23 23:04:28,484:INFO:__init__:get_port@139: Using remotesocketio for communications
2023-04-23 23:04:28,484:DEBUG:__init__:get_port@146: got ip: 192.168.66.63, port: 8801
2023-04-23 23:04:28,485:DEBUG:__init__:get_protocol@13: Protocol JK04
2023-04-23 23:04:28,486:DEBUG:device:__init__@38: __init__ name BMS, port <mppsolar.inout.remotesocketio.remoteSocketIO object at 0x7f63e0f8e4d0>, protocol JK04 - JKBMS BLE 4 byte data communication protocol handler
2023-04-23 23:04:28,486:DEBUG:__init__:main@402: Commands [(<mppsolar.devices.jkbms.jkbms object at 0x7f63e0f8ee50>, '', '', 'screen', None, None)]
2023-04-23 23:04:28,486:INFO:__init__:main@407: Looping 1 commands
2023-04-23 23:04:28,486:INFO:__init__:main@417: Getting results from device: jkbms device - name: BMS, port: <mppsolar.inout.remotesocketio.remoteSocketIO object at 0x7f63e0f8e4d0>, protocol: JK04 - JKBMS BLE 4 byte data communication protocol handler for command: , tag: , outputs: screen
2023-04-23 23:04:28,486:INFO:device:run_command@50: Running command
2023-04-23 23:04:28,486:INFO:jkabstractprotocol:get_full_command@74: Using protocol b'JK04' with 2 commands
2023-04-23 23:04:28,486:DEBUG:jkabstractprotocol:get_command_defn@105: get_command_defn for: getCellData
2023-04-23 23:04:28,486:DEBUG:abstractprotocol:get_command_defn@59: Processing command 'getCellData'
2023-04-23 23:04:28,486:DEBUG:abstractprotocol:get_command_defn@61: Found command getCellData in protocol b'JK04'
2023-04-23 23:04:28,486:DEBUG:jkabstractprotocol:get_full_command@79: self._command = getCellData
2023-04-23 23:04:28,486:DEBUG:jkabstractprotocol:get_full_command@90: cmd with SOR: bytearray(b'\xaaU\x90\xeb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2023-04-23 23:04:28,486:DEBUG:jkabstractprotocol:get_full_command@98: cmd with command code: bytearray(b'\xaaU\x90\xeb\x96\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2023-04-23 23:04:28,486:DEBUG:jkabstractprotocol:get_full_command@100: cmd with crc: bytearray(b'\xaaU\x90\xeb\x96\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10')
2023-04-23 23:04:28,486:INFO:device:run_command@78: full command bytearray(b'\xaaU\x90\xeb\x96\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10') for command getCellData
2023-04-23 23:04:28,486:DEBUG:jkabstractprotocol:get_command_defn@105: get_command_defn for: getCellData
2023-04-23 23:04:28,486:DEBUG:abstractprotocol:get_command_defn@59: Processing command 'getCellData'
2023-04-23 23:04:28,486:DEBUG:abstractprotocol:get_command_defn@61: Found command getCellData in protocol b'JK04'
2023-04-23 23:04:28,486:DEBUG:remotesocketio:send_and_receive@19: host ip: 192.168.66.63, host port: 8801
2023-04-23 23:04:28,486:WARNING:remotesocketio:send_and_receive@32: socket read error: 'str' object cannot be interpreted as an integer
2023-04-23 23:04:28,487:INFO:remotesocketio:send_and_receive@33: Command execution failed
2023-04-23 23:04:28,487:DEBUG:device:run_command@95: Send and Receive Response {'ERROR': ['Socket command execution failed', '']}
2023-04-23 23:04:28,487:INFO:abstractprotocol:decode@218: response passed to decode: {'ERROR': ['Socket command execution failed', '']}
2023-04-23 23:04:28,487:DEBUG:jkabstractprotocol:get_command_defn@105: get_command_defn for: getCellData
2023-04-23 23:04:28,487:DEBUG:abstractprotocol:get_command_defn@59: Processing command 'getCellData'
2023-04-23 23:04:28,487:DEBUG:abstractprotocol:get_command_defn@61: Found command getCellData in protocol b'JK04'
2023-04-23 23:04:28,487:INFO:abstractprotocol:decode@262: Processing response of type POSITIONAL
2023-04-23 23:04:28,487:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Str', 4, 'Header', '']
Traceback (most recent call last):
File "/var/lib/ha/bin/jkbms", line 8, in <module>
sys.exit(main())
^^^^^^
File "/var/lib/ha/lib/python3.11/site-packages/mppsolar/__init__.py", line 420, in main
results = _device.run_command(command=_command)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/ha/lib/python3.11/site-packages/mppsolar/devices/device.py", line 112, in run_command
decoded_response = self._protocol.decode(raw_response, command)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/ha/lib/python3.11/site-packages/mppsolar/protocols/abstractprotocol.py", line 265, in decode
responses = self.get_responses(response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/ha/lib/python3.11/site-packages/mppsolar/protocols/jkabstractprotocol.py", line 132, in get_responses
item = response[:size]
~~~~~~~~^^^^^^^
TypeError: unhashable type: 'slice'`
Am I doing something wrong?
Thanks.
need to use rs485 protocol with the command - the default protocol for jkbms is the ble protocol
try adding -P jk485 or -P jk232 (though these havent been fully tested yet)