Posts: 120
Threads: 24
Joined: Jul 2015
Reputation:
0
Hi,
On a project I’m working on, we have a kNX switch that shall open a lock, in the main door of a house. The video intercom device is a Zennio Getface IP. I want to use the LM5 lite that I already have, to be used as a gateway. To my knowledge the Zennio Getface Ip has Http Api license installed.
Is it possible to do? And if so can someone help me?
LM5 ip: 192.168.1.103
Zennio Getface ip: 192.168.1.101
See link below for manual to Zennio Getface IP:
http://zennio.com/video-intercom/getface...basic-unit
Best Regard.
Even Sundgot.
Posts: 7264
Threads: 40
Joined: Jun 2015
Reputation:
416
Do you have documentation on HTTP API? Sending requests via HTTP is simple, but without documentation there's nothing we can help with.
Posts: 120
Threads: 24
Joined: Jul 2015
Reputation:
0
(15.05.2018, 08:39)admin Wrote: Do you have documentation on HTTP API? Sending requests via HTTP is simple, but without documentation there's nothing we can help with.
Hi,
I can`t find anything on Zennio Gatface Ip documentation, but on 2N who is the manufacture i found this:
https://wiki.2n.cz/hip/hapi/latest/en
BR Even
Posts: 7264
Threads: 40
Joined: Jun 2015
Reputation:
416
Attach this code to an event script (boolean object). It will contol switch 1 depending on object value. Make sure that Switch API is enabled without encryption and authentication. log(...) call at the end should be removed if script is working correctly.
Code: require('socket.http')
switch = 1
value = event.getvalue()
if value then
action = 'on'
else
action = 'off'
end
url = 'http://192.168.1.101/api/switch/ctrl?switch=' .. switch .. '&action=' .. action
res, err = socket.http.request(url)
log(res, err)
Posts: 120
Threads: 24
Joined: Jul 2015
Reputation:
0
(16.05.2018, 12:38)admin Wrote: Attach this code to an event script (boolean object). It will contol switch 1 depending on object value. Make sure that Switch API is enabled without encryption and authentication. log(...) call at the end should be removed if script is working correctly.
Code: require('socket.http')
switch = 1
value = event.getvalue()
if value then
action = 'on'
else
action = 'off'
end
url = 'http://192.168.1.101/api/switch/ctrl?switch=' .. switch .. '&action=' .. action
res, err = socket.http.request(url)
log(res, err)
Hi
Works perfectly, thanks!
Now to my next question, how to read a input from Zennio Getface IP ?
is there an easy way?
Br Even.
Posts: 7264
Threads: 40
Joined: Jun 2015
Reputation:
416
State has to be polled so you need a resident script. Adjust sleep time as needed, but do not use 0 as it will consume all CPU.
Uncomment and modify grp calls depending on how many inputs are used.
Code: require('json')
require('socket.http')
res, err = socket.http.request('http://192.168.1.101/api/io/status')
if res then
data = json.pdecode(res)
if type(data) == 'table' then
ports = data.result.ports
log(ports)
-- grp.checkwrite('1/1/1', ports[ 1 ].state)
-- grp.checkwrite('1/1/1', ports[ 2 ].state)
else
alert('failed to decode data')
end
else
alert('http request failed ' .. tostring(err))
end
-- release unused resources
collectgarbage('collect')
Posts: 120
Threads: 24
Joined: Jul 2015
Reputation:
0
(18.05.2018, 08:07)admin Wrote: State has to be polled so you need a resident script. Adjust sleep time as needed, but do not use 0 as it will consume all CPU.
Uncomment and modify grp calls depending on how many inputs are used.
Code: require('json')
require('socket.http')
res, err = socket.http.request('http://192.168.1.101/api/io/status')
if res then
data = json.pdecode(res)
if type(data) == 'table' then
ports = data.result.ports
log(ports)
-- grp.checkwrite('1/1/1', ports[ 1 ].state)
-- grp.checkwrite('1/1/1', ports[ 2 ].state)
else
alert('failed to decode data')
end
else
alert('http request failed ' .. tostring(err))
end
-- release unused resources
collectgarbage('collect')
Hi Admin,
Thank you!
It kinda works, but not 100%.
When triggering input1 nothing happens.
When triggering ext1.input1 port 2 goes to ON.
When triggering ext1.input2 nothing happens
Im not shure if it`s the Getface that is the problem or what? do you have an idea?
From current errors:
Test Script Getface 18.05.2018 10:21:51
Resident script:9: attempt to index field 'result' (a nil value)
stack traceback:
From Log:
Test Script Getface 18.05.2018 11:02:05
* table:
[1]
* table:
[state]
* number: 0
[port]
* string: led_secured
[2]
* table:
[state]
* number: 0
[port]
* string: relay1
[3]
* table:
[state]
* number: 0
[port]
* string: output1
[4]
* table:
[state]
* number: 0
[port]
* string: input1
[5]
* table:
[state]
* number: 0
[port]
* string: ext1.relay1
[6]
* table:
[state]
* number: 0
[port]
* string: ext1.relay2
[7]
* table:
[state]
* number: 0
[port]
* string: ext1.input1
[8]
* table:
[state]
* number: 0
[port]
* string: ext1.input2
BR Even.
Posts: 7264
Threads: 40
Joined: Jun 2015
Reputation:
416
You access the same URL ( http://192.168.1.101/api/io/status) in your browser and check whether input states change or not.
Error checking can be improved like this:
Code: if type(data) == 'table' and type(data.result) == 'table' and type(data.result.ports) == 'table' then
ports = data.result.ports
Posts: 120
Threads: 24
Joined: Jul 2015
Reputation:
0
18.05.2018, 10:40
(This post was last modified: 18.05.2018, 10:43 by Evens.)
(18.05.2018, 09:32)admin Wrote: You access the same URL (http://192.168.1.101/api/io/status) in your browser and check whether input states change or not.
Error checking can be improved like this:
Code: if type(data) == 'table' and type(data.result) == 'table' and type(data.result.ports) == 'table' then
ports = data.result.ports
Hi,
When using the url, i see that all innputs work like they should.
I think the problem is the port number, it doesn`t seem to match the input correctly.
Do you have an idea?
BR Even.
(18.05.2018, 10:40)Evens Wrote: (18.05.2018, 09:32)admin Wrote: You access the same URL (http://192.168.1.101/api/io/status) in your browser and check whether input states change or not.
Error checking can be improved like this:
Code: if type(data) == 'table' and type(data.result) == 'table' and type(data.result.ports) == 'table' then
ports = data.result.ports
Hi,
When using the url, i see that all innputs work like they should.
I think the problem is the port number, it doesn`t seem to match the input correctly.
Do you have an idea?
BR Even.
Correction, i missunderstood.
It works, perfectly!
Thanks!
BR Even.
Posts: 7264
Threads: 40
Joined: Jun 2015
Reputation:
416
It might be that array input order is not defined. Try this instead:
Code: ports = {}
for _, p in ipairs(data.result.ports) do
ports[ p.port ] = p.state
end
grp.checkwrite('1/1/1', ports['ext1.input1'])
grp.checkwrite('1/1/2', ports['ext1.input2'])
Posts: 120
Threads: 24
Joined: Jul 2015
Reputation:
0
(18.05.2018, 10:46)admin Wrote: It might be that array input order is not defined. Try this instead:
Code: ports = {}
for _, p in ipairs(data.result.ports) do
ports[ p.port ] = p.state
end
grp.checkwrite('1/1/1', ports['ext1.input1'])
grp.checkwrite('1/1/2', ports['ext1.input2'])
it did work, i just didn`t change the port number.
it was on 1 and 2 and i didn`t change it. so when changing to 4 and 7 it worked perfectly.
the reason why it worked on 2 is becouse relay 1 is linked to ext.input 1 in the getface.
[1] led_secured
[2] relay1
[3] output1
[4] input1
[5] ext1.relay1
[6] ext1.relay2
[7] ext1.input1
[8] ext1.input2
Thanks, for all the help!
BR Even.
Posts: 296
Threads: 69
Joined: Jan 2021
Reputation:
0
23.10.2023, 11:12
(This post was last modified: 23.10.2023, 11:39 by khalil.)
(16.05.2018, 12:38)admin Wrote: Attach this code to an event script (boolean object). It will contol switch 1 depending on object value. Make sure that Switch API is enabled without encryption and authentication. log(...) call at the end should be removed if script is working correctly.
Code: require('socket.http')
switch = 1
value = event.getvalue()
if value then
action = 'on'
else
action = 'off'
end
url = 'http://192.168.1.101/api/switch/ctrl?switch=' .. switch .. '&action=' .. action
res, err = socket.http.request(url)
log(res, err)
Hello dear Admin
If I want to do the job reverse, means I want to receive a command/trigger from the Getface IP, what is the http command from the zennio getface should look like?
Best Regards,
Posts: 7264
Threads: 40
Joined: Jun 2015
Reputation:
416
You can use Remote services. See docs here (examples are at the bottom): https://openrb.com/docs/remote-new.htm
|