pimatic / pimatic-homeduino

Pimatic plugin for using 433mhz devices and sensors with a connected Arduino with homeduino sketch
https://pimatic.org/
GNU General Public License v2.0
37 stars 29 forks source link

HowTo: Add a new protocol #31

Closed kenci closed 9 years ago

kenci commented 9 years ago

How can i add a new protocol? Is there a tutorial or something similar. I am not good at javascript but i will give my best :)

This is what i get from debug: 19:20:07.231 [pimatic-homeduino] debug: data: "RF receive 1472 490 6956 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 19:20:07.246 [pimatic-homeduino] debug: received: [ 490, 1472, 6956 ] 101001011010010110011010100101011001010101100110101001100101101002

and sometimes this: 19:25:46.176 [pimatic-homeduino] debug: data: "RF receive 496 1471 6924 0 0 0 0 0 011010011010010110101010010101101010011001100110100101100101101002" 19:25:46.207 [pimatic-homeduino] debug: received: [ 496, 1471, 6924 ] 011010011010010110101010010101101010011001100110100101100101101002 19:25:46.670 [pimatic-homeduino] debug: data: "RF receive 495 1467 7036 0 0 0 0 0 011010011010010110101010010101101010011001100110100101100101101002" 19:25:46.681 [pimatic-homeduino] debug: received: [ 495, 1467, 7036 ] 011010011010010110101010010101101010011001100110100101100101101002 19:25:46.881 [pimatic-homeduino] debug: data: "RF receive 498 1468 6920 0 0 0 0 0 011010011010010110101010010101101010011001100110100101100101101002" 19:25:46.893 [pimatic-homeduino] debug: received: [ 498, 1468, 6920 ] 011010011010010110101010010101101010011001100110100101100101101002

Is someone willling to help?

Xento commented 9 years ago

I'm new to protocol developing, but I created a new one for a smokedetector ;-) What device do you want to receive?

kenci commented 9 years ago

It's a door bell like this one Elro DB286A https://www.amazon.de/dp/B005DDYL1I/ref=cm_sw_r_awd_8UK5ub1TAETZ7

Markus notifications@github.com schrieb am Do., 19. Feb. 2015 21:37:

I'm new to protocol developing, but I created a new one for a smokedetector ;-) What device do you want to receive?

— Reply to this email directly or view it on GitHub https://github.com/pimatic/pimatic-homeduino/issues/31#issuecomment-75131014 .

Xento commented 9 years ago

You could copy the https://github.com/pimatic/rfcontroljs/blob/master/lib/protocols/pir2.js and name it pir3.js and place it in the same folder. To be loaded you have to edit controler.js in the directory above and add pir3 as protocol. Now you have to edit the pir3.js and change the pulseleghths to yours: pulseLengths: [451, 1402, 14356] to pulseLength: [ 496, 1471, 6924 ] You get 54 digits so your pulseCount is 54 Now you could try to decode the message so that you get something to identify your doorbell. Because I don't know the protocol and I think you only have one doorbell you could leave the decoding as it is. Look at the changed files in my branch:https://github.com/Xento/rfcontroljs/tree/added-ELRO-DB286A-doorbell You have to place them here: /usr/local/pimatic-app/node_modules/pimatic-homeduino/node_modules/homeduino/node_modules/rfcontroljs/lib

kenci commented 9 years ago

I will try tomorrow, thank you very much.

Markus notifications@github.com schrieb am Do., 19. Feb. 2015 22:13:

You could copy the https://github.com/pimatic/rfcontroljs/blob/master/lib/protocols/pir2.js and name it pir3.js and place it in the same folder. To be loaded you have to edit controler.js in the directory above and add pir2 as protocol. Now you have to edit the pir3.js and change the pulseleghths to yours: pulseLengths: [451, 1402, 14356] to pulseLength: [ 496, 1471, 6924 ] You get 54 digits so your pulseCount is 54 Now you could try to decode the message so that you get something to identify your doorbell. Because I don't know the protocol and I think you only have one doorbell you could leave the decoding as it is. Look at the changed files in my branch: https://github.com/Xento/rfcontroljs/tree/added-ELRO-DB286A-doorbell You have to place them here: /usr/local/pimatic-app/node_modules/pimatic-homeduino/node_modules/homeduino/node_modules/rfcontroljs/lib

