Doorbird bell + Velbus installation

Hello,

As i’m trying again to get some stuff working with each other i have (again) a problem.
My doorbel (dingdong) is connected to a Velbus relay output. So if i switch this relay on, it does “ding” if i switch it of, is does “dong” :grinning:

My button at the front door is connected to a Velbus input module. So in Velbuslink, i configured it so when i push the button, the relay goes on 1 second, off 1 second and this repeats 2 times. So i get “ding, dong, ding, dong”.

Since a couple of months i have a doorbird installed on my eletric gate.
Now i want to make the button of the doorbird also make my doorbel do “ding dong” but only once so i can know the difference between front door and gate.

I made a rule:

rule "Timer Doorbird bel"
when 
Channel 'doorbird:d210x:8c76aea5:doorbell' triggered PRESSED
then
    GF_Deurbel.sendCommand (ON)
    createTimer(now.plusSeconds(2), GF_Deurbel.sendCommand (OFF))
end

and this works, but when i look at the log from the Karaf console with

log:tail

i get the following output:

14:48:20.440 [INFO ] [smarthome.event.ChannelTriggeredEvent] - doorbird:d210x:xxxxxx:doorbell triggered PRESSED
14:48:20.625 [ERROR] [runtime.internal.engine.RuleEngineImpl] - Rule 'Timer Doorbird bel': null
14:48:20.642 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'GF_Deurbel' received command ON
14:48:20.651 [INFO ] [smarthome.event.ItemStatePredictedEvent] - GF_Deurbel predicted to become ON
14:48:20.689 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'GF_Deurbel' received command OFF
14:48:20.695 [INFO ] [smarthome.event.ItemStateChangedEvent] - GF_Deurbel changed from OFF to ON
14:48:20.701 [INFO ] [smarthome.event.ItemStatePredictedEvent] - GF_Deurbel predicted to become OFF
14:48:20.724 [INFO ] [smarthome.event.ItemStateChangedEvent] - GF_Deurbel changed from ON to OFF
14:48:20.731 [INFO ] [smarthome.event.ItemStateChangedEvent] - GF_Deurbel changed from OFF to ON
14:48:20.751 [INFO ] [smarthome.event.ItemStateChangedEvent] - GF_Deurbel changed from ON to OFF

What could be the reason of the ERROR? And why is the doorbel going on and off twice?

Many thanks in advance

1 Like

Try:

rule "Timer Doorbird bel"
when 
Channel 'doorbird:d210x:8c76aea5:doorbell' triggered PRESSED
then
    if ( GF_Deurbel.state == OFF ){
        GF_Deurbel.sendCommand (ON)
        createTimer(now.plusSeconds(2)) [ |
        GF_Deurbel.sendCommand (OFF)
        ]
    }
end
1 Like

The DSL rule solution provided by @H102 is by far the easiest solution.

If you want to really over complicate the solution, but explore more options within your Velbus setup, you might want to look at the NodeRed Function code that I have just “hacked” together.

You could inject a 1 second timer into the function when the gate door bell is triggered?

However you might need to add an openHAB2 events node to detect the Pressed event

you’ll need to adapt this

