Velux Integra

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

mojojojo490
Posts: 32
Joined: Saturday 03 August 2019 7:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands, Heiloo
Contact:

Re: Velux Integra

Post by mojojojo490 »

I already have the integra. And also interested in the working solution :)
Starter RPi3B, Domoticz Stable 2020.2, 10x Qubino Mini Dimmer, 1x Qubino shutter
Plugwise Anna + Adam + 2x Koen-4 & 1x Floor; SolarEdge SE3000H
Dashticz v3
ProfBoc75
Posts: 4
Joined: Wednesday 21 October 2020 11:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Contact:

Re: Velux Integra

Post by ProfBoc75 »

mojojojo490 wrote: Wednesday 08 July 2020 21:46 I already have the integra. And also interested in the working solution :)
Hi.

I started to work on it. It's working in read status , from Velux KLF-200 --> Domoticz.
Each time a Velux roof window or blind is changing position, it's updated acccordingly in Domoticz.

But I still not start the reverse, Domoticz --> Velux KLF-200. Need little of work to understand how to send command using Velux-Node (in progress... )

My setup is :
Domoticz <--in/out --> MQTT Broker <---> Node-Red + Node-red-contrib-velux <---> Velux KLF-200 <---> Velux roof window + external blind.

Most of the work is in Node-Red Flows with function to convert idx (Domoticz) and nodeID (KLF-200).

To be continued ...
Prof'Boc75
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Velux Integra

Post by Geitje »

Well, if you need help/suggestions, you could always post here...
I'm planning to buy velux integra, so I'm interested too...
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
ProfBoc75
Posts: 4
Joined: Wednesday 21 October 2020 11:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Contact:

Re: Velux Integra

Post by ProfBoc75 »

Hi,

My installation is now working end to end. So I'm sharing how it works.

My installation :

Domoticz <--in/out --> MQTT Broker <---> Node-Red + Node-red-contrib-velux + Functions & Flows <---> Velux KLF-200 <---> Velux Integra with Roof window openers + roller shutters.

Prerequisites : h**ps://www.domoticz.com/wiki/MQTT
1- Have installed a MQTT Broker like mosquitto h**ps://mosquitto.org/blog/2013/01/mosquitto-debian-repository/
2- Have installed Node-Red h**ps://nodered.org/docs/getting-started/raspberrypi

***********************************************************************
11h September 2026 Update

Older versions of the node-red-contrib-velux module, from 0.0.4 to 0.0.7, are no longer supported; since 12 July 2026, an expired certificate has prevented any new connections. A fork is available and is 100% compatible (same node names).
If your flow is already set up, back it up using the export function, delete the flow and deploy.
Check that there are no longer any nodes associated with Velux.
This will allow you to remove the old module – which is no longer used by any nodes – and install the new one; see point 3 below, which has been updated accordingly.
Once the new module is installed, re-importing the backup and redeploying the flow should suffice.

Alternative solution from command line is :

npm remove node-red-contrib-velux
npm install node-red-contrib-velux-klf200
# then restart Node-RED

***********************************************************************

3- Then install from Manage Palette, install node-red-contrib-velux-klf200 (version 1.0.2)
4- For sure the KLF-200 must be also setup : choose the interface mode, follow the installation wizard to import Velux Products and Scenes. At least one scene must exist in the KLF-200 to avoid any issue with the velux-node connection in Node-Red flow.

Domoticz part:
1- Create a hardware Velux Dummy.
2- From this Velux Dummy and for each Velux product, create a "virtual Sensor", type switch then update it to "blinds percentage". Note the idx numbers as usual. Prefer keep the same Names of the products under Domoticz than shown in KLF-200 to facilitate the conversion done later in Node-Red part.
Domoticz_Velux.png
Domoticz_Velux.png (73.66 KiB) Viewed 4433 times
***********************************************************************
27th November 2022 Update

The last version of Domoticz 2022.2 needs a modification for "blinds" equipment , this is the case of Velux Blinds and Roof Windows
Reverse Open/Close State: Enabled
In order to get the good status : Open/Closed.
***********************************************************************

