Hello
Happy new year to you.
I’m glad to hear that the DSL rules are working for you.
As far as sending “Button events” back into Velbus from openHAB2, that isn’t possible right now.
At least, not through the Velbus binding.
I have worked out how to send a mimicking packet from NodeRed using a TCP node.
If that is something you’d like to play with ?
I would assume that there is a way to send a TCP packet to VelServ using the TCP / UDP binding in openHAB2, but I haven’t got my head around that yet.
What I do know is that you may need to send just a “Button Pressed” packet, but ideally follow it with a “Button Released” packet (just for compliance with the protocol)
Or you may need to send a “Button Pressed” packet, followed by “Button Long Pressed” packet, later followed with a “Button Released” packet, depending on how you have setup your scenes in VelbusLink.,
I have tested the following with a button from a VMB8PBU, which was programmed in VelbusLink with a “Up/Down” action on a VMB2BLE motor controller.
Just issuing a “Button Pressed” packet was enough to start and stop the VMB2BLE.
What happens with other modules will be a matter for you to explore.
Here is what I did.
I opened VelbusLink logging and isolated the VMB8PBU packets by using the filter
packet.addr==$A0
Then I Pressed, Long Pressed and Released Button 7 of the VMB8PBU (I did it from within VelbusLink, using the Operate function)
Which gave me this
The first Button Status is the “Press”
Second Button Status is the “Long Press”
Third Button Status is the “Released”
You’ll note that H40 pops up in all three strings, at different places.
H40 is derived from Bin 01000000, which indicated that Button 7 is in play.
So equally, H01 would mean Button 1, from Bin 00000001
By highlighting the first Button Status and clicking on “USE”, followed by “Check Sum”
I was able to highlight and copy the “RAW packet”
This gave me these three HEX strings
Press 0F F8 A0 04 00 40 00 00 15 04
Long press 0F F8 A0 04 00 00 00 40 15 04
Release 0F F8 A0 04 00 00 40 00 15 04
By using an Inject Node and an OutGoing TCP node in NodeRed, I was able to trigger the VMB2BLE as if I were pressing button 7 on the VMB8PBU
The BIG issue I found (and it may be possible to bypass this step if you know more about NodeRed than I do) is that I couldn’t simply paste in the HEX string into the Inject node.
I had to convert the HEX packet into something that NodeRed would convert (correctly) back into exactly the same HEX string.
I used a Google Drive sheet to convert the HEX string from VelbusLink into a formatted TEXT string.
Something like this
I’ve put that spreadsheet in a ZIP file here in Open Document and Excel formats.
The flow I used in NodeRed is this, which you can simply import into your own NodeRed instance, assuming that you have VelServ running on the same machine, on port 6000
[
{
"id": "42f5ffcd.151f3",
"type": "comment",
"z": "cfdce1d.4428b2",
"name": "8PBU button 8",
"info": "Press 0F F8 A0 04 00 40 00 00 15 04\nLong press 0F F8 A0 04 00 00 00 40 15 04\nRelease 0F F8 A0 04 00 00 40 00 15 04",
"x": 460,
"y": 160,
"wires": []
},
{
"id": "a30a7b05.702d98",
"type": "tcp out",
"z": "cfdce1d.4428b2",
"host": "127.0.0.1",
"port": "6000",
"beserver": "client",
"base64": false,
"end": true,
"name": "Velserv OUT",
"x": 840,
"y": 240,
"wires": []
},
{
"id": "e2810117.a6b88",
"type": "tcp in",
"z": "cfdce1d.4428b2",
"name": "",
"server": "client",
"host": "127.0.0.1",
"port": "6000",
"datamode": "stream",
"datatype": "buffer",
"newline": "",
"topic": "",
"base64": false,
"x": 180,
"y": 300,
"wires": [
[
"47871c2b.681744"
]
]
},
{
"id": "47871c2b.681744",
"type": "debug",
"z": "cfdce1d.4428b2",
"name": "",
"active": true,
"tosidebar": false,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"x": 410,
"y": 300,
"wires": []
},
{
"id": "1f59345f.b397cc",
"type": "inject",
"z": "cfdce1d.4428b2",
"name": "Pressed",
"topic": "",
"payload": "[15,248,160,4,0,64,0,0,21,4]",
"payloadType": "bin",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 595,
"y": 200,
"wires": [
[
"a30a7b05.702d98"
]
],
"l": false
},
{
"id": "8e7383d0.c541b",
"type": "inject",
"z": "cfdce1d.4428b2",
"name": "Released",
"topic": "",
"payload": "[15,248,160,4,0,0,64,0,21,4]",
"payloadType": "bin",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 595,
"y": 240,
"wires": [
[
"a30a7b05.702d98"
]
],
"l": false
}
]
Looking into this further, I discovered that it is possible to use a Function node to format the VelServ packet, and get triggered by different Payload content.
For example, I created a Function node that can output the 3 different button events, based on a payload containing matching text.
Which means that by using a couple of Delay nodes and Change nodes, you could automate the sending of the correct sequence of Button events to correctly match your requirements.
IE
- Pressed
- Long_Pressed
- Released
You will just have to work out the correct sequence of Button Events to trigger your scene and release all modules (IE, Don’t Leave them waiting for a “Button Released” event)
Please note that I have added 2 variables to the Function node so that you can easily adapt it for your use.
- address
- button
These need to the the Decimal version of the HEX command you wish to send, whereas the rest of the string you see in the function is made up of HEX .
This might help you a little further
[
{
"id": "60e3ffbc.83dd9",
"type": "function",
"z": "cfdce1d.4428b2",
"name": "Send Button Events to VelServ",
"func": "var button = 64; // Decimal of Hex 40, which is button No 7 only (Different numbers are generated if multiple buttons are pressed). Note Dec 64 is derived from the Binary state 01000000 indicating button 7\nvar address = 160; // Decimal of Hex A0\n\nvar incoming = String(msg.payload);\nvar buffer = \"\"\n\nif (incoming == \"Pressed\" ) {\n// Format Pressed event\nbuffer = Buffer.from( [0x0F, 0xF8, address, 0x04, 0x00, button, 0x00, 0x00, 0x15, 0x04] );\nreturn {payload:buffer};\n\t}\n\nif (incoming == \"Released\" ) {\n// Format Released event\nbuffer = Buffer.from( [0x0F, 0xF8, address, 0x04, 0x00, 0x00, button, 0x00, 0x15, 0x04] );\nreturn {payload:buffer};\n\t}\n\t\nif (incoming == \"Long_Pressed\" ) {\n// Format Long_Pressed event\nbuffer = Buffer.from( [0x0F, 0xF8, address, 0x04, 0x00, 0x00, 0x00, button, 0x15, 0x04] );\nreturn {payload:buffer};\n\t}\t\n\t\n\treturn [msg];\n\n\n// Press of Button 7 0F F8 A0 04 00 40 00 00 15 04\n// Long press of Button 7 0F F8 A0 04 00 00 00 40 15 04\n// Release of Button 7 0F F8 A0 04 00 00 40 00 15 04",
"outputs": 1,
"noerr": 0,
"x": 630,
"y": 400,
"wires": [
[
"a30a7b05.702d98",
"bad326f4.ddade8"
]
]
},
{
"id": "a30a7b05.702d98",
"type": "tcp out",
"z": "cfdce1d.4428b2",
"host": "127.0.0.1",
"port": "6000",
"beserver": "client",
"base64": false,
"end": true,
"name": "Velserv OUT",
"x": 970,
"y": 220,
"wires": []
},
{
"id": "6ffad126.388b2",
"type": "inject",
"z": "cfdce1d.4428b2",
"name": "",
"topic": "",
"payload": "Pressed",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 340,
"y": 480,
"wires": [
[
"60e3ffbc.83dd9",
"d5348adc.aafe68"
]
]
},
{
"id": "bad326f4.ddade8",
"type": "debug",
"z": "cfdce1d.4428b2",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"x": 990,
"y": 420,
"wires": []
},
{
"id": "bc061d43.76115",
"type": "inject",
"z": "cfdce1d.4428b2",
"name": "",
"topic": "",
"payload": "Long_Pressed",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 350,
"y": 520,
"wires": [
[
"60e3ffbc.83dd9",
"d5348adc.aafe68"
]
]
},
{
"id": "1a857fb7.e05dd",
"type": "inject",
"z": "cfdce1d.4428b2",
"name": "",
"topic": "",
"payload": "Released",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 340,
"y": 560,
"wires": [
[
"60e3ffbc.83dd9",
"d5348adc.aafe68"
]
]
},
{
"id": "d5348adc.aafe68",
"type": "debug",
"z": "cfdce1d.4428b2",
"name": "",
"active": true,
"tosidebar": false,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"x": 610,
"y": 480,
"wires": []
},
{
"id": "42f5ffcd.151f3",
"type": "comment",
"z": "cfdce1d.4428b2",
"name": "8PBU button 8",
"info": "Press 0F F8 A0 04 00 40 00 00 15 04\nLong press 0F F8 A0 04 00 00 00 40 15 04\nRelease 0F F8 A0 04 00 00 40 00 15 04",
"x": 460,
"y": 160,
"wires": []
}
]
Information sources
This mentions using HEX as a donor for strings