Comments (5)
would like to send the information to my local broker,
pms mqtt --help
Usage: pms mqtt [OPTIONS]
Read sensor and push PM measurements to a MQTT server
Options:
-t, --topic TEXT mqtt root/topic [default: homie/test]
--mqtt-host TEXT mqtt server [default: mqtt.eclipse.org]
--mqtt-port INTEGER server port [default: 1883]
--mqtt-user TEXT server username [env var: MQTT_USER]
--mqtt-pass TEXT server password [env var: MQTT_PASS]
--help Show this message and exit.
Looks like you need to set the --mqtt-host
option.
Try with --mqtt-host YOUR_BROKER_HOST_NAME.local
or the IP of your local broker.
I read a PMSA003
sensor from within a container, and send the measurement to a local mosquitto server (on a different container).
I provide the mqtt username and password trough environment variables MQTT_USER
and MQTT_PASS
,
which I keep on an .env
file.
There is the command line with environment variables would be
export MQTT_USER=mqttuser MQTT_PASS=mqttpassword
pms --sensor-model PMSx003 --serial-port /dev/ttyUSB0 --interval 60 \
mqtt --topic air_quality/livingroom --mqtt-host mosquitto
Or provide the username and password from the command line
pms --sensor-model PMSx003 --serial-port /dev/ttyUSB0 --interval 60 \
mqtt --topic air_quality/livingroom --mqtt-host mosquitto \
--mqtt-user mqttuser --mqtt-pass mqttpassword
from pypms.
Thanks! I just wrote pms mqtt, and I have got a lot of error, so I thought the command is not good...
pms mqtt
Traceback (most recent call last):
File "/usr/local/bin/pms", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/typer/main.py", line 214, in __call__
return get_command(self)(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/typer/main.py", line 497, in wrapper
return callback(**use_params) # type: ignore
File "/usr/local/lib/python3.7/site-packages/pms/service/mqtt.py", line 140, in mqtt
pub = client_pub(topic=topic, host=host, port=port, username=user, password=word)
File "/usr/local/lib/python3.7/site-packages/pms/service/mqtt.py", line 50, in client_pub
c.connect(host, port, 60)
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 941, in connect
return self.reconnect()
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1075, in reconnect
sock = self._create_socket_connection()
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3546, in _create_socket_connection
return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
File "/usr/local/lib/python3.7/socket.py", line 727, in create_connection
raise err
File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
But With --help it is fine! Now I know how to use it ;).
I hope there will be no more questions.
Thanks again
from pypms.
looks like the default --mqtt-host
(mqtt.eclipse.org
) is currently down.
Can you try with test.mosquitto.org?
pms --debug mqtt --mqtt-host test.mosquitto.org
DEBUG:pms:capture ? PMSx003 obs from /dev/ttyUSB0 every 60 secs
DEBUG:pms:Sending CONNECT (u0, p0, wr1, wq1, wf1, c1, k60) client_id=b'homie/test'
DEBUG:pms:open /dev/ttyUSB0
DEBUG:pms:wake PMSx003
DEBUG:pms:Received CONNACK (0, 0)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m1), 'b'homie/test/$online'', ... (4 bytes)
DEBUG:pms:Received PUBACK (Mid: 1)
DEBUG:pms:buffer length: 40
DEBUG:pms:message hex: 424d001c000200140044000200140044000000000000000000000000970001f6424d0004e1000174
DEBUG:pms:message hex: 424d0004e1000174
DEBUG:pms:message payload: (57600,)
DEBUG:pms:message hex: 424d001c000000000000000000000000000000000000000000000000000000ab
DEBUG:pms:message empty: warming up sensor
DEBUG:pms:message hex: 424d001c0004000d00120004000d001200000000000000000000000097000188
DEBUG:pms:message payload: (4, 13, 18, 4, 13, 18, 0, 0, 0, 0, 0, 0, 38656)
DEBUG:pms:inconsistent obs: PM10=18 and N0.3=0.0
DEBUG:pms:message hex: 424d001c000600110013000600110013044401640066002200000000970002cb
DEBUG:pms:message payload: (6, 17, 19, 6, 17, 19, 1092, 356, 102, 34, 0, 0, 38656)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m2), 'b'homie/test/pm01/$type'', ... (3 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m3), 'b'homie/test/pm01/$properties'', ... (25 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m4), 'b'homie/test/pm01/sensor'', ... (7 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m5), 'b'homie/test/pm01/unit'', ... (6 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m6), 'b'homie/test/pm01/concentration'', ... (1 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m7), 'b'homie/test/pm25/$type'', ... (5 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m8), 'b'homie/test/pm25/$properties'', ... (25 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m9), 'b'homie/test/pm25/sensor'', ... (7 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m10), 'b'homie/test/pm25/unit'', ... (6 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m11), 'b'homie/test/pm25/concentration'', ... (2 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m12), 'b'homie/test/pm10/$type'', ... (4 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m13), 'b'homie/test/pm10/$properties'', ... (25 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m14), 'b'homie/test/pm10/sensor'', ... (7 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m15), 'b'homie/test/pm10/unit'', ... (6 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m16), 'b'homie/test/pm10/concentration'', ... (2 bytes)
DEBUG:pms:message hex: 424d001c000600110013000600110013044401640066002200000000970002cb
DEBUG:pms:message payload: (6, 17, 19, 6, 17, 19, 1092, 356, 102, 34, 0, 0, 38656)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m17), 'b'homie/test/pm01/concentration'', ... (1 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m18), 'b'homie/test/pm25/concentration'', ... (2 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m19), 'b'homie/test/pm10/concentration'', ... (2 bytes)
DEBUG:pms:Received PUBACK (Mid: 2)
DEBUG:pms:Received PUBACK (Mid: 3)
DEBUG:pms:Received PUBACK (Mid: 4)
DEBUG:pms:Received PUBACK (Mid: 5)
DEBUG:pms:Received PUBACK (Mid: 6)
DEBUG:pms:Received PUBACK (Mid: 7)
DEBUG:pms:Received PUBACK (Mid: 8)
DEBUG:pms:Received PUBACK (Mid: 9)
DEBUG:pms:Received PUBACK (Mid: 10)
DEBUG:pms:Received PUBACK (Mid: 11)
DEBUG:pms:Received PUBACK (Mid: 12)
DEBUG:pms:Received PUBACK (Mid: 13)
DEBUG:pms:Received PUBACK (Mid: 14)
DEBUG:pms:Received PUBACK (Mid: 15)
DEBUG:pms:Received PUBACK (Mid: 16)
DEBUG:pms:Received PUBACK (Mid: 17)
DEBUG:pms:Received PUBACK (Mid: 18)
DEBUG:pms:Received PUBACK (Mid: 19)
If this still does not work, I would need a bit more info on tour setup.
Which versions do you have installed? I have pms 0.5.0
and paho.mqtt 1.5.1
from pypms.
With my local broker it looks good:
pms -m PMS5003T -i 20 -s /dev/ttyAMA0 --debug mqtt --topic domoticz/out --mqtt-host 127.0.0.1
DEBUG:pms:capture ? PMS5003T obs from /dev/ttyAMA0 every 20 secs
DEBUG:pms:Sending CONNECT (u0, p0, wr1, wq1, wf1, c1, k60) client_id=b'domoticz/out'
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake PMS5003T
DEBUG:pms:Received CONNACK (0, 0)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m1), 'b'domoticz/out/$online'', ... (4 bytes)
DEBUG:pms:Received PUBACK (Mid: 1)
DEBUG:pms:buffer length: 40
DEBUG:pms:message hex: 424d001c0008000f001f0008000f001f000000000000000000d900df9a000369424d0004e1000174
DEBUG:pms:message hex: 424d0004e1000174
DEBUG:pms:message payload: (57600,)
DEBUG:pms:message hex:
DEBUG:pms:message header: b''
DEBUG:pms:message hex: 424d001c0014002000290014001f0029000000000000000000d900e19a0003b8
DEBUG:pms:message payload: (20, 32, 41, 20, 31, 41, 0, 0, 0, 0, 217, 225, 39424)
DEBUG:pms:inconsistent obs: PM10=41 and N0.3=0.0
DEBUG:pms:message hex: 424d001c0017002500290016002100290eca045e010a001200d900e39a00051d
DEBUG:pms:message payload: (23, 37, 41, 22, 33, 41, 3786, 1118, 266, 18, 217, 227, 39424)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m2), 'b'domoticz/out/pm01/$type'', ... (3 bytes)
DEBUG:pms:Received PUBACK (Mid: 2)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m3), 'b'domoticz/out/pm01/$properties'', ... (25 bytes)
DEBUG:pms:Received PUBACK (Mid: 3)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m4), 'b'domoticz/out/pm01/sensor'', ... (8 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m5), 'b'domoticz/out/pm01/unit'', ... (6 bytes)
DEBUG:pms:Received PUBACK (Mid: 4)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m6), 'b'domoticz/out/pm01/concentration'', ... (2 bytes)
DEBUG:pms:Received PUBACK (Mid: 5)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m7), 'b'domoticz/out/pm25/$type'', ... (5 bytes)
DEBUG:pms:Received PUBACK (Mid: 6)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m8), 'b'domoticz/out/pm25/$properties'', ... (25 bytes)
DEBUG:pms:Received PUBACK (Mid: 7)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m9), 'b'domoticz/out/pm25/sensor'', ... (8 bytes)
DEBUG:pms:Received PUBACK (Mid: 8)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m10), 'b'domoticz/out/pm25/unit'', ... (6 bytes)
DEBUG:pms:Received PUBACK (Mid: 9)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m11), 'b'domoticz/out/pm25/concentration'', ... (2 bytes)
DEBUG:pms:Received PUBACK (Mid: 10)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m12), 'b'domoticz/out/pm10/$type'', ... (4 bytes)
DEBUG:pms:Received PUBACK (Mid: 11)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m13), 'b'domoticz/out/pm10/$properties'', ... (25 bytes)
DEBUG:pms:Received PUBACK (Mid: 12)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m14), 'b'domoticz/out/pm10/sensor'', ... (8 bytes)
DEBUG:pms:Received PUBACK (Mid: 13)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m15), 'b'domoticz/out/pm10/unit'', ... (6 bytes)
DEBUG:pms:Received PUBACK (Mid: 14)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m16), 'b'domoticz/out/pm10/concentration'', ... (2 bytes)
DEBUG:pms:Received PUBACK (Mid: 15)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m17), 'b'domoticz/out/temp/$type'', ... (11 bytes)
DEBUG:pms:Received PUBACK (Mid: 16)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m18), 'b'domoticz/out/temp/$properties'', ... (19 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m19), 'b'domoticz/out/temp/sensor'', ... (8 bytes)
DEBUG:pms:Received PUBACK (Mid: 17)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m20), 'b'domoticz/out/temp/unit'', ... (3 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m21), 'b'domoticz/out/temp/degrees'', ... (4 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m22), 'b'domoticz/out/rhum/$type'', ... (17 bytes)
DEBUG:pms:Received PUBACK (Mid: 18)
DEBUG:pms:Received PUBACK (Mid: 19)
DEBUG:pms:Received PUBACK (Mid: 20)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m23), 'b'domoticz/out/rhum/$properties'', ... (22 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m24), 'b'domoticz/out/rhum/sensor'', ... (8 bytes)
DEBUG:pms:Received PUBACK (Mid: 21)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m25), 'b'domoticz/out/rhum/unit'', ... (1 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m26), 'b'domoticz/out/rhum/percentage'', ... (4 bytes)
DEBUG:pms:Received PUBACK (Mid: 22)
DEBUG:pms:Received PUBACK (Mid: 23)
DEBUG:pms:Received PUBACK (Mid: 24)
DEBUG:pms:Received PUBACK (Mid: 25)
DEBUG:pms:message hex: 424d001c0017002500290016002100290eca045e010a001200d900e39a00051d
DEBUG:pms:message payload: (23, 37, 41, 22, 33, 41, 3786, 1118, 266, 18, 217, 227, 39424)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m27), 'b'domoticz/out/pm01/concentration'', ... (2 bytes)
DEBUG:pms:Received PUBACK (Mid: 26)
DEBUG:pms:Received PUBACK (Mid: 27)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m28), 'b'domoticz/out/pm25/concentration'', ... (2 bytes)
DEBUG:pms:Received PUBACK (Mid: 28)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m29), 'b'domoticz/out/pm10/concentration'', ... (2 bytes)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m30), 'b'domoticz/out/temp/degrees'', ... (4 bytes)
DEBUG:pms:Received PUBACK (Mid: 29)
DEBUG:pms:Sending PUBLISH (d0, q1, r1, m31), 'b'domoticz/out/rhum/percentage'', ... (4 bytes)
DEBUG:pms:Received PUBACK (Mid: 30)
DEBUG:pms:Received PUBACK (Mid: 31)
Now I don't know how can I have IDX, because in domoticz My sensors have it's own IDX number...
from pypms.
Now I don't know how can I have IDX, because in domoticz My sensors have it's own IDX number...
I do not know what would be required to make it work with domoticz
.
The mqtt messages loosely follow the homie convention
If you want domoticz
support, please open a new issue including the relevant information.
For example, you can provide an example on how the mqtt message should look like.
Also, you are most welcomed to submit a PR adding that functionality.
It looks like your original question was answered, so I'll close this issue.
from pypms.
Related Issues (20)
- Add to pypi HOT 2
- SDS198 wrong message header HOT 5
- List all possible reader attributes in the README HOT 7
- Add instructions on how to use this package within a script or application
- MCU680 obs.pres typo
- Consistent attribute names HOT 5
- pip3 module not found HOT 2
- PMS5003T not recognized HOT 10
- unreliably identifying the SPS30 sensor HOT 12
- Cannot read HPMA115C0 HOT 9
- logging.basicConfig() conflicts with use as a library HOT 1
- SPS30 to mosquitto socket error HOT 8
- pms: Command not found HOT 4
- RPi zero with SDS198 reboots after running command HOT 1
- Stop after a number of readings and "one-shot" mode HOT 1
- Broken travis environment
- capture and decode raw-data
- PMS5003T/PMS5003ST signed temperature
- PMS5003S/PMS5003ST HCHO unit/format HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pypms.