Community
OpenEnergyMonitor

Community

[solved]MQTT Data not shown


(Hans) #1

I use the example from https://github.com/mattjgalloway/openenergymonitor-emonhub/blob/emon-pi/examples/control_sender.py
In this post I found the structure for the data:
As MQTT topic is documented as :
[basetopic]/[node]/[keyname] i use
emon is the base topic (found in the docu)

Whats about node and keyname? Must they defined in emonhub.conf like:

[nodes]
[[12]]
nodename = MQTT1
hardware = MQTT1
[[[rx]]]
names = M1
datacode = 0
scales = 1
units = C

?

For this usage the python code should be:

client = mqtt.Client(“P1”)
client.connect(“127.0.0.1”, 1883, 60)
client.loop_start()

topic = “emon/12/M1”
payload = “1,1850”
client.publish(topic, payload=payload, qos=0, retain=False)
client.loop()
But there is no data shown in Input as well as no data arrived in the log:
[email protected]:~ $ tail -f /var/log/emonhub/emonhub.log
2018-12-29 10:26:16,763 DEBUG SerialDirect 128 Sent to channel(end)’ : ToEmonCMS
2018-12-29 10:26:16,954 DEBUG MQTT Publishing: emon/RPICT4T4/WP_L1 99.88
2018-12-29 10:26:16,957 DEBUG MQTT Publishing: emon/RPICT4T4/WP_L2 47.21
2018-12-29 10:26:16,959 DEBUG MQTT Publishing: emon/RPICT4T4/WP_L3 59.5
2018-12-29 10:26:16,960 DEBUG MQTT Publishing: emon/RPICT4T4/SERVER 165.58
2018-12-29 10:26:16,962 DEBUG MQTT Publishing: emon/RPICT4T4/MI-FBH-VL 30.81
2018-12-29 10:26:16,964 DEBUG MQTT Publishing: emon/RPICT4T4/AUSSEN-W -0.31
2018-12-29 10:26:16,967 DEBUG MQTT Publishing: emon/RPICT4T4/INNEN-WZ 22.87
2018-12-29 10:26:16,969 DEBUG MQTT Publishing: emon/RPICT4T4/WP-VL 41.69
2018-12-29 10:26:16,971 INFO MQTT Publishing: emonhub/rx/11/values 99.88,47.21,59.5,165.58,30.81,-0.31,22.87,41.69
2018-12-29 10:26:21,823 DEBUG SerialDirect 129 NEW FRAME : 11 99.40 46.65 54.77 166.58 30.81 -0.31 22.87 41.69
2018-12-29 10:26:21,825 DEBUG SerialDirect 129 Timestamp : 1546079181.82
2018-12-29 10:26:21,826 DEBUG SerialDirect 129 From Node : 11
2018-12-29 10:26:21,827 DEBUG SerialDirect 129 Values : [99.4, 46.65, 54.77, 166.58, 30.81, -0.31, 22.87, 41.69]
2018-12-29 10:26:21,828 DEBUG SerialDirect 129 Sent to channel(start)’ : ToEmonCMS
2018-12-29 10:26:21,829 DEBUG SerialDirect 129 Sent to channel(end)’ : ToEmonCMS

MQTT is running, password set in emonhub.conf. I have no idea how to publish my data. Please, can someone send the necessary, missing line of code?

The log of mqtt has:

('log: ', u"Received PUBLISH (d0, q0, r0, m0), ‘emon/12/M1’, … (6 bytes)")
('log: ', “Sending PUBLISH (d0, q0, r0, m45), ‘emon/12/M1’, … (6 bytes)”)
('log: ', u"Received PUBLISH (d0, q0, r0, m0), ‘emon/12/M1’, … (6 bytes)")
('log: ', “Sending SUBSCRIBE (d0, m46) [(‘emon/12/M1’, 0)]”)
('log: ', “Sending PUBLISH (d0, q0, r0, m47), ‘emon/12/M1’, … (6 bytes)”)('log: ', ‘Received SUBACK’)


(Hans) #2

There is no entry in emonhub.conf needed

The mentioned example does not work with emonCMS V9. You need authentifaction.

A python script could be like the enclosed one. Good Luck.mqtt_test.py.txt (600 Bytes)