modpoll will output directly to MQTT. Output to the emoncms MQTT Broker on thetopic emon/solar
and emoncms will pick it up directly.
I’ve removed the scales option - same error.
Tried setting them to 1 - same error.
Connection failed on read of register: 11000 : 'ModbusIOException' object has no attribute 'function_code'
modpoll will output directly to MQTT
Yep, the docs suggest it will, spent an hour trying and failed.
It runs in the foreground so I’d need something extra to keep it alive.
It’s a swamp of alligators in both directions!
So it’s not causing the error (I knew that) but left in there, it would have obscured the result when you did solve the original problem. And the default scales is 1.0, which explains why no scales = ...
and scales = 1.0, 1.0
showed the same.
This error message seems to suggest a 4-byte number (f
, L
or l
datacode) is expected.
Sorry, but I don’t think I can help much more.
No problem @Robert.Wall. I appreciate your time.
I’ll persevere.
What command were you using and what was the error?
A simple systemctl
service file will suffice for that (lots of howtos out there).
Hi Brian,
I’m using
modpoll --tcp 192.168.1.254 --config https://raw.githubusercontent.com/gavinying/modpoll/master/contrib/foxess/foxess.cfg --mqtt-host 127.0.0.1 --mqtt-topic-prefix emon --mqtt-user emonpi --mqtt-pass emonpimqtt2016
The config came from an example in the modpoll library specific to the Fox-ESS inverter I am messing with.
2023-10-23 17:57:58,524 | I | modpoll.main | Setup MQTT connection to 127.0.0.1
2023-10-23 17:57:58,528 | I | modpoll.modbus_task | Loading config from: https://raw.githubusercontent.com/gavinying/modpoll/master/contrib/foxess/foxess.cfg
2023-10-23 17:57:58,530 | I | modpoll.mqtt_task | Connection successful
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3591, in _thread_main
self.loop_forever(retry_first_connection=True)
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
rc = self._loop(timeout)
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1164, in _loop
rc = self.loop_read()
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1556, in loop_read
rc = self._packet_read()
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2439, in _packet_read
rc = self._packet_handle()
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3039, in _packet_handle
return self._handle_connack()
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3138, in _handle_connack
on_connect(
File "/home/pi/.local/lib/python3.9/site-packages/modpoll/mqtt_task.py", line 29, in _on_connect
client.subscribe(f"{args.mqtt_topic_prefix}+/set")
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1491, in subscribe
raise ValueError('Invalid subscription filter.')
ValueError: Invalid subscription filter.
Traceback (most recent call last):
File "/home/pi/.local/bin/modpoll", line 8, in <module>
sys.exit(app())
File "/home/pi/.local/lib/python3.9/site-packages/modpoll/main.py", line 63, in app
if not modbus_setup(args, event_exit):
File "/home/pi/.local/lib/python3.9/site-packages/modpoll/modbus_task.py", line 398, in modbus_setup
load_config(args.config)
File "/home/pi/.local/lib/python3.9/site-packages/modpoll/modbus_task.py", line 380, in load_config
parse_config(csv_reader)
File "/home/pi/.local/lib/python3.9/site-packages/modpoll/modbus_task.py", line 296, in parse_config
fc = row[1].lower()
IndexError: list index out of range
I think it relates to the top line device,foxess,1
. I think that value should be 247.
If I copy the config to the Pi and try to run like this
modpoll --tcp 192.168.1.254 --config foxess.cfg --mqtt-host 127.0.0.1 --mqtt-topic-prefix emon --mqtt-user emonpi --mqtt-pass emonpimqtt2016
I get an error requests.exceptions.MissingSchema: Invalid URL 'foxess.cfg': No scheme supplied. Perhaps you meant https://foxess.cfg?
So I think the config file needs to be hosted on a web server?
On main page,
I found this - Basic Usage — Modpoll 0.5.0 documentation - bit more documentation
This shows config flag as -f
. Also try providing the full path to the config file.
Get this working first before adding in MQTT I suggest.
For MQTT
Add a trailing /
Also, is this being run on the emonbase/emonPi?
modpoll --tcp 192.168.1.254 --config /home/pi/foxess.cfg --mqtt-host 127.0.0.1 --mqtt-topic-prefix emon/ --mqtt-user emonpi --mqtt-pass emonpimqtt2016
Results in
requests.exceptions.MissingSchema: Invalid URL '/home/pi/foxess.cfg': No scheme supplied. Perhaps you meant https:///home/pi/foxess.cfg?
I think there must be some prefix in the Python Requests package for something like file://
however I don’t see much in the docs for it.
Nevermind, I put the file in the emomcms web root and got past that error.
modpoll --tcp 192.168.1.254 --config http://localhost/foxess.cfg --mqtt-host 127.0.0.1 --mqtt-topic-prefix emon/ --mqtt-user emonpi --mqtt-pass emonpimqtt2016
Nothing appears in MQTT (Watching it with MQTT Explorer)
I’ll keep trying.
The general rule on debugging this is to start simple. So try using the config file and print to terminal. This proves the config file works.
It does say a ‘local path’ for the config file - the issue might be permissions.
note putting that config file in emoncms root will probably stop emoncms from updating as it will not expect that file there.
Go back to your original command, does that work? Can you use that instead of the config file? If so can you then send it to the MQTT Broker?
[edit]
Try as ‘sudo’