— Reply to this email directly or view it on GitHub https://github.com/pimatic/pimatic-homeduino/issues/31#issuecomment-75137085 .

sweetpi commented 9 years ago

The official tutorial can be found here: https://github.com/pimatic/rfcontroljs#adding-a-new-protocol

Best is to edit the coffeescript files instead and use gulp to update the js files. But for me its ok if you edit the js file and I convert it back to coffeescript.

kenci commented 9 years ago

@Xento Where do you get the pulse count (54) from? If i count the data i received i get 66 bits

Xento commented 9 years ago

Uh, maybe copy&paste mistake. Your are right.

kenci commented 9 years ago

So, i copied controller.js and pir3.js to the dirs, added a new pir3 device, but nothing happens when i press the button.

18:05:58.827 [pimatic-homeduino] debug: data: "RF receive 498 1468 620 6944 0 0 0 0 011010011010010110101010010101101010011001100112100101100101101003" 18:05:58.840 [pimatic-homeduino] debug: received: [ 498, 620, 1468, 6944 ] 022020022020020220202020020202202020022002200221200202200202202003 18:05:59.863 [pimatic-homeduino] debug: data: "RF receive 1479 482 560 6908 0 0 0 0 010120200101202001200101011010100110101010011001010110011010010113" 18:05:59.877 [pimatic-homeduino] debug: received: [ 482, 560, 1479, 6908 ] 202012122020121220122020200202022002020202200220202002200202202003 18:06:00.075 [pimatic-homeduino] debug: data: "RF receive 1478 493 6948 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:06:00.088 [pimatic-homeduino] debug: received: [ 493, 1478, 6948 ] 101001011010010110011010100101011001010101100110101001100101101002 18:06:00.288 [pimatic-homeduino] debug: data: "RF receive 1477 494 6944 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:06:00.300 [pimatic-homeduino] debug: received: [ 494, 1477, 6944 ] 101001011010010110011010100101011001010101100110101001100101101002 18:06:00.501 [pimatic-homeduino] debug: data: "RF receive 1478 492 6940 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:06:00.514 [pimatic-homeduino] debug: received: [ 492, 1478, 6940 ] 101001011010010110011010100101011001010101100110101001100101101002 18:06:00.714 [pimatic-homeduino] debug: data: "RF receive 1477 494 6944 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:06:00.727 [pimatic-homeduino] debug: received: [ 494, 1477, 6944 ] 101001011010010110011010100101011001010101100110101001100101101002 18:06:02.352 [pimatic-homeduino] debug: data: "RF receive 500 1471 6956 0 0 0 0 0 011010011010010110101010010101101010011001100110100101100101101002" 18:06:02.366 [pimatic-homeduino] debug: received: [ 500, 1471, 6956 ] 011010011010010110101010010101101010011001100110100101100101101002 18:06:02.565 [pimatic-homeduino] debug: data: "RF receive 502 1468 6952 0 0 0 0 0 011010011010010110101010010101101010011001100110100101100101101002" 18:06:02.580 [pimatic-homeduino] debug: received: [ 502, 1468, 6952 ] 011010011010010110101010010101101010011001100110100101100101101002 18:06:02.779 [pimatic-homeduino] debug: data: "RF receive 500 1470 6940 0 0 0 0 0 011010011010010110101010010101101010011001100110100101100101101002" 18:06:02.793 [pimatic-homeduino] debug: received: [ 500, 1470, 6940 ] 011010011010010110101010010101101010011001100110100101100101101002 18:06:02.992 [pimatic-homeduino] debug: data: "RF receive 500 1470 6944 0 0 0 0 0 011010011010010110101010010101101010011001100110100101100101101002" 18:06:03.006 [pimatic-homeduino] debug: received: [ 500, 1470, 6944 ] 011010011010010110101010010101101010011001100110100101100101101002 18:06:13.754 [pimatic-homeduino] debug: data: "RF receive 1478 493 6944 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:06:13.767 [pimatic-homeduino] debug: received: [ 493, 1478, 6944 ] 101001011010010110011010100101011001010101100110101001100101101002 18:06:13.967 [pimatic-homeduino] debug: data: "RF receive 1476 494 6976 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:06:13.981 [pimatic-homeduino] debug: received: [ 494, 1476, 6976 ] 101001011010010110011010100101011001010101100110101001100101101002 18:06:14.182 [pimatic-homeduino] debug: data: "RF receive 1478 492 6956 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:06:14.196 [pimatic-homeduino] debug: received: [ 492, 1478, 6956 ] 101001011010010110011010100101011001010101100110101001100101101002

