jblance/mpp-solar

multiple hidraw inverters

rene-dev opened this issue · 14 comments

I have 2 MPP 10k inverters, connected via hidraw.
according to udevadm info --name=/dev/hidraw0 --attribute-walk they dont have a unique serial number, so I cant use udev to distinguish them.
The only way of telling which inverter is which seems to be the serial number using the ID command.
Im using hassd_mqtt integration. What is the best way of handling multiple inverters?

Rene

are they connected with separate cables or in parallel?

one usb cable for each inverter, so 2 hidraw devices. Probably best way is if mpp-solar queries the serial number on each hidraw device, and looks up the device name via serial in the config.

yeah auto determination is not implmented - it has been asked for
best bet is udev on physical path for the usb port (or checking after a reboot for changes - as the hidraw device is only changed then)

I can probably do it if you give me a few hints where to start, and how you would like the config to look like.
should all hidraw ports be polled? can probably be limited by querying udev for the manufacturer name?

you can set up udev rules to create a symlink based on which physical port the cable goes to, then the mppsolar config is static and will always relate to the correct inverter
ie similar to https://unix.stackexchange.com/questions/443250/udev-rule-to-alias-device-depending-on-usb-port-number

I will try that as a workaround, thanks. But this is not a perfect solution, as some boards use hubs, which cause the location to be non deterministic.

as far as i understand even hubs enumerate the physical port the same each time

it doesnt like the symlink: 2023-12-13 00:06:22,152:ERROR:device:run_command@57: No communications port defined - unable to run command PS

