openHAB 2.2 binding
-
@TimO My sketches are sending the nodes remaining battery power to the controller via a V_VOLTAGE. Openhab 2 with your binding doesn't seem to be able to read these values. Is this an error (possibly on my side) or does the not yet support this?
@LastSamurai Did you connect a channel / item for V_VOLTAGE? If the sensor is not represented by the sketch you need to connect it manually.
-
Can we use this binding for MQTT once the PR is available in OpenHAB?
It is a separate mqtt generic binding in ESH for things discovery but I cannot make out if this will solve the dependency issue or not.
https://github.com/eclipse/smarthome/pull/3876@gahlawathome I'm currently looking into the new MQTT implementation in smartphone. It should work without the PR above. The PR will bring us a new option to connect a MQTT binding with OpenHAB!
-
@LastSamurai Did you connect a channel / item for V_VOLTAGE? If the sensor is not represented by the sketch you need to connect it manually.
@TimO I am not sure what you mean.
My sketch sends a presentation:present(CHILD_ID_BATTERY, S_MULTIMETER);and in openhab I added these (tried both sensor kinds)
// things customSensor abc [nodeId=26, childId=1] multimeter def [nodeId=17, childId=1] // and items Number voltageSensorWZ ... { channel="mysensors:multimeter:gwSerial:def:volt" } //...Is there anything i am missing here?
-
@TimO I am not sure what you mean.
My sketch sends a presentation:present(CHILD_ID_BATTERY, S_MULTIMETER);and in openhab I added these (tried both sensor kinds)
// things customSensor abc [nodeId=26, childId=1] multimeter def [nodeId=17, childId=1] // and items Number voltageSensorWZ ... { channel="mysensors:multimeter:gwSerial:def:volt" } //...Is there anything i am missing here?
The channel is not correct:
channel="mysensors:multimeter:gwSerial:voltageSensorWZ:volt"It's confusing, but that's the way OpenHAB2 handles channels. :confused:
-
The channel is not correct:
channel="mysensors:multimeter:gwSerial:voltageSensorWZ:volt"It's confusing, but that's the way OpenHAB2 handles channels. :confused:
@TimO Thanks for your help though I am afraid you mixed something up there. The channel linking to the item itself doesn't really make sense ;)
Not 100% sure why it did not work earlier for me but I now got it to work like this:// thing multimeter voltTHWohnzimmer [nodeId=1, childId=2] // item Number voltageSensorWZ "Spannung [%3f mV]" <poweroutlet_eu> (grVolt, grWZ) { channel="mysensors:multimeter:gwSerial:voltTHWohnzimmer:volt" }My error in the code above seems to have been that I defined most as customSensor instead of multimeter.
-
@TimO said in openHAB 2.2 binding:
The channel is not correct:
channel="mysensors:multimeter:gwSerial:voltageSensorWZ:volt"It's confusing, but that's the way OpenHAB2 handles channels. :confused:
Is the pattern:
<binding name>:<mysensors type>:<gateway id>:<thing name>:<data name> ? -
Just to let you know that I am very happy with this binding.
One thing for others to be aware of:
If you use PaperUI for configuring etc, make sure you leave Simple Mode off if you expect to use Groups later on. Simple mode adds the items (including the VAR1-5 :-() automatically but they are not 'managed'. This means you will get 404 and 405 errors on trying to edit them later on.
My solution was to let the binding autodiscover and add the Things. Then add 1 Item manually so that the\\192.168.0.123\openHAB-share\openhab2-userdata\jsondb\org.eclipse.smarthome.core.items.Item.json
file gets created and filled with an example to clone. I then added the various sensors using Name of pattern <binding name><sensorname><nodeid>_<dataname>, e.g."mysensors_light_level_node4_last_update": { "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem", "value": { "groupNames": [ "gLastUpdated" ], "itemType": "DateTime", "tags": [], "label": "Last", "category": "calendar" } },You must stop Openhab before editing the file (else you will lose your edits) but once it starts up again you will see the Items listed in PaperUI (and VSCode if you use that). You can then add the Channel/Item links for each Thing.
-
Thanks for some great work @TimO ! Version 2.2 now works smoothly with my simple OpenHAB setup (2.2 snapshot).
One thing I noticed is that the gateway thing configuration page says "Disable network sanity check" even though the logic has been reversed in v2.2.
So the UI needs to be similarly changed to "Enable startup check" instead.While I'm at it, could you please also clarify (in the UI) what "Send delay" is? Please also add that timing is in ms. If I understand things correctly it could say "Minimum time between messages sent to the gateway (ms)"
Also, the comment for "Imperial/Metric selection" could use some clarification. Preferably change the label to "Imperial units" and the explanation to "Use imperial units (default is metric)."
And finally it would be great to add add that the time is given in "...(minutes)" for the Network sanity check interval.
-
I have just updated to the stable openHAB 2.2 Version and everything seemed to be working just fine in the beginning but after the next restart I got this error:
10:31:19.727 [WARN ] [fig.xml.osgi.XmlDocumentBundleTracker] - The XML document '/ESH-INF/binding/binding.xml' in module 'org.openhab.binding.mysensors' could not be parsed: The XmlConfigDescriptionProvider must not be null!It seems like I can still control my devices just fine but I just wanted to make sure that this doesn't cause errors down the line. So @TimO any idea where this error is coming from?
-
After upgrade OH to 2.2 stable release. (2.2_01). I'm having the same issue that zwave binding not working. After Mysensors binding is installed and gateway configured. There is only one serial port visiable in PaperUI, which is /dev/ttyUSB0 that is configured for the serial gateway. I'm using org.openhab.binding.mysensors-2.2.0-SNAPSHOT-serial-fix.jar.
Also the old 2.1 snapshot version doesn't work either. anyone else experience this issue?
-
Hi,
I have issues with MySensors and specifically Energy Sensors where they request latest value.
See this thread for details: https://forum.mysensors.org/topic/8833/power-sensors-stopped-workingAny idea how to solve it?
-
Hello,
iam using "openHAB 2.2.0-1 (Release Build)" as openhabian on a PI3.
i've installed "org.openhab.binding.mysensors-2.2.0-SNAPSHOT.jar" as explained in the instructions.
configured the thing "MySensors Serial Gateway" to use "/dev/ttyACM0" with Baudrate "38400" because i'm using a pro micro with 8Mhz which isn't capable of 115200 (as far as i know).
the Items got discovered fine.
Atm i have only one item with
#define CHILD_ID_TEMP 0 unsigned long SLEEP_TIME = 3 * 1000; // Sleep time between reads (in milliseconds) MyMessage tempMsg(CHILD_ID_TEMP, S_TEMP);Presentation:
void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Temp/Hum/Pre Sensor", "1.2"); // Register all sensors to gateway (they will be created as child devices) present(CHILD_ID_TEMP, S_TEMP); }and Loop:
unsigned long currentTime = millis(); temperature++;//bme.readTemperature(); lastSend = currentTime; send(tempMsg.set(temperature, 2)); lastTemp = temperature; sleep(SLEEP_TIME);This is my debug from "openhab-cli showlogs"
2018-01-07 13:59:17.676 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;0;1;0;6;109.00 2018-01-07 13:59:17.680 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 13:59:17.683 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 13:59:17.687 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not presentAnd this from Log Viewer
2018-01-07 14:00:18.836 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 14:00:18.841 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 14:00:18.846 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not present 2018-01-07 14:00:27.561 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=6,pt=7,l=5,sg=0:117.00 2018-01-07 14:00:27.566 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;0;1;0;6;117.00 2018-01-07 14:00:27.572 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 14:00:27.577 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 14:00:27.582 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not present 2018-01-07 14:00:36.301 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=6,pt=7,l=5,sg=0:118.00 2018-01-07 14:00:36.308 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;0;1;0;6;118.00 2018-01-07 14:00:36.311 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 14:00:36.315 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 14:00:36.318 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not present 2018-01-07 14:00:45.034 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=6,pt=7,l=5,sg=0:119.00 2018-01-07 14:00:45.037 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;0;1;0;6;119.00 2018-01-07 14:00:45.039 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 14:00:45.042 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 14:00:45.045 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not presentSo from log i can see Temp is counting up. but in "Paper Ui"
i always get "Temperature -NaN °C" or "Temperature 0 °C"
Please correct me if this is the wrong place for this question.
Greets Andi
-
After upgrade OH to 2.2 stable release. (2.2_01). I'm having the same issue that zwave binding not working. After Mysensors binding is installed and gateway configured. There is only one serial port visiable in PaperUI, which is /dev/ttyUSB0 that is configured for the serial gateway. I'm using org.openhab.binding.mysensors-2.2.0-SNAPSHOT-serial-fix.jar.
Also the old 2.1 snapshot version doesn't work either. anyone else experience this issue?
@mythbai said in openHAB 2.2 binding:
After upgrade OH to 2.2 stable release. (2.2_01). I'm having the same issue that zwave binding not working. After Mysensors binding is installed and gateway configured. There is only one serial port visiable in PaperUI, which is /dev/ttyUSB0 that is configured for the serial gateway. I'm using org.openhab.binding.mysensors-2.2.0-SNAPSHOT-serial-fix.jar.
Also the old 2.1 snapshot version doesn't work either. anyone else experience this issue?
Up my own post. Not many users are using Zwave dongle and Mysensors at the same time? I feel this forum or trend is dead... This problem is driving me crazy, render all my mysensors useless. I'm trying to build a ethernet gateway now...
-
@mythbai said in openHAB 2.2 binding:
After upgrade OH to 2.2 stable release. (2.2_01). I'm having the same issue that zwave binding not working. After Mysensors binding is installed and gateway configured. There is only one serial port visiable in PaperUI, which is /dev/ttyUSB0 that is configured for the serial gateway. I'm using org.openhab.binding.mysensors-2.2.0-SNAPSHOT-serial-fix.jar.
Also the old 2.1 snapshot version doesn't work either. anyone else experience this issue?
Up my own post. Not many users are using Zwave dongle and Mysensors at the same time? I feel this forum or trend is dead... This problem is driving me crazy, render all my mysensors useless. I'm trying to build a ethernet gateway now...
Hey @mythbai !
Could you please download and install the most recent version of the binding? I've not changed anything at the serial code, but while we're trying to figure out the problem, we should be on the same base of code. :-)
I too have two serial devices connected to my OpenHAB box, one serial MySensors gateway and one Ebus-Adapter to Ebusd.
You may need to execute:
feature:install esh-io-transport-mqttBecause the most current version of the binding now supports MQTT gateways.
-
Hello,
iam using "openHAB 2.2.0-1 (Release Build)" as openhabian on a PI3.
i've installed "org.openhab.binding.mysensors-2.2.0-SNAPSHOT.jar" as explained in the instructions.
configured the thing "MySensors Serial Gateway" to use "/dev/ttyACM0" with Baudrate "38400" because i'm using a pro micro with 8Mhz which isn't capable of 115200 (as far as i know).
the Items got discovered fine.
Atm i have only one item with
#define CHILD_ID_TEMP 0 unsigned long SLEEP_TIME = 3 * 1000; // Sleep time between reads (in milliseconds) MyMessage tempMsg(CHILD_ID_TEMP, S_TEMP);Presentation:
void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Temp/Hum/Pre Sensor", "1.2"); // Register all sensors to gateway (they will be created as child devices) present(CHILD_ID_TEMP, S_TEMP); }and Loop:
unsigned long currentTime = millis(); temperature++;//bme.readTemperature(); lastSend = currentTime; send(tempMsg.set(temperature, 2)); lastTemp = temperature; sleep(SLEEP_TIME);This is my debug from "openhab-cli showlogs"
2018-01-07 13:59:17.676 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;0;1;0;6;109.00 2018-01-07 13:59:17.680 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 13:59:17.683 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 13:59:17.687 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not presentAnd this from Log Viewer
2018-01-07 14:00:18.836 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 14:00:18.841 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 14:00:18.846 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not present 2018-01-07 14:00:27.561 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=6,pt=7,l=5,sg=0:117.00 2018-01-07 14:00:27.566 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;0;1;0;6;117.00 2018-01-07 14:00:27.572 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 14:00:27.577 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 14:00:27.582 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not present 2018-01-07 14:00:36.301 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=6,pt=7,l=5,sg=0:118.00 2018-01-07 14:00:36.308 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;0;1;0;6;118.00 2018-01-07 14:00:36.311 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 14:00:36.315 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 14:00:36.318 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not present 2018-01-07 14:00:45.034 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=6,pt=7,l=5,sg=0:119.00 2018-01-07 14:00:45.037 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;0;1;0;6;119.00 2018-01-07 14:00:45.039 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2018-01-07 14:00:45.042 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1 2018-01-07 14:00:45.045 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_RAIN not presentSo from log i can see Temp is counting up. but in "Paper Ui"
i always get "Temperature -NaN °C" or "Temperature 0 °C"
Please correct me if this is the wrong place for this question.
Greets Andi
Hello @lesockz !
Well your node is sending V_RAIN instead of V_TEMP, so OpenHAB is not able to work with that.
Try:
MyMessage tempMsg(CHILD_ID_TEMP, V_TEMP);For presentation S_TEMP (== 6) is used, while for set messages V_TEMP (==0) is used.
-
@mythbai said in openHAB 2.2 binding:
After upgrade OH to 2.2 stable release. (2.2_01). I'm having the same issue that zwave binding not working. After Mysensors binding is installed and gateway configured. There is only one serial port visiable in PaperUI, which is /dev/ttyUSB0 that is configured for the serial gateway. I'm using org.openhab.binding.mysensors-2.2.0-SNAPSHOT-serial-fix.jar.
Also the old 2.1 snapshot version doesn't work either. anyone else experience this issue?
Up my own post. Not many users are using Zwave dongle and Mysensors at the same time? I feel this forum or trend is dead... This problem is driving me crazy, render all my mysensors useless. I'm trying to build a ethernet gateway now...
@mythbai While the code for the serial connection in the binding was unchanged for a while it definatly issn't working now together with zwave binding.
Some time ago I've prepared a change of the serial library the binding is using. A few first tests looked promising but I didn't find the time to test it. So lets give it a new try: could you please test this binding: OH2 Binding with Serial Refactoring
Please remove the old binding with bundle:list, bundle:remove ID before installing the new one.
-
I am moving the topic here as more appropriate :) (old ref)
I have OH v2.2 and latest MySensors 2.2.0 binding and my power sensors have stopped working.
After some investigation it seems they cannot receive the old pulse count value and by that cannot start working.
MySensors GW running 2.1.1 and the one power sensor I am testing also 2.1.1 (the rest 1.5.x)The debug (serial monitor) of the sensor shows that
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 3 TSM:INIT 4 TSF:WUR:MS=0 11 TSM:INIT:TSP OK 13 TSM:INIT:STATID=5 14 TSF:SID:OK,ID=5 16 TSM:FPAR 52 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 2060 !TSM:FPAR:NO REPLY 2062 TSM:FPAR 2098 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 2983 TSF:MSG:READ,0-0-5,s=255,c=3,t=8,pt=1,l=1,sg=0:0 2989 TSF:MSG:FPAR OK,ID=0,D=1 4106 TSM:FPAR:OK 4107 TSM:ID 4108 TSM:ID:OK 4110 TSM:UPL 4147 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1 6154 TSM:UPL 6159 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=1,st=OK:1 6168 TSF:MSG:READ,0-0-5,s=255,c=3,t=25,pt=1,l=1,sg=0:1 6173 TSF:MSG:PONG RECV,HP=1 6175 TSM:UPL:OK 6177 TSM:READY:ID=5,PAR=0,DIS=1 6182 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 6189 TSF:MSG:READ,0-0-5,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 6232 !TSF:MSG:SEND,5-5-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=NACK:2.1.1 6243 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=1,st=OK:0 6259 TSF:MSG:READ,0-0-5,s=255,c=3,t=6,pt=0,l=1,sg=0:M 6305 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=11,pt=0,l=13,sg=0,ft=0,st=NACK:Heater Energy 6349 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=1,st=NACK:2.0 6391 !TSF:MSG:SEND,5-5-0-0,s=0,c=0,t=13,pt=0,l=0,sg=0,ft=2,st=NACK: 6397 MCO:REG:REQ 6435 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=3,st=NACK:2 8476 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=4,st=NACK:2 10486 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=5,st=OK:2 10493 TSF:MSG:READ,0-0-5,s=255,c=3,t=27,pt=1,l=1,sg=0:1 10499 MCO:PIM:NODE REG=1 10501 MCO:BGN:STP 10528 TSF:MSG:SEND,5-5-0-0,s=0,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK: Got Pulse 10534 MCO:BGN:INIT OK,TSP=1 Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse No count received. Try requesting it again 30570 !TSF:MSG:SEND,5-5-0-0,s=0,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=NACK: Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse No count received. Try requesting it again 50546 TSF:MSG:SEND,5-5-0-0,s=0,c=2,t=24,pt=0,l=0,sg=0,ft=1,st=OK: Got PulseThe sketch looks like this:
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik EKblad * * DESCRIPTION * This sketch provides an example how to implement a distance sensor using HC-SR04 * Use this sensor to measure KWH and Watt of your house meeter * You need to set the correct pulsefactor of your meeter (blinks per KWH). * The sensor starts by fetching current KWH value from gateway. * Reports both KWH and Watt back to gateway. * * Unfortunately millis() won't increment when the Arduino is in * sleepmode. So we cannot make this sensor sleep if we also want * to calculate/report watt-number. * http://www.mysensors.org/build/pulse_power */ // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 5 #include <MySensors.h> #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!) #define PULSE_FACTOR 1000 // Nummber of blinks per KWH of your meeter #define MAX_WATT 10000 // Max watt value to report. This filetrs outliers. #define CHILD_ID 0 // Id of the sensor child unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway. double ppwh = ((double)PULSE_FACTOR)/1000; // Pulses per watt hour bool pcReceived = false; volatile unsigned long pulseCount = 0; volatile unsigned long lastBlink = 0; volatile unsigned long watt = 0; unsigned long oldPulseCount = 0; unsigned long oldWatt = 0; double oldKwh; unsigned long lastSend; MyMessage wattMsg(CHILD_ID,V_WATT); MyMessage kwhMsg(CHILD_ID,V_KWH); MyMessage pcMsg(CHILD_ID,V_VAR1); void setup() { // Fetch last known pulse count value from gw request(CHILD_ID, V_VAR1); // Use the internal pullup to be able to hook up this sketch directly to an energy meter with S0 output // If no pullup is used, the reported usage will be too high because of the floating pin pinMode(DIGITAL_INPUT_SENSOR,INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, RISING); lastSend=millis(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Heater Energy", "2.0"); // Register this device as power sensor present(CHILD_ID, S_POWER); } void loop() { unsigned long now = millis(); // Only send values at a maximum frequency or woken up from sleep bool sendTime = now - lastSend > SEND_FREQUENCY; if (pcReceived && sendTime) { // New watt value has been calculated if (watt != oldWatt) { // Check that we dont get unresonable large watt value. // could hapen when long wraps or false interrupt triggered if (watt<((unsigned long)MAX_WATT)) { send(wattMsg.set(watt)); // Send watt value to gw } Serial.print("Watt:"); Serial.println(watt); oldWatt = watt; } // Pulse cout has changed if (pulseCount != oldPulseCount) { send(pcMsg.set(pulseCount)); // Send pulse count value to gw double kwh = ((double)pulseCount/((double)PULSE_FACTOR)); oldPulseCount = pulseCount; if (kwh != oldKwh) { send(kwhMsg.set(kwh, 4)); // Send kwh value to gw oldKwh = kwh; } } lastSend = now; } else if (sendTime && !pcReceived) { // No count received. Try requesting it again Serial.println("No count received. Try requesting it again"); request(CHILD_ID, V_VAR1); lastSend=now; } } void receive(const MyMessage &message) { Serial.print("MessageType:"); Serial.println(message.type); Serial.print("Message:"); Serial.println(message.getLong()); if (message.type==V_VAR1) { pulseCount = oldPulseCount = message.getLong(); Serial.print("Received last pulse count from gw:"); Serial.println(pulseCount); pcReceived = true; } } void onPulse() { Serial.println("Got Pulse"); unsigned long newBlink = micros(); unsigned long interval = newBlink-lastBlink; if (interval<10000L) { // Sometimes we get interrupt on RISING return; } watt = (3600000000.0 /interval) / ppwh; lastBlink = newBlink; pulseCount++; }Today I realized that I likely need to have item(s) created in OH to save the values - so created Var1 (and then added one after another with no success). Currently it looks like:
Number CellarAirHeaterSensorWatt "Airheater Watt" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:watt", mqtt=">[rabbitmq:/myhouse/airpump/sensor/power:state:*:Power,sensor=${itemName},location=airpump watt=${state} ]" } Number CellarAirHeaterSensorKwh "Airheater Kwh" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:kwh", mqtt=">[rabbitmq:/myhouse/airpump/sensor/power:state:*:Power,sensor=${itemName},location=airpump kwh=${state} ]" } Number CellarAirHeaterSensorVar "Airheater Var" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:var" } Number CellarAirHeaterSensorVar1 "Airheater Var1" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:var1" } Number CellarAirHeaterSensorVA "Airheater VA" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:va" }Still no success!
Do you have any idea what's wrong?
-
@mythbai While the code for the serial connection in the binding was unchanged for a while it definatly issn't working now together with zwave binding.
Some time ago I've prepared a change of the serial library the binding is using. A few first tests looked promising but I didn't find the time to test it. So lets give it a new try: could you please test this binding: OH2 Binding with Serial Refactoring
Please remove the old binding with bundle:list, bundle:remove ID before installing the new one.
@timo said in openHAB 2.2 binding:
Some time ago I've prepared a change of the serial library the binding is using. A few first tests looked promising but I didn't find the time to test it. So lets give it a new try: could you please test this binding: OH2 Binding with Serial Refactoring
Please remove the old binding with bundle:list, bundle:remove ID before installing the new one.
@TimO Thank you very much! Here is what I got with the new jar:
Initial bundle:uninstall, and replace jar works. But after server reboot, the MySensor binding is not loading due to some "Multiexception" on framework level (sorry didn't capture that log).
I tried to restart binding in console:openhab> bundle:restart 233 Error executing command: Error restarting bundles: Unable to start bundle 233: Could not resolve module: org.openhab.binding.mysensors [233] Unresolved requirement: Import-Package: org.eclipse.smarthome.io.transport.mqttThis is an easy fix by "feature:install openhab-transport-mqtt". And after that bundle works! (why do I have to install mqtt transport here .... )
2). After fix above, did a server reboot. Got MySensors thing discovery related exceptions, but both zwave and mysensors binding loaded, and things got online. The fix actually works!!! just with some minor glitch:
09:04:38.710 [ERROR] [org.openhab.binding.mysensors ] - [org.openhab.binding.mysensors.discovery.MySensorsDiscoveryService(221)] Error during instantiation of the implementation object java.lang.InstantiationException: org.openhab.binding.mysensors.discovery.MySensorsDiscoveryService at java.lang.Class.newInstance(Class.java:427) [?:?] at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:237) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:109) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:823) [42:org.apache.felix.scr:2.0.12] at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212) [?:?] at java.security.AccessController.doPrivileged(Native Method) ~[?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619) [?:?] at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.inject.BindMethod.getServiceObject(BindMethod.java:651) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2201) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1714) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1699) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:372) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:320) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:291) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127) [42:org.apache.felix.scr:2.0.12] at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:915) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464) [?:?] at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:887) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:874) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:132) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:941) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:741) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:675) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:430) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:390) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:265) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:254) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:227) [42:org.apache.felix.scr:2.0.12] at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) [?:?] at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) [?:?] at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [?:?] at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [?:?] at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156) [?:?] at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [?:?] at org.eclipse.osgi.container.Module.start(Module.java:467) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1600) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?] Caused by: java.lang.NoSuchMethodException: org.openhab.binding.mysensors.discovery.MySensorsDiscoveryService.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:?] at java.lang.Class.newInstance(Class.java:412) ~[?:?] ... 70 more 09:04:39.069 [WARN ] [org.openhab.binding.mysensors ] - FrameworkEvent WARNING - org.openhab.binding.mysensors org.osgi.framework.ServiceException: org.apache.felix.scr.impl.manager.SingleComponentManager.getService() returned a null service object at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:232) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619) [?:?] at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.inject.BindMethod.getServiceObject(BindMethod.java:651) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2201) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1714) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1699) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:372) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:320) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:291) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127) [42:org.apache.felix.scr:2.0.12] at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:915) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464) [?:?] at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:887) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:874) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:132) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:941) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:741) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:675) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:430) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:390) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:265) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:254) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:227) [42:org.apache.felix.scr:2.0.12] at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) [?:?] at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) [?:?] at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [?:?] at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [?:?] at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156) [?:?] at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [?:?] at org.eclipse.osgi.container.Module.start(Module.java:467) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1600) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]It's a good start, I now have all my sensors working now!
-
@timo said in openHAB 2.2 binding:
Some time ago I've prepared a change of the serial library the binding is using. A few first tests looked promising but I didn't find the time to test it. So lets give it a new try: could you please test this binding: OH2 Binding with Serial Refactoring
Please remove the old binding with bundle:list, bundle:remove ID before installing the new one.
@TimO Thank you very much! Here is what I got with the new jar:
Initial bundle:uninstall, and replace jar works. But after server reboot, the MySensor binding is not loading due to some "Multiexception" on framework level (sorry didn't capture that log).
I tried to restart binding in console:openhab> bundle:restart 233 Error executing command: Error restarting bundles: Unable to start bundle 233: Could not resolve module: org.openhab.binding.mysensors [233] Unresolved requirement: Import-Package: org.eclipse.smarthome.io.transport.mqttThis is an easy fix by "feature:install openhab-transport-mqtt". And after that bundle works! (why do I have to install mqtt transport here .... )
2). After fix above, did a server reboot. Got MySensors thing discovery related exceptions, but both zwave and mysensors binding loaded, and things got online. The fix actually works!!! just with some minor glitch:
09:04:38.710 [ERROR] [org.openhab.binding.mysensors ] - [org.openhab.binding.mysensors.discovery.MySensorsDiscoveryService(221)] Error during instantiation of the implementation object java.lang.InstantiationException: org.openhab.binding.mysensors.discovery.MySensorsDiscoveryService at java.lang.Class.newInstance(Class.java:427) [?:?] at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:237) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:109) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:823) [42:org.apache.felix.scr:2.0.12] at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212) [?:?] at java.security.AccessController.doPrivileged(Native Method) ~[?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619) [?:?] at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.inject.BindMethod.getServiceObject(BindMethod.java:651) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2201) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1714) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1699) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:372) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:320) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:291) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127) [42:org.apache.felix.scr:2.0.12] at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:915) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464) [?:?] at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:887) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:874) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:132) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:941) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:741) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:675) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:430) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:390) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:265) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:254) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:227) [42:org.apache.felix.scr:2.0.12] at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) [?:?] at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) [?:?] at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [?:?] at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [?:?] at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156) [?:?] at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [?:?] at org.eclipse.osgi.container.Module.start(Module.java:467) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1600) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?] Caused by: java.lang.NoSuchMethodException: org.openhab.binding.mysensors.discovery.MySensorsDiscoveryService.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:?] at java.lang.Class.newInstance(Class.java:412) ~[?:?] ... 70 more 09:04:39.069 [WARN ] [org.openhab.binding.mysensors ] - FrameworkEvent WARNING - org.openhab.binding.mysensors org.osgi.framework.ServiceException: org.apache.felix.scr.impl.manager.SingleComponentManager.getService() returned a null service object at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:232) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619) [?:?] at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.inject.BindMethod.getServiceObject(BindMethod.java:651) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2201) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1714) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1699) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:372) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:320) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:291) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127) [42:org.apache.felix.scr:2.0.12] at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:915) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [?:?] at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464) [?:?] at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:887) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:874) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:132) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:941) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:741) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:675) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:430) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:390) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:265) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:254) [42:org.apache.felix.scr:2.0.12] at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:227) [42:org.apache.felix.scr:2.0.12] at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) [?:?] at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) [?:?] at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [?:?] at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [?:?] at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [?:?] at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [?:?] at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156) [?:?] at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [?:?] at org.eclipse.osgi.container.Module.start(Module.java:467) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1600) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514) [?:?] at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?] at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]It's a good start, I now have all my sensors working now!
@mythbai Thank you for reporting back! I'm glad it is working now.
The transport-mqtt feature is now needed because the support for MQTT GW is now part of the binding and the fix I've provided to you is based on the current code base.
The exception is completely unrelated to your problem and will do no harm. It only occures on startup and will soon be fixed!
-
I am moving the topic here as more appropriate :) (old ref)
I have OH v2.2 and latest MySensors 2.2.0 binding and my power sensors have stopped working.
After some investigation it seems they cannot receive the old pulse count value and by that cannot start working.
MySensors GW running 2.1.1 and the one power sensor I am testing also 2.1.1 (the rest 1.5.x)The debug (serial monitor) of the sensor shows that
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 3 TSM:INIT 4 TSF:WUR:MS=0 11 TSM:INIT:TSP OK 13 TSM:INIT:STATID=5 14 TSF:SID:OK,ID=5 16 TSM:FPAR 52 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 2060 !TSM:FPAR:NO REPLY 2062 TSM:FPAR 2098 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 2983 TSF:MSG:READ,0-0-5,s=255,c=3,t=8,pt=1,l=1,sg=0:0 2989 TSF:MSG:FPAR OK,ID=0,D=1 4106 TSM:FPAR:OK 4107 TSM:ID 4108 TSM:ID:OK 4110 TSM:UPL 4147 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1 6154 TSM:UPL 6159 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=1,st=OK:1 6168 TSF:MSG:READ,0-0-5,s=255,c=3,t=25,pt=1,l=1,sg=0:1 6173 TSF:MSG:PONG RECV,HP=1 6175 TSM:UPL:OK 6177 TSM:READY:ID=5,PAR=0,DIS=1 6182 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 6189 TSF:MSG:READ,0-0-5,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 6232 !TSF:MSG:SEND,5-5-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=NACK:2.1.1 6243 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=1,st=OK:0 6259 TSF:MSG:READ,0-0-5,s=255,c=3,t=6,pt=0,l=1,sg=0:M 6305 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=11,pt=0,l=13,sg=0,ft=0,st=NACK:Heater Energy 6349 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=1,st=NACK:2.0 6391 !TSF:MSG:SEND,5-5-0-0,s=0,c=0,t=13,pt=0,l=0,sg=0,ft=2,st=NACK: 6397 MCO:REG:REQ 6435 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=3,st=NACK:2 8476 !TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=4,st=NACK:2 10486 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=5,st=OK:2 10493 TSF:MSG:READ,0-0-5,s=255,c=3,t=27,pt=1,l=1,sg=0:1 10499 MCO:PIM:NODE REG=1 10501 MCO:BGN:STP 10528 TSF:MSG:SEND,5-5-0-0,s=0,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK: Got Pulse 10534 MCO:BGN:INIT OK,TSP=1 Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse No count received. Try requesting it again 30570 !TSF:MSG:SEND,5-5-0-0,s=0,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=NACK: Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse Got Pulse No count received. Try requesting it again 50546 TSF:MSG:SEND,5-5-0-0,s=0,c=2,t=24,pt=0,l=0,sg=0,ft=1,st=OK: Got PulseThe sketch looks like this:
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik EKblad * * DESCRIPTION * This sketch provides an example how to implement a distance sensor using HC-SR04 * Use this sensor to measure KWH and Watt of your house meeter * You need to set the correct pulsefactor of your meeter (blinks per KWH). * The sensor starts by fetching current KWH value from gateway. * Reports both KWH and Watt back to gateway. * * Unfortunately millis() won't increment when the Arduino is in * sleepmode. So we cannot make this sensor sleep if we also want * to calculate/report watt-number. * http://www.mysensors.org/build/pulse_power */ // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 5 #include <MySensors.h> #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!) #define PULSE_FACTOR 1000 // Nummber of blinks per KWH of your meeter #define MAX_WATT 10000 // Max watt value to report. This filetrs outliers. #define CHILD_ID 0 // Id of the sensor child unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway. double ppwh = ((double)PULSE_FACTOR)/1000; // Pulses per watt hour bool pcReceived = false; volatile unsigned long pulseCount = 0; volatile unsigned long lastBlink = 0; volatile unsigned long watt = 0; unsigned long oldPulseCount = 0; unsigned long oldWatt = 0; double oldKwh; unsigned long lastSend; MyMessage wattMsg(CHILD_ID,V_WATT); MyMessage kwhMsg(CHILD_ID,V_KWH); MyMessage pcMsg(CHILD_ID,V_VAR1); void setup() { // Fetch last known pulse count value from gw request(CHILD_ID, V_VAR1); // Use the internal pullup to be able to hook up this sketch directly to an energy meter with S0 output // If no pullup is used, the reported usage will be too high because of the floating pin pinMode(DIGITAL_INPUT_SENSOR,INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, RISING); lastSend=millis(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Heater Energy", "2.0"); // Register this device as power sensor present(CHILD_ID, S_POWER); } void loop() { unsigned long now = millis(); // Only send values at a maximum frequency or woken up from sleep bool sendTime = now - lastSend > SEND_FREQUENCY; if (pcReceived && sendTime) { // New watt value has been calculated if (watt != oldWatt) { // Check that we dont get unresonable large watt value. // could hapen when long wraps or false interrupt triggered if (watt<((unsigned long)MAX_WATT)) { send(wattMsg.set(watt)); // Send watt value to gw } Serial.print("Watt:"); Serial.println(watt); oldWatt = watt; } // Pulse cout has changed if (pulseCount != oldPulseCount) { send(pcMsg.set(pulseCount)); // Send pulse count value to gw double kwh = ((double)pulseCount/((double)PULSE_FACTOR)); oldPulseCount = pulseCount; if (kwh != oldKwh) { send(kwhMsg.set(kwh, 4)); // Send kwh value to gw oldKwh = kwh; } } lastSend = now; } else if (sendTime && !pcReceived) { // No count received. Try requesting it again Serial.println("No count received. Try requesting it again"); request(CHILD_ID, V_VAR1); lastSend=now; } } void receive(const MyMessage &message) { Serial.print("MessageType:"); Serial.println(message.type); Serial.print("Message:"); Serial.println(message.getLong()); if (message.type==V_VAR1) { pulseCount = oldPulseCount = message.getLong(); Serial.print("Received last pulse count from gw:"); Serial.println(pulseCount); pcReceived = true; } } void onPulse() { Serial.println("Got Pulse"); unsigned long newBlink = micros(); unsigned long interval = newBlink-lastBlink; if (interval<10000L) { // Sometimes we get interrupt on RISING return; } watt = (3600000000.0 /interval) / ppwh; lastBlink = newBlink; pulseCount++; }Today I realized that I likely need to have item(s) created in OH to save the values - so created Var1 (and then added one after another with no success). Currently it looks like:
Number CellarAirHeaterSensorWatt "Airheater Watt" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:watt", mqtt=">[rabbitmq:/myhouse/airpump/sensor/power:state:*:Power,sensor=${itemName},location=airpump watt=${state} ]" } Number CellarAirHeaterSensorKwh "Airheater Kwh" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:kwh", mqtt=">[rabbitmq:/myhouse/airpump/sensor/power:state:*:Power,sensor=${itemName},location=airpump kwh=${state} ]" } Number CellarAirHeaterSensorVar "Airheater Var" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:var" } Number CellarAirHeaterSensorVar1 "Airheater Var1" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:var1" } Number CellarAirHeaterSensorVA "Airheater VA" <energy> { channel="mysensors:power:gateway:sensor-air-pump-power:va" }Still no success!
Do you have any idea what's wrong?
@jocke4u The request needs to be handled with rules because it is not allowed to access the value of an item via the binding API :smirk:.
Please post the request (from the OpenHAB log, enable DEBUG with log:set DEBUG org.openhab.binding.mysensors if not already done in the karaf console) and we'll figure out the rule.