I get only this on debug.

Why are the pulse lengths different every time i press the button on my door bell?

Xento commented 9 years ago

The pulselength are always a bit different but pimatic accepts them, too. I updated the file, there were two mistakes

  1. the name
  2. the pulsecount

Did you add the pir3 in controler.js?

kenci commented 9 years ago

Yes, and i changed the name to pir3 in pir3.js file.

Config { "id": "homeduino-pir", "name": "Klingel", "class": "HomeduinoRFPir", "protocols": [ { "name": "pir3" } ], "resetTime": 6000 },

Xento commented 9 years ago

Do you see any messages, that there is no protocol pir3 or something else when you start pimatic in console mode?

kenci commented 9 years ago

Nothing. Name of device is "Klingel" and is loaded 18:02:02.773 2015-02-20 Friday 18:02:15.047 [pimatic] info: Starting pimatic version 0.8.45 18:02:21.639 [pimatic] info: loading plugin: "pimatic-cron" (0.8.5) 18:02:23.941 [pimatic] info: loading plugin: "pimatic-mobile-frontend" (0.8.44) 18:02:29.143 [pimatic] info: loading plugin: "pimatic-homeduino" (0.8.41) 18:02:30.720 [pimatic] info: loading plugin: "pimatic-sunrise" (0.8.0) 18:02:30.928 [pimatic] info: loading plugin: "pimatic-ping" (0.8.3) 18:02:31.180 [pimatic] info: loading plugin: "pimatic-shell-execute" (0.8.6) 18:02:31.549 [pimatic] info: loading plugin: "pimatic-mail" (0.8.2) 18:02:33.434 [pimatic-cron] info: the time is: Fri Feb 20 2015 18:02:33 GMT+0100 (CET) 18:02:34.355 [pimatic-sunrise] info: Your location is set to lat: 47.1992, long: 9.702 18:02:35.059 [pimatic] info: new device "WZ Jalousie Links"... 18:02:35.359 [pimatic] info: new device "WZ Jalousie Rechts"... 18:02:35.616 [pimatic] info: new device "WZ Terrassentuer Links"... 18:02:35.854 [pimatic] info: new device "WZ Subwoofer"... 18:02:35.959 [pimatic] info: new device "WZ Steckdose hinten"... 18:02:36.065 [pimatic] info: new device "Klingel"... 18:02:36.166 [pimatic] info: new device "Kueche Jalousie"... 18:02:36.263 [pimatic] info: new device "HR Homecinema"... 18:02:36.362 [pimatic] info: new device "TEST Steckdose"... 18:02:36.501 [pimatic] info: new device "RPi Pool"... 18:02:36.608 [pimatic] info: new device "Naira"... 18:02:36.699 [pimatic] info: new device "Kenan"... 18:02:36.791 [pimatic] info: new device "Kamera Vorplatz"... 18:02:36.881 [pimatic] info: new device "Kamera Terrasse"... 18:02:37.003 [pimatic] info: new device "Alarmanlage"... 18:02:37.120 [pimatic] info: new device "Filteranlage"... 18:02:37.229 [pimatic] info: new device "Filteranlage-Modus"... 18:02:37.403 [pimatic] info: new device "Alarmanlage-Modus"... 18:02:37.500 [pimatic] info: new device "Filterpumpe"... 18:02:38.500 [pimatic] info: new device "Solarsteuerung"... 18:02:38.619 [pimatic] info: new device "Bodenreinigung"... 18:02:38.710 [pimatic] info: new device "Alarmanlage"... 18:03:37.696 [pimatic] info: rule system-alarmanlage-aktivieren: Alarmanlage wurde aktiviert! 18:03:39.343 [pimatic-mobile-frontend] info: packing static assets 18:03:41.192 [pimatic-mobile-frontend] info: packing static assets finished 18:03:41.229 [pimatic-mobile-frontend] info: rendering html 18:04:08.452 [pimatic-mobile-frontend] info: rendering html finished 18:04:08.615 [pimatic] info: listening for http-request on port 1607... 18:04:08.786 [pimatic-homeduino] debug: data: "ready" 18:04:08.805 [pimatic-homeduino] debug: data: "PING" 18:04:08.823 [pimatic-homeduino] info: Connected to homeduino device. 18:04:08.941 [pimatic-homeduino] debug: data: "ACK" 18:04:08.957 [pimatic-homeduino] debug: Receiving on pin 0 18:04:28.483 [pimatic-homeduino] debug: data: "RF receive 1477 492 6976 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:04:28.538 [pimatic-homeduino] debug: received: [ 492, 1477, 6976 ] 101001011010010110011010100101011001010101100110101001100101101002 18:04:28.696 [pimatic-homeduino] debug: data: "RF receive 1477 493 6956 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:04:28.712 [pimatic-homeduino] debug: received: [ 493, 1477, 6956 ] 101001011010010110011010100101011001010101100110101001100101101002 18:04:28.910 [pimatic-homeduino] debug: data: "RF receive 1478 492 6940 0 0 0 0 0 010110100101101001100101011010100110101010011001010110011010010112" 18:04:28.921 [pimatic-homeduino] debug: received: [ 492, 1478, 6940 ] 101001011010010110011010100101011001010101100110101001100101101002

