Logic Machine Forum
Set KNX object's value via HTTP? - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Set KNX object's value via HTTP? (/showthread.php?tid=550)



Set KNX object's value via HTTP? - Thomas - 10.01.2017

Hi
I can read exported objects values. But
Is it possible to set a new value to KNX object through LM via REST API, SOAP etc?
If so do you have any excample?
 
Thank you


RE: Set KNX object's value via HTTP? - buuuudzik - 10.01.2017

Here you have a full description of read/set function:
http://openrb.com/docs/remote-new.htm

Write value of 50 to 1/1/1:
Code:
http://remote:remote@192.168.0.10/scada-remote?m=json&r=grp&fn=write&alias=1/1/1&value=50

To use this function you must first enable Remote services in "System config" and set some login and password for this service.


RE: Set KNX object's value via HTTP? - Erwin van der Zwart - 11.01.2017

Hi,

Here is a full sample:

You must enable remote services and check the objects for export and use this LUA command to have HTTP communication for older FW use:

Code:
require('socket.http')
socket.http.TIMEOUT = 5

-- Read from object
local reply = socket.http.request('http://remote:remote@192.168.0.10/cgi-bin/scada-remote/request.cgi?m=json&r=grp&fn=getvalue&alias=0/0/8')
grp.write('0/0/7', reply)

-- Write to object
value = grp.getvalue('0/0/7')
local reply = socket.http.request('http://remote:remoter@192.168.0.10/cgi-bin/scada-remote/request.cgi?m=json&r=grp&fn=write&alias=0/0/8&value=' .. value .. '')

See for all possible syntax this URL: http://www.openrb.com/docs/remote.htm

For new (and BETA) FW use:

Code:
require('socket.http')
socket.http.TIMEOUT = 5

-- Read from object
local reply = socket.http.request('http://remote:remote@192.168.0.10/scada-remote?m=json&r=grp&fn=getvalue&alias=0/0/8')
grp.write('0/0/7', reply)

-- Write to object
value = grp.getvalue('0/0/7')
local reply = socket.http.request('http://remote:remote@192.168.0.10/scada-remote?m=json&r=grp&fn=write&alias=0/0/8&value=' .. value .. '')

See for all possible syntax this URL: http://www.openrb.com/docs/remote-new.htm

I strongly recommend to change the default remote password..

BR,

Erwin


RE: Set KNX object's value via HTTP? - Thomas - 12.01.2017

Thank you
It works perfectly!


RE: Set KNX object's value via HTTP? - gjniewenhuijse - 08.05.2017

how to get this working over https? port 443


RE: Set KNX object's value via HTTP? - Erwin van der Zwart - 08.05.2017

(08.05.2017, 10:03)gjniewenhuijse Wrote: how to get this working over https? port 443

Hi Gert-Jan,

Like this:

Code:
require('ssl.https')
ssl.https.TIMEOUT = 5

-- Read from object
local reply = ssl.https.request('https://remote:remote@www.yourdomain.com/scada-remote?m=json&r=grp&fn=getvalue&alias=1/1/1')
log(reply)

BR,

Erwin


RE: Set KNX object's value via HTTP? - gjniewenhuijse - 08.05.2017

(08.05.2017, 10:18)Erwin van der Zwart Wrote:
(08.05.2017, 10:03)gjniewenhuijse Wrote: how to get this working over https? port 443

Hi Gert-Jan,

Like this:

Code:
require('ssl.https')
ssl.https.TIMEOUT = 5

-- Read from object
local reply = ssl.https.request('https://remote:remote@www.yourdomain.com/scada-remote?m=json&r=grp&fn=getvalue&alias=1/1/1')
log(reply)

BR,

Erwin

Hello,

It doesn't work. When i use this link in a browser without user/password it works (after entering my credentials in the popup).


RE: Set KNX object's value via HTTP? - admin - 08.05.2017

Does your password contain any special characters?


RE: Set KNX object's value via HTTP? - gjniewenhuijse - 08.05.2017

(08.05.2017, 13:45)admin Wrote: Does your password contain any special characters?

nope, in the format: abc12345

result log:
* arg: 1
  * nil
* arg: 2
  * string: revcd alert fatal error
* arg: 3
  * nil
* arg: 4
  * nil

or is there a better/safer way to sync some groupaddresses between a homelynk and a logicmachine?


RE: Set KNX object's value via HTTP? - admin - 08.05.2017

Have you tried RC1 firmware?


RE: Set KNX object's value via HTTP? - gjniewenhuijse - 08.05.2017

(08.05.2017, 14:44)admin Wrote: Have you tried RC1 firmware?

nope its our production environment.

HL 1.5.1 <-> LM4 20160927

(08.05.2017, 14:44)admin Wrote: Have you tried RC1 firmware?

its works with RC1 instead of using the HL.

LM4 RC1 -> LM4 2060927


RE: Set KNX object's value via HTTP? - Erwin van der Zwart - 08.05.2017

Hi,

I tested it on HL FW 2.0.0 and it should work, but ssl.https should also work on older HL FW as i use it for Pushover also..

BR,

Erwin


RE: Set KNX object's value via HTTP? - gjniewenhuijse - 09.05.2017

(08.05.2017, 15:47)Erwin van der Zwart Wrote: Hi,

I tested it on HL FW 2.0.0 and it should work, but ssl.https should also work on older HL FW as i use it for Pushover also..

BR,

Erwin

Problem solved after installing HL FW 2.0.0


RE: Set KNX object's value via HTTP? - willynt - 03.01.2018

Hi,

I'm new to this, so please excuse any obvious question...
I'd like to use a remote url, like https://remote:remote@www.yourdomain.com/scada-remote?
I know how to write a value for an object, say 2/2/6:
http://remote:remote@192.168.0.10/scada-remote?m=json&r=grp&fn=write&alias=2/2/6&value=50
so far so good.

All my blinds are on 2/2/x, and I'd like to write a value (say 0) to all the 2/2/x objects.
Is that possible with a single request? (I tagged all my objects and I tried to use the "&tags=xxx" parameters, but it doesn't work).
Any help much appreciated.
Thx


RE: Set KNX object's value via HTTP? - Erwin van der Zwart - 04.01.2018

Hi,

'tags' is not a valid parameter for the remote services 'grp' function.

What you can do is create a new (virtual) object and attach this script to it (change tag name to your tag name):
Code:
value = event.getvalue()
myobjects = grp.tag('tag name')
myobjects:write(value)
You can now send a single command to the new created (virtual) object with the remote service to trigger multiple objects.

BR,

Erwin


RE: Set KNX object's value via HTTP? - willynt - 04.01.2018

Thx a mil!
Exactly what I needed Smile