(venv) solar@odroidc2:~/mpp$ mpp-solar -P pi17infini -p /dev/links -c PS -n rechts -o hassd_mqtt,screen -q homebemis --mqttuser pwr --mqttpass pwr -DI
2023-12-13 00:15:35,616:INFO:__init__:main@216: Solar Device Command Utility, version: 0.16.15, python version: 3.11.2
2023-12-13 00:15:35,616:DEBUG:mqttbrokerc:__init__@29: mqttbroker config: {'name': 'homebemis', 'port': 1883, 'user': 'pwr', 'pass': 'pwr'}
2023-12-13 00:15:35,617:DEBUG:__init__:main@251: MqttBroker name: homebemis, port: 1883, user: pwr
2023-12-13 00:15:35,617:DEBUG:__init__:main@253: udp port 5555
2023-12-13 00:15:35,618:DEBUG:__init__:main@255: Using Postgres None
2023-12-13 00:15:35,618:DEBUG:__init__:main@258: Using Mongo None with mppsolar
2023-12-13 00:15:35,618:INFO:__init__:main@359: Creating device "rechts" (type: "mppsolar") on port "/dev/links (porttype=None)" using protocol "pi17infini"
2023-12-13 00:15:35,624:DEBUG:__init__:main@363: device_class <class 'mppsolar.devices.mppsolar.mppsolar'>
2023-12-13 00:15:35,624:DEBUG:device:__init__@34: __init__ args ()
2023-12-13 00:15:35,625:DEBUG:device:__init__@35: __init__ kwargs {'name': 'rechts', 'port': '/dev/links', 'protocol': 'pi17infini', 'baud': 2400, 'porttype': None, 'mqtt_broker': <mppsolar.libs.mqttbrokerc.MqttBroker object at 0xffff8fbd4450>, 'udp_port': '5555', 'mongo_url': None, 'mongo_db': 'mppsolar'}
2023-12-13 00:15:35,625:DEBUG:__init__:get_protocol@13: Protocol pi17infini
2023-12-13 00:15:36,216:DEBUG:device:__init__@39: __init__ name rechts, port None, protocol PI17INFINI protocol handler
2023-12-13 00:15:36,217:DEBUG:__init__:main@408: Commands [(<mppsolar.devices.mppsolar.mppsolar object at 0xffff8f4336d0>, 'PS', 'PS', 'hassd_mqtt,screen', None, None)]
2023-12-13 00:15:36,217:INFO:__init__:main@413: Looping 1 commands
2023-12-13 00:15:36,217:INFO:__init__:main@423: Getting results from device: mppsolar device - name: rechts, port: None, protocol: PI17INFINI protocol handler for command: PS, tag: PS, outputs: hassd_mqtt,screen
2023-12-13 00:15:36,217:INFO:device:run_command@51: Running command PS
2023-12-13 00:15:36,218:ERROR:device:run_command@57: No communications port defined - unable to run command PS
2023-12-13 00:15:36,218:DEBUG:__init__:main@427: results: {'ERROR': ['No communications port defined - unable to run command PS', '']}
2023-12-13 00:15:36,218:INFO:__init__:get_output@40: attempting to create output processor: hassd_mqtt
2023-12-13 00:15:36,231:DEBUG:hassd_mqtt:__init__@18: __init__: kwargs {}
2023-12-13 00:15:36,232:INFO:__init__:get_output@40: attempting to create output processor: screen
2023-12-13 00:15:36,233:DEBUG:screen:__init__@15: processor.screen __init__ kwargs {}
2023-12-13 00:15:36,233:DEBUG:__init__:main@433: Using output filter: None
2023-12-13 00:15:36,234:INFO:hassd_mqtt:output@171: Using output processor: hassd_mqtt
2023-12-13 00:15:36,234:DEBUG:hassd_mqtt:output@172: kwargs {'data': {'ERROR': ['No communications port defined - unable to run command PS', '']}, 'tag': 'PS', 'name': 'rechts', 'mqtt_broker': <mppsolar.libs.mqttbrokerc.MqttBroker object at 0xffff8fbd4450>, 'udp_port': '5555', 'postgres_url': None, 'mongo_url': None, 'mongo_db': 'mppsolar', 'mqtt_topic': None, 'filter': None, 'excl_filter': None, 'keep_case': False}
2023-12-13 00:15:36,234:DEBUG:hassd_mqtt:build_msgs@21: kwargs {'data': {'ERROR': ['No communications port defined - unable to run command PS', '']}, 'tag': 'PS', 'name': 'rechts', 'mqtt_broker': <mppsolar.libs.mqttbrokerc.MqttBroker object at 0xffff8fbd4450>, 'udp_port': '5555', 'postgres_url': None, 'mongo_url': None, 'mongo_db': 'mppsolar', 'mqtt_topic': None, 'filter': None, 'excl_filter': None, 'keep_case': False}
2023-12-13 00:15:36,235:DEBUG:hassd_mqtt:output@186: hassd_mqtt.output config_msgs [{'topic': 'homeassistant/sensor/mpp_PS_error/config', 'payload': '{"name": "PS ERROR", "state_topic": "homeassistant/sensor/mpp_PS_error/state", "unique_id": "mpp_PS_error", "force_update": "true", "device": {"name": "rechts", "identifiers": ["rechts"], "model": "rechts", "manufacturer": "MPP-Solar"}}'}]
2023-12-13 00:15:36,235:DEBUG:hassd_mqtt:output@187: hassd_mqtt.output value_msgs [{'topic': 'homeassistant/sensor/mpp_PS_error/state', 'payload': 'No communications port defined - unable to run command PS'}]
2023-12-13 00:15:36,235:DEBUG:mqttbrokerc:publish@146: Publishing '{"name": "PS ERROR", "state_topic": "homeassistant/sensor/mpp_PS_error/state", "unique_id": "mpp_PS_error", "force_update": "true", "device": {"name": "rechts", "identifiers": ["rechts"], "model": "rechts", "manufacturer": "MPP-Solar"}}' to 'homeassistant/sensor/mpp_PS_error/config'
2023-12-13 00:15:36,235:DEBUG:mqttbrokerc:publish@152: Not connected, connecting
2023-12-13 00:15:36,235:DEBUG:mqttbrokerc:connect@88: Connecting to homebemis on port 1883
2023-12-13 00:15:36,236:INFO:mqttbrokerc:connect@92: Using mqtt authentication, username: pwr, password: ********
2023-12-13 00:15:36,248:DEBUG:mqttbrokerc:on_connect@64: MqttBroker connection returned result: 0 Connection successful
2023-12-13 00:15:38,749:DEBUG:mqttbrokerc:publish@146: Publishing 'No communications port defined - unable to run command PS' to 'homeassistant/sensor/mpp_PS_error/state'
2023-12-13 00:15:38,750:DEBUG:__init__:main@433: Using output filter: None
2023-12-13 00:15:38,751:INFO:screen:output@21: Using output processor: screen
2023-12-13 00:15:38,751:DEBUG:screen:output@22: kwargs {'data': {'ERROR': ['No communications port defined - unable to run command PS', '']}, 'tag': 'PS', 'name': 'rechts', 'mqtt_broker': <mppsolar.libs.mqttbrokerc.MqttBroker object at 0xffff8fbd4450>, 'udp_port': '5555', 'postgres_url': None, 'mongo_url': None, 'mongo_db': 'mppsolar', 'mqtt_topic': None, 'filter': None, 'excl_filter': None, 'keep_case': False}
2023-12-13 00:15:38,751:DEBUG:screen:output@74: displayData: {'error': ['No communications port defined - unable to run command PS', '']}
Command: Unknown command - No description found
--------------------------------------------------------------------------------
Parameter Value          	Unit
error     No communications port defined - unable to run command PS	    
--------------------------------------------------------------------------------


2023-12-13 00:15:38,752:DEBUG:__init__:main@458: Not daemon, so not looping

you'll need to add --porttype=hidraw to the command

Thanks, now its working! I can use this as a workaround.
I think there is still a bug somewhere, as it publishes the error to mqtt, and Im not sure this is intended.
image

Thanks, now its working! I can use this as a workaround. I think there is still a bug somewhere, as it publishes the error to mqtt, and Im not sure this is intended. image

yeah that is as designed currently