Xento commented 9 years ago

I changed the decoding. If this doesn't work I don't know whats going wrong. https://github.com/Xento/rfcontroljs/commit/084a63895eece835f626278e5ec1200b05ac2f75

kenci commented 9 years ago

Thank you very much, Markus! It works now. You helped me a lot, thanks. +1 20:19:15.347 [pimatic-homeduino] debug: data: "RF receive 498 1470 6952 0 0 0 0 0 011010011010010110101010010101101010011001100110100101100101101002" 20:19:15.361 [pimatic-homeduino] debug: received: [ 498, 1470, 6952 ] 011010011010010110101010010101101010011001100110100101100101101002 20:19:15.373 [pimatic-homeduino] debug: pir3: { unit: '10010011000011100010101001101100', presence: true } 20:19:15.398 [pimatic] info: rule system-tuerklingel: Es hat geklingelt

Xento commented 9 years ago

Now you could add the ID to your config, so you could use multiple doorbells at the same time: { "id": "homeduino-pir", "name": "Klingel", "class": "HomeduinoRFPir", "protocols": [ { "name": "pir3" } ], "resetTime": 6000, unit: "10010011000011100010101001101100"},

kenci commented 9 years ago

Brilliant! Actually, it's really easy to add a new protocol if you know what to do +1:

Danke!

Markus notifications@github.com schrieb am Fr., 20. Feb. 2015 20:30:

Now you could add the ID to your config, so you could use multiple doorbells at the same time: { "id": "homeduino-pir", "name": "Klingel", "class": "HomeduinoRFPir", "protocols": [ { "name": "pir3" } ], "resetTime": 6000, unit: "10010011000011100010101001101100"},

