openHAB 2.0 binding


  • Hero Member

    Features

    • Serial Gateway supported (with variable baud rate)
    • Ethernet Gateway supported
    • Supported sensors: S_TEMP, S_HUM, S_VOLTAGE, S_LIGHT, S_POWER, S_BARO, S_DOOR, S_MOTION, S_SMOKE, S_DIMMER, S_COVER (Stop not implemented in OH2 yet), S_WIND, S_RAIN, S_UV, S_WEIGHT, S_DISTANCE, S_LIGHT_LEVEL
    • Request for an ID is answered (random free number is given)
    • Discovery of devices, to use it: start the scan for devices in OpenHAB 2.0 and restart your nodes

    Pictures
    Discovery:
    openhab2-mysensors-discovery-2015-07-27.png

    What is not working yet:

    • no reconnect after lost connection

    How to test:

    Visit the wiki on the GitHub Repo.



  • Good work, hope it will be ready with first stable 2.0.


  • Admin

    @TimO

    Looks good. Nice to finally see a plugin (embryo) for OpenHAB that doesn't require hacking around in configuration files.


  • Admin

    I have been watching OpenHab 2.0 with their new discovery class model and nice to see someone forging a proper integration. Bravo! :+1:


  • Hero Member

    Nice one Tim.

    I wish to move from Vera onto OpenHab eventually and this is a key piece of the puzzle!

    Looks forward to seeing your progress!



  • This is what everybody has been waiting for. Let me know when you need help testing / troubleshooting.


  • Hero Member

    Thanks for your offer!

    I've made some progress with the plugin. The plugin is now able to answer id requests and works for some sensors like humidity, temperature and voltage.
    A switch/light "thing" is working too, I've implemented a command queue, because with OpenHAB 1.x and the serial binding some commands are send too fast and won't get commited. For example my Close-all-shutter-scenario didn't always shuts all shutters.
    I'm currently working on the discovery process, so sensors that represent themself to the MySensors network will automatically be discovered by OpenHAB. So the user only has to decide if the thing should be displayed and where, but don't need to worry about node id and child id.

    I will definialty need some testers and I will call for help, if I think my github repository is useable.


  • Hero Member

    Hi Timo,

    I've just ( as of about 5mins ago) run up Openhab2 A2 on my Rpi2....and last night ran up a new iBoard ( unmodified thanks to @hugob ) with the MySensors Ethernet gateway sketch.

    As mentioned i plan to migrate off Vera so building a parallel environment to get up and running with.

    So i would love to help test/troubleshoot your MySensors binding....ethernet though?



  • I am very interested in this. I want to run openhab 2.0, but haven't been able to figure out the bindings for mqtt or mysensors. I'm available to test as well!



  • Good work!

    I will definialty need some testers and I will call for help, if I think my github repository is useable.

    We want to help! What is you github repo url?


  • Hero Member

    Sign me up or testing as well, please :-)


  • Hero Member

    Ok, so for those of you that would like to test a bleeding edge alpha version I've prepared a little test environment of OpenHAB 2.0.

    Please keep in mind: OpenHAB 2.0 is Alpha and my binding is in best case pre-alpha, so don't expect it to work. ;-)

    What should (maybe) work:

    • Serial Gateway supported
    • Ethernet Gateway supported
    • Supported sensors: V_TEMPERATURE, V_HUMIDITY, V_VOLTAGE, V_LIGHT
    • Request for an ID is answered (random free number is given)

    What is not working yet:

    • Automatic discovery of sensors that represent themself. I've made a basic implementation and in the debug mode there will be messages which say that a new device was discovered, but that is a lie. ;-) I've found the error in the implementation but it's not that easy to change, so I've postponed that.

    How to test:

    1. Download the package from: Download
    2. Unzip the file
    3. Change in the directory openhab2
    4. Execute "start_debug.sh" (or "start_debug.bat" should work on windows too, but not tested yet)
    5. Direct your browser to http://localhost:8080
    6. Watch the video for further information.

    I've made a demo of how to set up OpenHAB 2.0: Vimeo Link

    How to give feedback:

    1. If you've made a test and it is not working, reset everything and start from scratch and try to reproduce the error. Tell me, what you've done and give me the debug output.

    2. If you want to test a type of sensor that is not implemented yet, post the messages the sensor sends or expects and I will implement it so you're able to test. Someone posted a sketch for mock-sensors, I will look in that too.

    My ToDo List

    • Get discovery of sensors working
    • implement discovery of bridges / gateways
    • implement additional sensors
    • look into items-, rules-, config-files (the OpenHAB 1.X way to implement things)


  • As it seems there is no option for configuring the speed of the serial port. I have flashed my gateway with 9600 baud in config.h. Could this be a problem? I have added a temp and a hum sensor both using static node ids but I see no sensor data coming in. During startup of openhab2 I am seeing the following errors:

    2015-07-25 18:33:53 [INFO ] [ome.event.ThingStatusInfoEvent:43   ] - mysensors:humidity:93e7b934' updated: UNINITIALIZED (HANDLER_INITIALIZING_ERROR)
    2015-07-25 18:33:53 [ERROR] [.c.thing.internal.ThingManager:489  ] - Exception occured while calling thing handler factory 'org.openhab.binding.mysensors.internal.MySensorsHandlerFactory@1e5c7cf': nulljava.lang.NullPointerException: null
            at org.openhab.binding.mysensors.handler.MySensorsHandler.initialize(MySensorsHandler.java:51)
            at org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory.registerHandler(BaseThingHandlerFactory.java:116)
            at org.eclipse.smarthome.core.thing.internal.ThingManager$6.call(ThingManager.java:480)
            at org.eclipse.smarthome.core.thing.internal.ThingManager$6.call(ThingManager.java:1)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:744)
    
    

    and

    2015-07-25 18:33:53 [ERROR] [.c.thing.internal.ThingManager:489  ] - Exception occured while calling thing handler factory 'org.openhab.binding.mysensors.internal.MySensorsHandlerFactory@1e5c7cf': nulljava.lang.NullPointerException: null
            at org.openhab.binding.mysensors.handler.MySensorsHandler.initialize(MySensorsHandler.java:51)
            at org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory.registerHandler(BaseThingHandlerFactory.java:116)
            at org.eclipse.smarthome.core.thing.internal.ThingManager$6.call(ThingManager.java:480)
            at org.eclipse.smarthome.core.thing.internal.ThingManager$6.call(ThingManager.java:1)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:744)
    
    

    OpenHAB2 is running on a raspberry pi 2. I habe added this option to the start_debug.sh file: -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0


  • Hero Member

    @TimO It would be great if you could implement support for the power type. My sensor reports the following two values:
    3;1;1;0;17;2810, the current power consumption (Watt)
    3;1;1;0;18;106.2550, the overall power usage since sensor boot (KWH)

    It would also be good to be able to get the Gateway log messages such as this: 0;0;3;0;9;Gateway is alive.

    This is basically the only thing missing for me apart from the temperature and humidity sensors for the moment. I could give you some examples for barometric pressure and the resulting forecast message based on this if you're interested. I also think I have a sensor lying around that reports distance (actually it's time remaining, but it's using the distance type).

    Edit: The few sensors I have running at the moment should have reports available in the log file I included in the next post if you want something to look at :-)

    Edit: Barometer forecast message: 6;3;1;0;5;stable


  • Hero Member

    My five mins of experience:

    Setting up the serial Gateway thing work without problems, and I was also able to add a temperature sensor.

    BUG: Changing the name of the new thing (temperature sensor) was not successful. It stubbornly remained "Temperature sensor".

    Also, it does not seem to get any values even though they are reported in the log, but this might just be some kind of sluggishness?

    The same is the case for the humidity values. Example reports listed in the log: 6;2;1;0;1;48.0 (humidity)

    Edit: Humidity got updated, but I still get no update for the temperature.

    Updated log: server.log



  • @kolaf for which speed did you configure the serial gateway? The MySensors default or the openHAB default 9600 baud?


  • Hero Member

    @Jan-Gatzke I did not make any changes either to my Gateway or to the openhab configuration. I'm running at the default serial Gateway speed which I guess is 115200?



  • Ok, that explains my problems with openHAB 2.0. Former versions had a fixed speed of 9600 baud. Due to this my serial gateway is compiled with 9600 baud, to.

    @TimO can you easily add an option for changing the bit rate? If not I will upgrade my running installation of openHAB to 1.7. This way I could user 115200 baud productive and testing.

    edit: just did the update. Will have a look at openhab2 tomorrow.


  • Hero Member

    @kolaf , @Jan-Gatzke : Thanks for testing and your feedback!!

    I've edited the first posting, which now contains the documentation on how to test and I've added a new alpha version (Download) for test.

    The sensors you requested @kolaf are ready for a test. The discovery is working now too, feel free to give it a try.

    @kolaf : I can't work with your server.log. Did you provide the right file? Did you start OpenHAB with "start_debug.sh"?

    Your questions:

    • baud rate of the serial gateway is currently fixed to 115.200. It is easy to add that option but I would like to keep it simple and because it is a little bit hardcoded in the MySensors lib I would like to omit this option. If it is easier for you to test with that option I will add it.

    • Changing the name of a new thing: works for me but this could be a bug in the runtime it is nothing I've implemented in the binding.

    • You should see everything the gateway receives in the debug output. Mine looks like this:

    2015-07-27 18:52:40 [DEBUG] [.p.s.MySensorsSerialConnection:83   ] - 0;0;3;0;14;Gateway startup complete.
    2015-07-27 18:52:40 [DEBUG] [.p.s.MySensorsSerialConnection:83   ] - 172;255;0;0;18;1.4.1
    2015-07-27 18:52:40 [DEBUG] [.m.d.MySensorsDiscoveryService:70   ] - Representation Message received
    2015-07-27 18:52:40 [DEBUG] [.m.d.MySensorsDiscoveryService:71   ] - Preparing new thing for inbox
    2015-07-27 18:52:40 [DEBUG] [.p.s.MySensorsSerialConnection:83   ] - 172;255;3;0;6;0
    2015-07-27 18:52:40 [DEBUG] [.p.s.MySensorsSerialConnection:83   ] - 172;255;3;0;11;Humidity + Temp + Relay
    2015-07-27 18:52:40 [DEBUG] [.p.s.MySensorsSerialConnection:83   ] - 172;255;3;0;12;1.0
    2015-07-27 18:52:40 [DEBUG] [.p.s.MySensorsSerialConnection:83   ] - 172;0;0;0;7;1.4.1
    
    • I've added the S_POWER sensor and tested it with the values you have given @kolaf . Could you please check if it works in your environment too (look at the screenshots of the first posting in this thread)?

    • Also I've added S_BARO. The value that is received by the gateway is shown as a simple string. It is ok for a start, but I would like to change that later (given set of values, change icon in dependency of the state).


  • Hero Member

    @TimO Thank you very much for your excellent work :-).

    I have done some more testing, and I can report that discovery of sensors seems to work flawlessly (at least for the supported types ;-)). I like the change you made to the naming, it makes the default names much more easy to distinguish. As for renaming the elements, I will just have to play a bit around with that on my own, I guess.

    The new types seem to work well, but there is a problem when updating the light switches. It apparently does not like a DecimalType when updating the item. The light switch command looks like this: 6;4;1;0;2;1
    Also, the the updates appear twice in the log which is a bit weird.

    I set up two of my sensors, including a sensor type you have not yet implemented, the distance sensor. Two of the sensor reports looks like this:
    6;5;1;0;13;1.0
    6;5;1;0;13;0.7

    Apart from the small issues I'm very impressed with the implementation :-)

    I apologise for sending you the wrong log, I was not aware of its location in 2.0. Hopefully I should now have attached the right one.
    openhab.log

    This is what the sensors currently look like in my simple setup:
    openhab 2.0 test.png

    Edit: I should mention that switching the sensor on and off from the widgets on the page seems to work correctly, even though it does not report if the sensor is switched using its local interface (hardware interface, a button soldered to the sensor).


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.