SR-G / current-cost-forwarder

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

Multiple IAM inputs #3

Closed elyobelyob closed 9 years ago

elyobelyob commented 9 years ago

Not sure whether you use any IAM's, and need to separate the wattage data?

From what I can see, all the data is pushed into the same topic.

08:43:24.497 [THREAD-CURRENT-COST-FORWARDER-READER] INFO org.tensin.ccf.forwarder.mqtt.ForwarderMQTT - Forwarding event #5 EventWatts : watts [2] on topic [metrics/current-cost/watts] 08:43:26.976 [THREAD-CURRENT-COST-FORWARDER-READER] INFO org.tensin.ccf.forwarder.mqtt.ForwarderMQTT - Forwarding event #6 EventTemperature : temperature [22.6] on topic [metrics/current-cost/temperature] 08:43:27.049 [THREAD-CURRENT-COST-FORWARDER-READER] INFO org.tensin.ccf.forwarder.mqtt.ForwarderMQTT - Forwarding event #7 EventWatts : watts [151] on topic [metrics/current-cost/watts]

Here is a debug example of an IAM, with an alternate id ...

08:57:58.213 [THREAD-CURRENT-COST-FORWARDER-READER] DEBUG org.tensin.ccf.reader.CurrentCostReader - Now processing XML [CC128-v1.290163922.5103047100002]

So, all the data that comes through is not able to be identified, AFAIK. Unless, I'm missing something.

pi@raspberrypi ~ $ mosquitto_sub -h 127.0.0.1 -p 1883 -t metrics/# 22.4 143 22.4 2 22.4 164 22.4 229 22.4 2 22.4 146 22.4 231 22.4 2 22.4 169 22.4 259

SR-G commented 9 years ago

Indeed i don't have multiple IAMs so i haven't dealed with that situation.

Should be really easy on my side to modify in order to deal with this case.