— Reply to this email directly or view it on GitHub https://github.com/pimatic/pimatic-homeduino/issues/31#issuecomment-75303635 .

KlausFeld commented 9 years ago

Hi,

i don't understand how the protocol Definition works, sorry. Is there a better tutorial availble?

I can Switch some selflearning plugs with this code:

outlets['AON']="330 4940 330 1000 320 1010 970 360 320 1010 310 1010 970 370 320 1010 970 360 320 1010 970 370 960 370 960 360 320 1010 970 380 310 1020 300 1020 960 370 960 380 310 1020 960 370 310 1010 970 380 300 1030 950 380 300 1020 960 380 950 370 310 1020" outlets['AOFF']="320 4950 330 1000 320 1010 970 360 320 1010 320 1000 980 370 310 1010 320 1020 310 1010 970 370 320 1010 970 360 970 360 310 1030 960 370 960 360 970 360 320 1020 320 1010 970 360 310 1020 310 1040 300 1020 310 1020 310 1010 970 370 960 370 310 1020" outlets['BON']="330 4950 320 1010 320 1000 980 350 330 1010 310 1010 980 360 320 1010 320 1010 320 1010 970 370 970 360 320 1010 970 360 970 370 970 360 310 1030 950 370 960 380 310 1020 960 370 310 1020 960 370 320 1020 310 1010 310 1020 960 380 310 1010 960 370" outlets['BOFF']="320 4950 320 1010 320 1000 980 350 330 1000 320 1020 960 370 320 1020 310 1010 970 360 970 370 970 360 970 360 960 370 310 1030 310 1020 310 1020 960 360 970 370 310 1030 300 1020 310 1020 310 1030 310 1020 960 370 960 370 960 370 310 1010 970 370" outlets['CON']="320 4950 980 350 970 360 970 360 320 1010 320 1010 970 370 960 370 310 1020 310 1020 310 1030 960 360 970 360 970 370 300 1030 960 370 310 1020 960 370 960 390 950 370 310 1020 960 370 300 1040 300 1030 950 380 300 1030 300 1030 300 1020 960 370" outlets['COFF']="320 4950 970 360 970 360 970 360 310 1020 310 1010 970 370 970 360 970 360 970 360 320 1030 960 360 970 370 950 370 310 1040 950 370 960 370 310 1020 310 1030 960 370 960 370 300 1030 300 1030 960 370 960 370 310 1030 950 380 300 1020 960 370"

It's a Shell script that work fine. But how to implement it in pimatic?

Thats the debug from pimatic:

• 23:21:24debug [pimatic-homeduino]: received: [ 377, 1045, 4979 ] 1010100101101001010110101001100110101001100101100101011002 • 23:21:24debug [pimatic-homeduino]: data: "RF receive 1045 377 4979 0 0 0 0 0 0101011010010110101001010110011001010110011010011010100112" • 23:21:24debug [pimatic-homeduino]: received: [ 383, 561, 1093, 4977 ] 2020200202202002020221202002200220202002200202200202022003 • 23:21:24debug [pimatic-homeduino]: data: "RF receive 1093 383 561 4977 0 0 0 0 0101011010010110101002010110011001010110011010011010100113" • 23:21:24debug [pimatic-homeduino]: received: [ 369, 1030, 4988 ] 1010100101101001010110101001100110101001100101100101011002 • 23:21:24debug [pimatic-homeduino]: data: "RF receive 1030 369 4988 0 0 0 0 0 0101011010010110101001010110011001010110011010011010100112" • 23:21:24debug [pimatic-homeduino]: received: [ 372, 1035, 4983 ] 1010100101101001010110101001100110101001100101100101011002 • 23:21:24debug [pimatic-homeduino]: data: "RF receive 1035 372 4983 0 0 0 0 0 0101011010010110101001010110011001010110011010011010100112"

Gerne auch auf Deutsch ;-)

Thx Klaus