3- Add the hardware MQTT Client Gateway with LAN interface using the MQTT Broker server (prevent loop = true)

Node-Red part:

Status feedback into Domoticz:
1- Import this first flow into node-red :
"host": "192.168.xx.xx", --> KLF-200 IP address
"password": "YourWifiPassword", --> KLF-200 Wifi Password (not velux123, the other one written under the box close to the Wifi ssid)

Code: Select all

[
    {
        "id": "774ff8d2.0467c8",
        "type": "Velux Nodes",
        "z": "6e3cbaf0.36e4e4",
        "name": "",
        "datasource": "e59f5b49.c02b58",
        "index": "-1",
        "nodevalue": "ALL",
        "topic": "",
        "x": 590,
        "y": 80,
        "wires": [
            [
                "d7808506.616dc8",
                "209dd4dd.4e37ac"
            ]
        ]
    },
    {
        "id": "a2494c81.43609",
        "type": "mqtt out",
        "z": "6e3cbaf0.36e4e4",
        "name": "",
        "topic": "domoticz/in",
        "qos": "",
        "retain": "",
        "broker": "26a40b17.e8e744",
        "x": 1030,
        "y": 80,
        "wires": []
    },
    {
        "id": "209dd4dd.4e37ac",
        "type": "debug",
        "z": "6e3cbaf0.36e4e4",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1030,
        "y": 160,
        "wires": []
    },
    {
        "id": "d7808506.616dc8",
        "type": "function",
        "z": "6e3cbaf0.36e4e4",
        "name": "UpdatePosition",
        "func": "var dt = new Date();\n\nvar nodeID = msg.payload.nodeID;\nvar cpv = msg.payload.currentPosition.value;\n// var tpv = msg.payload.target.value\n\n//Convert NodeID to Domoticz IDX value\n\nif (nodeID === 0) {\n\tvar idx = 4556;\n} else if (nodeID === 1) {\n\tvar idx = 4550;\n} else if (nodeID === 2) {\n\tvar idx = 4551;\n} else if (nodeID === 3) {\n\tvar idx = 4552;\n}\n\n// set nvalue and svalue from current position\nif (cpv === 0) {\n\tvar nv=0;\n\tvar sv=0;\n} else if (cpv === 100) {\n\tvar nv=1;\n\tvar sv=100;\n} else {\n\tvar nv=2;\n\tvar sv=cpv;\n}\n\nmsg.payload = {};\nmsg.payload.command = \"switchlight\";\nmsg.payload.switchcmd = \"Set Level\";\nmsg.payload.level = sv;\nmsg.payload.idx = idx;\n// msg.payload.nvalue = nv;\n// msg.payload.svalue = sv;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 820,
        "y": 80,
        "wires": [
            [
                "a2494c81.43609"
            ]
        ]
    },
    {
        "id": "c1b21be6.47156",
        "type": "comment",
        "z": "6e3cbaf0.36e4e4",
        "name": "Opérationel",
        "info": "it works !",
        "x": 590,
        "y": 40,
        "wires": []
    },
    {
        "id": "6f16143d.f9793c",
        "type": "inject",
        "z": "6e3cbaf0.36e4e4",
        "name": "LectureVelux",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "velux:read",
        "payloadType": "str",
        "x": 330,
        "y": 80,
        "wires": [
            [
                "774ff8d2.0467c8"
            ]
        ]
    },
    {
        "id": "e59f5b49.c02b58",
        "type": "velux-connection",
        "z": "",
        "host": "192.168.xx.xx",
        "password": "YourWifiPassword",
        "monitor": "MONITOR"
    },
    {
        "id": "26a40b17.e8e744",
        "type": "mqtt-broker",
        "z": "",
        "name": "MQTTBroker",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]
- Check / Setup the mqtt-broker connection in the "domoticz/in" node
- Same for the "Velux-Nodes", KLF-200 ip address and Wifi Password are used.

- Deploy the new flow.
- Monitor the debug console for KLF-200 connection errors.
- "connected" must appear under the "domoticz/in" node.


Get the Velux nodeID to correspond with the Domoticz idx numbers:

h**p://hostname:1880/velux/nodes (hostname = ip where node-red webinterface is running)

Sample answer :
[{"id":3,"name":"VoletVeluxDroit","order":3},{"id":2,"name":"VoletVeluxGauche","order":2},{"id":0,"name":"VeluxDroite","order":1},{"id":1,"name":"VeluxGauche","order":0}]

Write down the "id" number for the next steps below.
Forget the "order" num, this is for KLF-200 position in the webinterface.

Notice: If your answer is [] only, check:
- The KLF-200 connection is at least possible from node-red (reachable/same local network)
- The version of the node-red-contrib-velux-klf200 should be the 1.0.2 or >
Restart Node-red : sudo node-red-restart and last a reboot could be required after all installation of node-red & .contrib-velux


After all is working as expected :
- Edit "Update Position" and make correction with your idx numbers from virtual sensors (Domoticz) accordingly with the id of Velux products (nodeID = id).
- In my case : 4 products, so 4 conversions are done.
Function_updateposition.png
Function_updateposition.png (97.52 KiB) Viewed 4433 times
- I'm not an expert, this code could be optimized for sure, but it works !

Note: The Velux product status is sent at each change of position , every 15 mn if connected to the main power supply, every hour if using high performance battery, and one per day if using low performance battery.

- After updates are done, Deploy again the flow

- You should be able to test using the "lectureVelux" button, the information is shown in the node-red debug console, same in the Domoticz log.
Example:

Code: Select all

26/10/2020 à 18:12:15node: 209dd4dd.4e37acmsg.payload : Object
{ id: 0, api: 529, apiText: "GW_NODE_STATE_POSITION_CHANGED…", nodeID: 0, order: 1 … }
26/10/2020 à 18:12:15node: 209dd4dd.4e37acmsg.payload : Object
{ id: 0, api: 529, apiText: "GW_NODE_STATE_POSITION_CHANGED…", nodeID: 1, order: 0 … }
26/10/2020 à 18:12:15node: 209dd4dd.4e37acmsg.payload : Object
{ id: 0, api: 529, apiText: "GW_NODE_STATE_POSITION_CHANGED…", nodeID: 2, order: 2 … }
26/10/2020 à 18:12:15node: 209dd4dd.4e37acmsg.payload : Object
{ id: 0, api: 529, apiText: "GW_NODE_STATE_POSITION_CHANGED…", nodeID: 3, order: 3 … }
- Check that Domoticz use them as expected, without error at idx level :
Example:

Code: Select all

2020-10-26 18:07:47.340 MQTT: Topic: domoticz/in, Message: {"command":"switchlight","switchcmd":"Set Level","level":100,"idx":4556}
2020-10-26 18:07:47.350 (Velux) Light/Switch (VeluxDroite)
2020-10-26 18:07:47.463 MQTT: Topic: domoticz/in, Message: {"command":"switchlight","switchcmd":"Set Level","level":100,"idx":4550}
2020-10-26 18:07:47.471 (Velux) Light/Switch (VeluxGauche)
2020-10-26 18:07:47.583 MQTT: Topic: domoticz/in, Message: {"command":"switchlight","switchcmd":"Set Level","level":100,"idx":4551}
2020-10-26 18:07:47.592 (Velux) Light/Switch (VoletVeluxGauche)
2020-10-26 18:07:47.704 MQTT: Topic: domoticz/in, Message: {"command":"switchlight","switchcmd":"Set Level","level":100,"idx":4552}
2020-10-26 18:07:47.714 (Velux) Light/Switch (VoletVeluxDroit)
This part is done, you can play with your remote control to see updates of position are going back to Domoticz accordingly.

2- Create the command flow :

Import the code in the same / current flow (at popup, select "import copy" since few nodes already exist):

Code: Select all

[
    {
        "id": "4adc61a.8da8ca",
        "type": "mqtt in",
        "z": "6e3cbaf0.36e4e4",
        "name": "",
        "topic": "domoticz/out",
        "qos": "2",
        "datatype": "json",
        "broker": "26a40b17.e8e744",
        "x": 110,
        "y": 220,
        "wires": [
            [
                "7e99db6c.65c0a4"
            ]
        ]
    },
    {
        "id": "209dd4dd.4e37ac",
        "type": "debug",
        "z": "6e3cbaf0.36e4e4",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1170,
        "y": 220,
        "wires": []
    },
    {
        "id": "11487e17.9aadfa",
        "type": "switch",
        "z": "6e3cbaf0.36e4e4",
        "name": "VeluxMsg",
        "property": "payload.name",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "VeluxGauche",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "VeluxDroite",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "VoletVeluxGauche",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "VoletVeluxDroit",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 4,
        "x": 260,
        "y": 400,
        "wires": [
            [
                "14871380.3ebfbd"
            ],
            [
                "3a5904ed.26840c"
            ],
            [
                "a2ff102b.2de6c"
            ],
            [
                "91019c5a.a94348"
            ]
        ]
    },
    {
        "id": "14871380.3ebfbd",
        "type": "change",
        "z": "6e3cbaf0.36e4e4",
        "name": "SetVeluxGauchenodeID",
        "rules": [
            {
                "t": "set",
                "p": "payload.nodeID",
                "pt": "msg",
                "to": "1",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 340,
        "wires": [
            [
                "acb78b54.7f69b"
            ]
        ]
    },
    {
        "id": "3a5904ed.26840c",
        "type": "change",
        "z": "6e3cbaf0.36e4e4",
        "name": "SetVeluxDroitenodeID",
        "rules": [
            {
                "t": "set",
                "p": "payload.nodeID",
                "pt": "msg",
                "to": "0",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 500,
        "y": 380,
        "wires": [
            [
                "acb78b54.7f69b"
            ]
        ]
    },
    {
        "id": "7e99db6c.65c0a4",
        "type": "change",
        "z": "6e3cbaf0.36e4e4",
        "name": "SetPosition",
        "rules": [
            {
                "t": "set",
                "p": "payload.position",
                "pt": "msg",
                "to": "$number(payload.svalue1)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 310,
        "y": 220,
        "wires": [
            [
                "11487e17.9aadfa"
            ]
        ]
    },
    {
        "id": "4ff6fe72.96ce78",
        "type": "Velux Api",
        "z": "6e3cbaf0.36e4e4",
        "name": "",
        "datasource": "e59f5b49.c02b58",
        "api": "768",
        "ntf": [
            "770",
            "771"
        ],
        "topic": "",
        "x": 1000,
        "y": 400,
        "wires": [
            [
                "209dd4dd.4e37ac"
            ]
        ]
    },
    {
        "id": "acb78b54.7f69b",
        "type": "function",
        "z": "6e3cbaf0.36e4e4",
        "name": "BougePosition",
        "func": "var dt = new Date();\n\nvar nodeID = msg.payload.nodeID\nvar position = msg.payload.position\nif (msg.payload.nvalue === 0) {\n    position = 0;\n} else if (msg.payload.nvalue === 1) {\n    position = 100;\n}\n\nvar cmd = { \n      commandOriginator: 1,\n      priorityLevel: 2,\n      parameterActive: 0,\n      functionalParameterMP: {valueType:'RELATIVE', value:position},\n      indexArrayCount: 1,\n      indexArray: [nodeID],\n      priorityLevelLock: false,\n      lockTime: 0\n  }\n\nmsg.payload = cmd;\n\n// msg.topic = \"velux:write\"\n// msg.payload.nvalue = nv;\n// msg.payload.svalue = sv;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 800,
        "y": 400,
        "wires": [
            [
                "4ff6fe72.96ce78"
            ]
        ]
    },
    {
        "id": "a2ff102b.2de6c",
        "type": "change",
        "z": "6e3cbaf0.36e4e4",
        "name": "SetVoletVeluxGauchenodeID",
        "rules": [
            {
                "t": "set",
                "p": "payload.nodeID",
                "pt": "msg",
                "to": "2",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 520,
        "y": 420,
        "wires": [
            [
                "acb78b54.7f69b"
            ]
        ]
    },
    {
        "id": "91019c5a.a94348",
        "type": "change",
        "z": "6e3cbaf0.36e4e4",
        "name": "SetVoletVeluxDroitnodeID",
        "rules": [
            {
                "t": "set",
                "p": "payload.nodeID",
                "pt": "msg",
                "to": "3",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 460,
        "wires": [
            [
                "acb78b54.7f69b"
            ]
        ]
    },
    {
        "id": "26a40b17.e8e744",
        "type": "mqtt-broker",
        "z": "",
        "name": "MQTTBroker",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "e59f5b49.c02b58",
        "type": "velux-connection",
        "z": "",
        "host": "192.168.xx.xx",
        "password": "YouWIFIPassword",
        "monitor": "MONITOR"
    }
]
- Again, check / control the connection of the mqtt-broker, here in the node "domoticz/out", connection should already setup after previous import.
- The Velux API is using the same "velux-connection" , check / control ip and password.

- Edit "VeluxMSG" to correspond with your products. I used the "name", but we can use the "idx", up to you to change the code.
- Edit each SetxxxxnodeID to reflect your installation.
- Deploy the flow.
- From Domoticz, you should be able to test the new "virtual sensors".

- Monitor Node-Red and Domoticz logs. Debug Console can be disabled by one click on the green button on the right of "msg.payload".

All done !


You should have something like that :
Resultat_final.png
Resultat_final.png (71.21 KiB) Viewed 4433 times
Note that my installation is limited to 2 roof windows and 2 roller shutters.
The "BougePosition" function should be adapted to your products, like light switches, doors , gate opener or so on.

Please have a look to the klf.js code to find the good JSON format for your product that will be sent to the Velux API :
github.com/PLCHome/velux-klf200-api/blob/master/lib/klf.js

*************************************************************************************
11h September 2026 Update
Since PLCHome no more contribute since years (last was 2021), a fork was created to correct issues
github.com/tix0815/node-red-contrib-velux

More details about this module 1.0.2:
flows.nodered.org/node/node-red-contrib-velux-klf200
*************************************************************************************

Thanks to read me until the end... ;)
Last edited by ProfBoc75 on Friday 11 September 2026 19:22, edited 2 times in total.
Prof'Boc75
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Velux Integra

Post by Geitje »

Thanks for this great tutorial, will certainly try it if everything here is ready.
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
hestia
Posts: 361
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

Re: Velux Integra

Post by hestia »

Great tutorial!
I have 2 velux windows with 2 having shutters.
Is only one KLF-200 enough to drive them independently?
Do the plugin could get the rain information?
Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Velux Integra

Post by Quax1507 »

Yes, it will work.
hestia
Posts: 361
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

Re: Velux Integra

Post by hestia »

Thanks!
ProfBoc75
Posts: 4
Joined: Wednesday 21 October 2020 11:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Contact:

Re: Velux Integra

Post by ProfBoc75 »

Hi,

My solution is still working well after 2 years. No major issue, except one time all the stuff was no more synchronized after a power supply outage, including the main remote KLR200 which was not able to control the Velux devices. It was resolve after power off/on the Velux only.

I confirm that the klf200 is able to manage 200 actuators or 5 wired groups with up to 200 actuators (in total).
If you're facing connection issue, you need to wait 15 min before retry logon, the tcpip socket is reset after 15 min without communication or reboot the klf200 (power off/on recycle)

Notice that the last version of Domoticz 2022.2 needs a little update at Blinds level to enable the reverse the Open/Close in order to get the good status Open/Closed.

Thanks.
Prof'Boc75
ProfBoc75
Posts: 4
Joined: Wednesday 21 October 2020 11:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Contact:

Re: Velux Integra

Post by ProfBoc75 »

Hi,

Little update, since the 12 July, the node connection is failing due to an expired certificate from the current palette module.
This module is no more updated since 2021 and must be replaced by a 100% compatible one : node-red-contrib-velux-klf200 (version 1.0.2)

I updated my post accordingly. Enjoy.
Prof'Boc75
Post Reply