Logic Machine Forum
Http Api command to Zennio Getface IP - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Http Api command to Zennio Getface IP (/showthread.php?tid=1392)

Pages: 1 2


Http Api command to Zennio Getface IP - Evens - 14.05.2018

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-ip-en/getface-basic-unit

Best Regard.
Even Sundgot.


RE: Http Api command to Zennio Getface IP - admin - 15.05.2018

Do you have documentation on HTTP API? Sending requests via HTTP is simple, but without documentation there's nothing we can help with.


RE: Http Api command to Zennio Getface IP - Evens - 15.05.2018

(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


RE: Http Api command to Zennio Getface IP - admin - 16.05.2018

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)



RE: Http Api command to Zennio Getface IP - Evens - 16.05.2018

(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! Smile

Now to my next question, how to read a input from Zennio Getface IP ? 
is there an easy way?

Br Even.


RE: Http Api command to Zennio Getface IP - admin - 18.05.2018

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')



RE: Http Api command to Zennio Getface IP - Evens - 18.05.2018

(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.


RE: Http Api command to Zennio Getface IP - admin - 18.05.2018

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



RE: Http Api command to Zennio Getface IP - Evens - 18.05.2018

(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! Smile

Thanks!

BR Even.


RE: Http Api command to Zennio Getface IP - admin - 18.05.2018

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'])



RE: Http Api command to Zennio Getface IP - Evens - 18.05.2018

(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! Smile

BR Even.


RE: Http Api command to Zennio Getface IP - khalil - 23.10.2023

(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?


RE: Http Api command to Zennio Getface IP - admin - 23.10.2023

You can use Remote services. See docs here (examples are at the bottom): https://openrb.com/docs/remote-new.htm


RE: Http Api command to Zennio Getface IP - khalil - 22.07.2024

(23.10.2023, 11:21)admin Wrote: You can use Remote services. See docs here (examples are at the bottom): https://openrb.com/docs/remote-new.htm

Hello Dear
could you check the remote configuration if there is any error?

Code:
http://remote:remote@172.28.**.**/scada-remote?m=json&r=grp&fn=write&alias=0/7/9&value=0



RE: Http Api command to Zennio Getface IP - admin - 22.07.2024

Try removing remote:remote@ from the URL. Or put correct user:pass into the URL and keep the Username and Password fields empty.


RE: Http Api command to Zennio Getface IP - khalil - 22.07.2024

(22.07.2024, 10:39)admin Wrote: Try removing remote:remote from the URL. Or put correct user:pass into the URL and keep the Username and Password fields empty.

Didn't work!
while when I try from the browser its bring the default webpage with user name and password when entered the command triggered, while both SL and Zennio are on the same VLAN and I tried to connect  my laptop on the same cable of the zennio intercom and its worked.
but from zennio its not working!


RE: Http Api command to Zennio Getface IP - Daniel - 22.07.2024

Contact Zennio support and ask how to send such request in this format from this device.


RE: Http Api command to Zennio Getface IP - khalil - 22.07.2024

(22.07.2024, 10:55)Daniel Wrote: Contact Zennio support and ask how to send such request in this format from this device.

I contact them, its the same http command used.
the strange thing that these commands  was working few days ago!


RE: Http Api command to Zennio Getface IP - khalil - 22.07.2024

How to check the http command comes out from zennio?
Could it be monitored from LM, or I need Wireshark?
If Wire shark needed what filters should I use?


RE: Http Api command to Zennio Getface IP - admin - 22.07.2024

You can use Wireshark but then you need configure Zennio to send requests to your PC IP address instead of LM. You will also need to run a HTTP server on your PC. You can use this one, but keep in mind that default port is 1180 not 80 when configuring Zennio.

In Wireshark set filter to ip.src==IP where IP is Zennio IP address.