Teekanne / openhab

Automatically exported from code.google.com/p/openhab
0 stars 0 forks source link

XBee Bindings #388

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I just finalized XBee bindings: 
http://code.google.com/r/diaoulael-xbee/source/browse#hg%2Fbundles%2Fbinding%2Fo
rg.openhab.binding.xbee

Configuration:

ZNetRxResponse Pattern: 
<(?<responseType>\\w+)@(?<address>([0-9a-zA-Z])+)#(?<pin>[AD][0-9]{1,2})(:(?<tra
nsformation>.*))?
ZNetRxResponse Example: <znetrxresponse@1122334455667788#0
What it does: This will extract bytes starting from byte 0 from the 
ZNetRxResponse from the address 1122334455667788. Bytes must be big endian and 
will be converted to the appropriate type depending on the type of the item. 
Number => DecimalType (4 bytes float), Dimmer => PercentType (1 byte), 
SwitchItem => OnOffType (1 byte), ContactItem => OpenCloseType (1 byte).
Use case: Custom XBee sensor with microcontrollers like arduino and multiple 
inputs. Digital temperature + humidity sensor

ZNetRxIoSampleResponse Pattern: 
<(?<responseType>\\w+)@(?<address>([0-9a-zA-Z])+)#(?<pin>[AD][0-9]{1,2})(:(?<tra
nsformation>.*))?
ZNetRxIoSampleResponse Example: 
<znetrxiosampleresponse@1122334455667788#A0:10*x-0.5
What it does: This will read pin A0 from the ZNetRxIoSampleResponse from the 
address 1122334455667788 and will apply the formula 10*(read value as int 
0-1023)-0.5
Use case: Standalone XBee with analog sensor like an temperature sensor. As the 
XBee has many inputs you can even add a digital sensor like a contact sensor.

Thanks to the low-level implementation it is possible to support more response 
types and more high-level responses like ZNetExplicitRxResponse and hence 
provide ZCL support.

Out bindings aren't supported yet but will work the same way responses do.

I hope this is not too late for 1.3.0 :)

Original issue reported on code.google.com by DiaoulAel on 28 Jul 2013 at 1:38

GoogleCodeExporter commented 9 years ago

Original comment by kai.openhab on 28 Jul 2013 at 2:14

GoogleCodeExporter commented 9 years ago

Original comment by kai.openhab on 7 Aug 2013 at 7:26

GoogleCodeExporter commented 9 years ago

Original comment by teichsta on 13 Aug 2013 at 8:14

GoogleCodeExporter commented 9 years ago
I've just updated the binding in my clone

ZNetRxResponse Pattern: 
"<(?<responseType>\\w+)@(?<address>([0-9a-zA-Z])+)#(?<dataOffset>\\d+)(\\[(?<dat
aType>\\w+)\\])?(:(?<firstByte>\\d{1,3}))?"
Change: It's now possible to specify a dataType for Number items. When 
unpacking, if dataType is float or int, 4 bytes will be read, if it's byte, a 
single one will be read. This allows Dimmer/Contact to fit on a single byte 
(0-255 is enough)
It's also possible to identify each responses as unique using first byte of 
data as "identifier". If different requests comes from the same address, they 
can thus be treated differently.
Use case: Temperature (float) & Humidity (byte) every 30s using firstByte to 0
Presence sensor (byte) every change using firstByte to 1

I'd like to add some wiki pages to describe the binding, how can I do that?

I'm more familiar with GitHub

Original comment by DiaoulAel on 29 Aug 2013 at 11:34

GoogleCodeExporter commented 9 years ago
Hi Antoine,

could you elaborate a bit more on the UseCase/Device this Binding binds to? I 
am a bit unsure if its "just" an implementation of the transport layer or if 
its provide higher level services.

Best,

Thomas E.-E.

Original comment by teichsta on 1 Sep 2013 at 1:58

GoogleCodeExporter commented 9 years ago
Hi,

For now the binding works for custom requests and DIY scenarii.

