Skip to content

Commit

Permalink
fix bug where node names not defined in emonhub.conf caused rssi to a…
Browse files Browse the repository at this point in the history
…dvance to all input names
  • Loading branch information
Trystan Lea committed Mar 1, 2018
1 parent 876cd95 commit 9263fc2
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/interfacers/EmonHubMqttInterfacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ def add(self, cargo):
f['data'] = cargo.realdata

if cargo.rssi:
f['names'].append('rssi')
f['data'].append(cargo.rssi)

f['rssi'] = cargo.rssi

# This basic QoS level 1 MQTT interfacer does not require buffering
# therefore we call _process_post here directly with an array
# containing only the one frame.
Expand Down Expand Up @@ -125,6 +124,18 @@ def _process_post(self, databuffer):
if result[0]==4:
self._log.info("Publishing error? returned 4")
return False

# send rssi
if 'rssi' in frame:
topic = self._settings["nodevar_format_basetopic"]+nodename+"/rssi"
payload = str(frame['rssi'])

self._log.debug("Publishing: "+topic+" "+payload)
result =self._mqttc.publish(topic, payload=payload, qos=2, retain=False)

if result[0]==4:
self._log.info("Publishing error? returned 4")
return False

# ----------------------------------------------------------
# Emoncms nodes module format: emonhub/rx/10/values ... 100,200,300
Expand All @@ -134,7 +145,10 @@ def _process_post(self, databuffer):
topic = self._settings["node_format_basetopic"]+"rx/"+str(nodeid)+"/values"

payload = ",".join(map(str,frame['data']))


if 'rssi' in frame:
payload = payload+","+str(frame['rssi'])

self._log.info("Publishing: "+topic+" "+payload)
result =self._mqttc.publish(topic, payload=payload, qos=2, retain=False)

Expand Down

0 comments on commit 9263fc2

Please sign in to comment.