PLCHome / velux-klf200-api

Provide node to Veluxl® KLF-200 io-homecontrol® Gateway API
42 stars 7 forks source link

functionalParameterMP / functionalParameterArray => How to use? #7

Closed nr001 closed 5 years ago

nr001 commented 5 years ago

Hello,

and thx for this great library. I'm trying to control my venetian blind. Moving it already works quite fine, the only thing that i couldn't realize at the moment is moving the slats.

As far as i understood i need to use the "functionalParameterArray" to add the value for the movement of the slats. Can anyone instruct me how this works?

The code says ` -in json data { .... functionalParameterMP: [int/value], functionalParameterArray [array of functionalParameter] .... }

json functionalParameter
{
  enabled: [boolean],
  prameter : [int/value]
}

` however i'm not sure what and how to pass correct data to functionalParameterMP and functionalParameterArray if both of them should be used? Can anyone provide a working example code?

PLCHome commented 5 years ago

Yes, both are possible at the same time if the device supports it.

"functionalParameterArray" is an array of objects. You must set enabeld to true and give a value. The value can either be a value or a value object. The first array index is 0. The highest array index is 15. It is possible to make the array shorter or only to set the index needed.

The operation of the command is described in the Velux api on page 57. On page 104 is explained which functional parameter has which function.

Example all functional parameters set:

'use strict'
const velux = require('velux-klf200-api')

velux.connect('192.168.2.15',{})
.then(()=>{
  return velux.login('<some password>')
})
.then((data)=>{
  return velux.sendCommand({ api: velux.API.GW_COMMAND_SEND_REQ,
      commandOriginator: 1,
      priorityLevel: 2,
      parameterActive: 0,
      functionalParameterMP: {valueType:'RELATIVE', value:100},
      /* functionalParameterMP: 100, */
      functionalParameterArray:[
           {enabled: true, prameter: {valueType:'RELATIVE', value:80}},
           {enabled: true, prameter: 90},
           {enabled: true, prameter: {valueType:'RELATIVE', value:100}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:1}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:2}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:3}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:4}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:5}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:6}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:7}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:8}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:9}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:10}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:11}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:12}},
           {enabled: true, prameter: {valueType:'RELATIVE', value:13}}
      ]
      indexArrayCount: 1,
      indexArray: [0],
      priorityLevelLock: false,
      lockTime: 0
  })
})
.then((data)=>{
  console.log(data)
})
.catch((err)=>{
  console.log(err)
  return velux.end()
})