# Example with Arduino
## Hardware
* An Arduino Fio + XBee module
* Another XBee module to plug into the computer running OpenHab (using this for 
example: https://www.sparkfun.com/products/9819 )
## Software
* Send Tx request from the Arduino to the other XBee with this 
https://code.google.com/p/xbee-arduino/source/browse/trunk/examples/Series2_Tx/S
eries2_Tx.pde on the Arduino
* OpenHab configured to receive ZNetRxResponse on an item
## What it does
This allows everyone willing to build his own sensor to send data to OpenHab. 
Data can be temperature, humidity, range, light, contact, alarm sensor or even 
a combination of all that.

# Using a standalone XBee
## Hardware
* An XBee module
* Another XBee module to plug into the computer running OpenHab (using this for 
example: https://www.sparkfun.com/products/9819 )
## Software
* The XBee module configured to send IO Samples
* OpenHab configured to receive ZNetRxIoSampleResponse
## What it does
XBee modules have analog and digital input pins meaning one can connect basic 
sensors directly to it with no micro controller. Suitable sensors are almost 
the same as previously but its raw data coming from the sensors.
I'd say custom contact sensors are very easy to make with this because XBee can 
be configured to send the state of the sensor every x seconds or whenever the 
state of the digital input changes.

# In the future
## ZCL
It is indeed an implementation of the transport layer for now. I'm planning to 
work on a more higher level interface as I acquire more hardware. Hue uses 
ZigBee Light Link, Netvox (http://www.netvox.com.tw/) sells a great variety of 
sensors.
## Out bindings
Out bindings aren't implemented yet, it is possible to send data to XBees 
wirelessly like turn on/off or do PWM on a remote xbee pin.

Original comment by ant.ber...@gmail.com on 1 Sep 2013 at 3:05

GoogleCodeExporter commented 9 years ago
could you give some example item configurations?

Original comment by teichsta on 1 Sep 2013 at 3:07

GoogleCodeExporter commented 9 years ago
I send a request from 0011223344556677 to the XBee on OpenHAB with temperature 
(as float) encoded on first 4 bytes and read it from OpenHAB with this:
<znetrxresponse@0011223344556677#0[float]

Same thing with humidity on another sensor. Values fits on one byte so it's 
encoded as such, starting from byte 5. First byte is used as identifier and has 
to be 0:
<znetrxresponse@1122334455667788#5[byte]:0

This way I can catch another request from the same sensor into a different 
item. This is a presence sensor so I use a Contact item. First byte is used as 
identifier and has to be 1:
<znetrxresponse@1122334455667788#1:1
I didn't specified the type here, it should be [byte] but this is obvious 
because I read a contact item which has only two states (1 bit).

Now more complex, reading analog input of the XBee directly from the IO Sample 
responses:
<znetrxiosampleresponse@2233445566778899#A0:((x/1024.0)*1.2-0.5)*100
The conversion function's purpose is to transfom the raw analog value (0-1024) 
to actual temperature, using the sensors specification.

HTH

Original comment by ant.ber...@gmail.com on 3 Sep 2013 at 10:15

GoogleCodeExporter commented 9 years ago
due to lack of time on my side this binding won't make it into 1.3.

Anyhow, thanks for this contribution!

Original comment by teichsta on 6 Sep 2013 at 2:48

GoogleCodeExporter commented 9 years ago
Why not delay 1.3 and add in there all finalized contributions?

That's fine by me but if one has to wait another couple of month for a 
finalize-but-not-yet-reviewed binding that's a shame.
Or you can just release it as beta within 1.3? It's a binding, it's optional 
anyway.

Original comment by DiaoulAel on 6 Sep 2013 at 8:20

GoogleCodeExporter commented 9 years ago
I'm slightly disappointed, I was hoping to test some small objects with my 
Openhab ...

Original comment by filg...@gmail.com on 9 Sep 2013 at 7:59

GoogleCodeExporter commented 9 years ago
> I'm slightly disappointed, I was hoping to test some small objects with my 
Openhab ...

Apologies for not having the appropriate time to review and merge into default. 
Anyhow, once the binding is merged into default you'll be able to download the 
binary from our CI-Server. No need to wait until the 1.4 release.

Regards,

Thomas E.-E.

Original comment by teichsta on 9 Sep 2013 at 9:10

GoogleCodeExporter commented 9 years ago
Thomas, thanks for your reply. I understand ! it was just to show interest of 
this bundle ;)

Original comment by filg...@gmail.com on 9 Sep 2013 at 9:59

GoogleCodeExporter commented 9 years ago

Original comment by teichsta on 5 Nov 2013 at 10:53

GoogleCodeExporter commented 9 years ago
This issue has been migrated to Github. If this issue id is greater than103 its 
id has been preserved on Github. You can open your issue by calling the URL 
https://github.com/openhab/openhab/issues/<issueid>. Issues with ids less or 
equal 103 new ids were created.

Original comment by teichsta on 17 Nov 2013 at 8:08

GoogleCodeExporter commented 9 years ago
see above!

Issue has been migrated to Github and should be discussed there.

Original comment by teichsta on 21 Nov 2013 at 1:51

GoogleCodeExporter commented 9 years ago
Hi, are you going to send a PullRequest for this binding? I quickly browsed 
through your code and found the XBeeSerialConnector is no longer valid since 
RXTXPort has changed into a final class. Please see Stick.java in 
org.openhab.binding plugwise how a serial connection can be handled. I'll 
promise to merge the binding into 1.4 if your PR is available on Friday COB. 
Would that be possible? Best, Thomas E.-E.

Original comment by teichsta on 28 Jan 2014 at 8:43