Could you post an additionnal XML debug (exactly like the one above) but for another device ? I don't know if it is the "sensor" and "id" fields that differ betweem IAMs, or the "channel" (ch1, ch2, ...) ? I'll probably make something like a customizable output pattern for the topic names (something like "base_topic/${device}/watts" or "base_topic/${id}/watts".

elyobelyob commented 9 years ago

http://elyob.no-ip.org/cc.txt

It's sensor.

SR-G commented 9 years ago

Hey again. I made the modification, can you try the 1.0.1-SNAPSHOT.zip distribution ? You have to make a modification in the .sh, something like : --broker-topic '/metrics/current-cost/${id}' or --broker-topic '/metrics/current-cost/${sensor}' (beware : you have in this shell to enclose the broker topic with single quotes ' ' and not double-quotes " ")

Then it should be published on the enhanced topic with id and/or sensor

21:04:05.042 [THREAD-CURRENT-COST-FORWARDER-MQTT] INFO org.tensin.ccf.forwarder.mqtt.ForwarderMQTT - Forwarding event #7 EventWatts : id [00077], sensor [0], timestamp [1425672244952], watts [725] on topic [metrics/current-cost/00077/watts]

elyobelyob commented 9 years ago

Hi,

Not exactly sure where to download it from?

https://github.com/SR-G/current-cost-forwarder/releases only show 1.0.0 and 1.0.0-snapshot

Thanks

On Fri, Mar 6, 2015 at 8:10 PM, Serge notifications@github.com wrote:

Hey again. I made the modification, can you try the 1.0.1-SNAPSHOT.zip distribution ? You have to make a modification in the .sh, something like : --broker-topic '/metrics/current-cost/${id}' or --broker-topic '/metrics/current-cost/${sensor}' (beware : you have in this shell to enclose the broker topic with single quotes ' ' and not double-quotes " ")

Then it should be published on the enhanced topic with id and/or sensor

21:04:05.042 [THREAD-CURRENT-COST-FORWARDER-MQTT] INFO org.tensin.ccf.forwarder.mqtt.ForwarderMQTT - Forwarding event #7 EventWatts : id [00077], sensor [0], timestamp [1425672244952], watts [725] on topic [metrics/current-cost/00077/watts]

— Reply to this email directly or view it on GitHub https://github.com/SR-G/current-cost-forwarder/issues/3#issuecomment-77626898 .

SR-G commented 9 years ago

Woops sorry hadn't finished the "publish" operation of the the 1.0.1-SNAPSHOT version. Done now https://github.com/SR-G/current-cost-forwarder/releases

elyobelyob commented 9 years ago

My config ...

!/bin/sh

SCRIPT_NAME=$0 CURRENT_PATH=dirname "${SCRIPT_NAME}" LIB_PATH="${CURRENT_PATH}/lib/" MAIN_JAR=ls -1 "${LIB_PATH}" 2>/dev/null | grep -v "plugin" | grep "current-cost-forwarder" java -Xms92M -Xmx128M -jar "${LIB_PATH}/${MAIN_JAR}" --pid ${CURRENT_PATH}/current-cost-forwarder.pid --broker-url "tcp:// 127.0.0.1:1883" --broker-topic "metrics/current-cost/${sensor}" $*

Output data (verbose to show topic)

pi@raspberrypi ~ $ mosquitto_sub -h 127.0.0.1 -p 1883 -t metrics/# -v metrics/current-cost/temperature 23.9 metrics/current-cost/watts 2 metrics/current-cost/temperature 23.9 metrics/current-cost/watts 82 metrics/current-cost/temperature 23.8 metrics/current-cost/watts 243 metrics/current-cost/temperature 23.8

Not sure that the sensor is being built into the topic correctly?

Thanks

On Sun, Mar 8, 2015 at 6:02 PM, Serge notifications@github.com wrote:

Woops sorry hadn't finished the "publish" operation of the the 1.0.1-SNAPSHOT version. Done now https://github.com/SR-G/current-cost-forwarder/releases

— Reply to this email directly or view it on GitHub https://github.com/SR-G/current-cost-forwarder/issues/3#issuecomment-77764698 .

SR-G commented 9 years ago

Beware, in your shell pasted above it seems that you put " and not ' around the broker-topic ... (with " the ${sensor} string is evaluated by the shell itself and thus sent blank to the program ...) (you can check the base topic correctly read in a previous log)

elyobelyob commented 9 years ago

That's great, thanks.

metrics/current-cost/2/temperature 23.9 metrics/current-cost/2/watts 81 metrics/current-cost/1/temperature 23.9 metrics/current-cost/1/watts 2 metrics/current-cost/2/temperature 23.9 metrics/current-cost/2/watts 89 metrics/current-cost/1/temperature 23.9 metrics/current-cost/1/watts 2 metrics/current-cost/0/temperature 23.9 metrics/current-cost/0/watts 238 metrics/current-cost/2/temperature 23.9 metrics/current-cost/2/watts 80 metrics/current-cost/1/temperature 23.9 metrics/current-cost/1/watts 2 metrics/current-cost/0/temperature 23.9 metrics/current-cost/0/watts 233 metrics/current-cost/2/temperature 23.9 metrics/current-cost/2/watts 123 metrics/current-cost/1/temperature 23.9

On Sun, Mar 8, 2015 at 6:24 PM, Serge notifications@github.com wrote:

Beware, in your shell pasted above it seems that you put " and not ' around the broker-topic ... (with " the ${sensor} string is evaluated by the shell itself and thus sent blank to the program ...) (you can check the base topic correctly read in a previous log)

— Reply to this email directly or view it on GitHub https://github.com/SR-G/current-cost-forwarder/issues/3#issuecomment-77765876 .

NigelCoxon commented 9 years ago

Serge This is great. I have a 3 phase supply and my Envi device outputs 3 channels separately as ch1, ch2, and ch3. I was about to ask if you could enhance the code to handle all 3 channels, but you had it fixed before I asked!. I have downloaded the latest snapshot and it works well for me.

Like you my plan is to load the data into Openhab

Cheers Nigel

SR-G commented 9 years ago

Hey Nigel. Thanks for the confirmation about the multi-channels properly handled !