[
    {
        "id": "d1244c28.d3e51",
        "type": "function",
        "z": "1233381f.cbcdb8",
        "name": "DoorBird event",
        "func": "var event = msg.payload.event;\nvar channel = msg.payload.channel;\nvar newMsg = { payload: msg.payload.event };\nvar button = \"doorbird:d210x:8c76aea5:doorbell\"\n\nif  (channel === button )  {\n\tif (event === \"PRESSED\") {\n\t\treturn [msg, newMsg, null, null];\n\t}\n\tif (event === \"LONG_PRESSED\") {\n\t\treturn [msg, null, newMsg, null];\n\t}\n\tif (event === \"RELEASED\") {\n\t\treturn [msg, null, null, newMsg];\n\t}\n}\nreturn null;",
        "outputs": 4,
        "noerr": 0,
        "x": 1860,
        "y": 300,
        "wires": [
            [],
            [
                "e2f22471.595168"
            ],
            [],
            []
        ],
        "outputLabels": [
            "Whole Msg",
            "PRESSED",
            "LONG_PRESSED",
            "RELEASED"
        ]
    },
    {
        "id": "e2f22471.595168",
        "type": "change",
        "z": "1233381f.cbcdb8",
        "name": "Start 1 second timer",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2100,
        "y": 300,
        "wires": [
            [
                "29389d4b.a45f02"
            ]
        ]
    },
    {
        "id": "29389d4b.a45f02",
        "type": "function",
        "z": "1233381f.cbcdb8",
        "name": "Set channel of Velbus Relay",
        "func": "var address = \"74\"; // Hex address of Relay\nvar channel = \"04\"; // Hex value of Channel No 3 of relay, derived from a bit array = 00100 (as in =bin2hex(00100) in a spreadsheet )\n\n\n\n\n\n// 01 = OFF, 02 = ON, 03 = Timer start\nvar eop = \"04\";\n\nvar a = '0f', b = 'f8', c = address, d = '02', e = '02', f = channel, g = '00', h =\"00\", i = \"00\", y = 'ff';\nvar ndigits = 2, x, carry = 0, z, checksum = \"\";\n\n\nvar incoming = String(msg.payload);\nvar buffer = \"\"\n\n\nvar newMsg =  { payload:incoming };\n\n\nif  (incoming == \"ON\" )  {\n    \n    command = \"02\"; // ON\n    c = address;\n    e = command;\n    f = channel;\n    \nfor (x = ndigits - 1; x >= 0; x--) {\n  z = parseInt(a[x], 16) + parseInt(b[x], 16)+ parseInt(c[x], 16)+ parseInt(d[x], 16)+ parseInt(e[x], 16)+ parseInt(f[x], 16) + carry;\n  carry = z >> 4;\n  checksum = (z & 15).toString(16) + checksum;\n}\n checksum = ((parseInt(y, 16) - parseInt(checksum, 16))+1).toString(16)\n   \n    \n\nnewMsg.payload = checksum;\n\n    \n    \n    \n    \n    \n// Format Pressed event\n// buffer = Buffer.from( [0x0F,0xF8,0x74,0x05,0x03,0x04,0x00,0x00,0x05,0x74,0x04] );\n\nbuffer = Buffer.from([\"0x\"+a.toString(16),\"0x\"+b.toString(16),\"0x\"+c.toString(16),\"0x\"+d.toString(16),\"0x\"+e.toString(16),\"0x\"+f.toString(16),\"0x\"+checksum,0x04])\nreturn [{payload:buffer},newMsg];\n\n\n\t}\n\n\nif  (incoming == \"OFF\" )  {\n    \n command = \"01\"; // OFF\n    c = address;\n    d = size;\n    e = command;\n    f = channel;\n    \n\nfor (x = ndigits - 1; x >= 0; x--) {\n  z = parseInt(a[x], 16) + parseInt(b[x], 16)+ parseInt(c[x], 16)+ parseInt(d[x], 16)+ parseInt(e[x], 16)+ parseInt(f[x], 16) + carry;\n  carry = z >> 4;\n  checksum = (z & 15).toString(16) + checksum;\n}\n checksum = ((parseInt(y, 16) - parseInt(checksum, 16))+1).toString(16)\n   \n    \n\n newMsg.payload = checksum;\n\n\n\nbuffer = Buffer.from([\"0x\"+a.toString(16),\"0x\"+b.toString(16),\"0x\"+c.toString(16),\"0x\"+d.toString(16),\"0x\"+e.toString(16),\"0x\"+f.toString(16),\"0x\"+checksum,0x04])\nreturn [{payload:buffer},newMsg];\n\n\n\t}\n\t\n\t\n\t// Timer value less than 255 seconds\nif  (incoming >= 0 )   { if (incoming <=255) {\n    \n command = \"03\"; // Start Timer\n    c = address;\n    d = \"05\"; // Size\n    e = command;\n    f = channel;\n    i = incoming.toString(16) // Duration of timer in seconds\n    \n\n\n    checksum = parseInt(a, 16) + parseInt(b, 16)+ parseInt(c, 16)+ parseInt(d, 16)+ parseInt(e, 16)+ parseInt(f, 16)+ parseInt(g, 16)+ parseInt(h, 16)+ parseInt(i, 16);\n    checksum = checksum.toString(16);\n    checksum = (parseInt(\"FFFF\",16) - parseInt(checksum,16));\n    checksum = (parseInt(checksum,10)) + 257;\n    checksum = checksum.toString(16);\n    checksum = checksum.slice(-2);\n\n\n newMsg.payload = checksum;\n\n\n\nbuffer = Buffer.from([\"0x\"+a.toString(16),\"0x\"+b.toString(16),\"0x\"+c.toString(16),\"0x\"+d.toString(16),\"0x\"+e.toString(16),\"0x\"+f.toString(16),\"0x\"+g.toString(16),\"0x\"+h.toString(16),\"0x\"+i.toString(16),\"0x\"+checksum,0x04])\nreturn [{payload:buffer},newMsg];\n\n\n\t}}\n\t\n\t\t// Timer value more than 255 seconds and less than 63535 seconds\nif  (incoming >= 255 )   { if (incoming <=63535) {\n    \n command = \"03\"; // Start Timer\n    c = address;\n    d = \"05\"; // Size\n    e = command;\n    f = channel;\n    h = incoming - 255\n    i = (incoming - h).toString(16) // Duration of timer in seconds\n    \n\n\n    checksum = parseInt(a, 16) + parseInt(b, 16)+ parseInt(c, 16)+ parseInt(d, 16)+ parseInt(e, 16)+ parseInt(f, 16)+ parseInt(g, 16)+ parseInt(h, 16)+ parseInt(i, 16);\n    checksum = checksum.toString(16);\n    checksum = (parseInt(\"FFFF\",16) - parseInt(checksum,16));\n    checksum = (parseInt(checksum,10)) + 257;\n    checksum = checksum.toString(16);\n    checksum = checksum.slice(-2);\n\n\n newMsg.payload = checksum;\n\n\n\nbuffer = Buffer.from([\"0x\"+a.toString(16),\"0x\"+b.toString(16),\"0x\"+c.toString(16),\"0x\"+d.toString(16),\"0x\"+e.toString(16),\"0x\"+f.toString(16),\"0x\"+g.toString(16),\"0x\"+h.toString(16),\"0x\"+i.toString(16),\"0x\"+checksum,0x04])\nreturn [{payload:buffer},newMsg];\n\n\n\t}}\n\t\n\tif  (incoming >= 63535 )   {\n\t    newMsg.payload =\"\";\n\t    msg.payload =\"\";\n\t    return;\n\t}\n\t\nreturn [msg,newMsg];",
        "outputs": 2,
        "noerr": 0,
        "x": 2140,
        "y": 180,
        "wires": [
            [
                "1a157d79.4959a3",
                "19e87fb3.6b71e"
            ],
            [
                "760977c6.8a7fd8"
            ]
        ],
        "outputLabels": [
            "Payload, Buffer value to TCP port",
            "Checksum in HEX"
        ]
    },
    {
        "id": "1a157d79.4959a3",
        "type": "debug",
        "z": "1233381f.cbcdb8",
        "name": "Full TCP Buffer content",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2410,
        "y": 120,
        "wires": []
    },
    {
        "id": "760977c6.8a7fd8",
        "type": "debug",
        "z": "1233381f.cbcdb8",
        "name": "Velbus packet Checksum",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2410,
        "y": 260,
        "wires": []
    },
    {
        "id": "8f1c0497.da7398",
        "type": "inject",
        "z": "1233381f.cbcdb8",
        "name": "",
        "topic": "",
        "payload": "ON",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 1810,
        "y": 140,
        "wires": [
            [
                "29389d4b.a45f02"
            ]
        ]
    },
    {
        "id": "66c78a16.50a5e4",
        "type": "inject",
        "z": "1233381f.cbcdb8",
        "name": "",
        "topic": "",
        "payload": "OFF",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 1810,
        "y": 180,
        "wires": [
            [
                "29389d4b.a45f02"
            ]
        ]
    },
    {
        "id": "c11edda3.df313",
        "type": "inject",
        "z": "1233381f.cbcdb8",
        "name": "Timer value in seconds",
        "topic": "",
        "payload": "32",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 1840,
        "y": 220,
        "wires": [
            [
                "29389d4b.a45f02"
            ]
        ]
    },
    {
        "id": "19e87fb3.6b71e",
        "type": "tcp out",
        "z": "1233381f.cbcdb8",
        "host": "127.0.0.1",
        "port": "6000",
        "beserver": "client",
        "base64": false,
        "end": true,
        "name": "Velserv OUT",
        "x": 2650,
        "y": 180,
        "wires": []
    },
    {
        "id": "afdfc27f.f346d",
        "type": "comment",
        "z": "1233381f.cbcdb8",
        "name": "Link the input to the openhAB events node",
        "info": "Use an openHAB2 V2 (v1.1.17) events node here",
        "x": 1580,
        "y": 300,
        "wires": []
    }
]