SR-G / current-cost-forwarder

Forwards readings from a Current Cost ENVIR through a MQTT Broker
8 stars 0 forks source link

Not forwarding events to MQTT #2

Closed bergvoll closed 9 years ago

bergvoll commented 9 years ago

Hi.

I'm trying to get this to work on my ubuntu x86 installation. My CurrentCost device is actually connected to the same computer as I'm running both the MQTT broker and OpenHab on, but i guess that should be irrelevant (i could not find any other solution for using CurrentCost with OpenHab).

After startup, the current-cost-forwarder stops after this: 21:32:39.593 [main] INFO org.tensin.ccf.reader.CurrentCostReader - Starting CurrentCostForwarder reader thread on device [/dev/ttyUSB1] 21:32:39.596 [main] INFO org.tensin.ccf.CurrentCostForwarder - CurrentCostForwarder started in [508ms] 21:32:39.603 [THREAD-CURRENT-COST-FORWARDER-READER] INFO org.tensin.ccf.reader.CurrentCostReader - Now connected on specified device [/dev/ttyUSB1]

It never starts forwarding events to MQTT. If i start it with the debug flag, i can see that it actually receives data from my CurrentCost:

07:48:44.648 [main] INFO org.tensin.ccf.reader.CurrentCostReader - Starting CurrentCostForwarder reader thread on device [/dev/ttyUSB1] 07:48:44.649 [main] INFO org.tensin.ccf.CurrentCostForwarder - CurrentCostForwarder started in [500ms] 07:48:44.656 [THREAD-CURRENT-COST-FORWARDER-READER] INFO org.tensin.ccf.reader.CurrentCostReader - Now connected on specified device [/dev/ttyUSB1] 07:48:44.657 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Now starting acquisition from device 07:48:58.029 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.030 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.031 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.032 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.034 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.035 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.036 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.037 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.038 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.038 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.039 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.039 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.040 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device 07:48:58.041 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Just received some characters from device etc.

cat /dev/ttyUSB1 works ok:

CC128-v1.290101823.5003344101229

Any ideas of where it's failing?

-AB

Edit: Forgot to mention, the MQTT broker seems to work fine. I've tested it with mosquitto_sub and mosquitto_sub w/o any problems (no authentication). I also set --broker-url "tcp://localhost:1883" in current-cost-forwarder.sh.

SR-G commented 9 years ago

Hey. Based on your log, the problem is about what is read from the Current Cost device (/dev/ttyUSB1 in your case). Could you :

bergvoll commented 9 years ago

I can see now that my paste from cat /dev/ttyUSB1 didn't show up correctly. This is what it outputs: <msg><src>CC128-v1.29</src><dsb>01018</dsb><time>05:00:19</time><tmpr>24.7</tmpr><sensor>0</sensor><id>03344</id><type>1</type><ch1><watts>01897</watts></ch1></msg>

Debug-mode now shows this: http://pastebin.com/Qy10NNJc

Guess the output is not the same as with your current cost device? This is what my unit looks like: http://www.frequencycast.co.uk/images/currentcost02.jpg

edit: new output to pastebin

SR-G commented 9 years ago

I think my device may be one generation older (but overall looks quite similar).

Based on your log, it seems that your model doesn't send at all the character that i use to split each message (character 13) : in your case, each xml messages are directly added to the previous one without any separation. Or that may be linux related, i don't know.

Anyway I will update the code tonight to deal with your situation, stay tuned.

bergvoll commented 9 years ago

I've never coded anything like this, but to me it looks like there are som characters between line 214 and 217 in the pastebin that might split the messages (not visible in cat /dev/ttyUSB1) ?

Anyway, thanks for helping me!

SR-G commented 9 years ago

Thanks for the pastebin, much clearer.

So in the end, indeed, it is just that on your setup the separator is 10 and not 13 ...

I've already commited the modified code and pushed a new zip, feel free to try it.

bergvoll commented 9 years ago

Great, now it works! Thank you so much for this app, and your quick support!

SR-G commented 9 years ago

Glad to hear that it works now ! Happy energy graphing in openhab then ;)

Closing the issue.