Posts: 95
Threads: 17
Joined: Jan 2020
Reputation:
2
Hi
Is there a script that can get status out of a Helvar routersystem with HelvarNet?
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
Try this script to check communication to HelvarNet. It will send query command every 3 seconds. If this works then status map to group address can be implemented.
Resident script, sleep time = 0. Change 192.168.1.1 to HelvarNet router IP. Change 1.1.2.15 to the address of the device you want to query. You will get raw and parsed replies in Logs tab.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
if not sock then
ip =
'192.168.1.1'
sock =
require (
'socket' ).
udp ()
sock :
setsockname (
'*' ,
60001 )
sock :
settimeout (
1 )
ptime =
os.time ()
function parseitem (
res ,
item )
if item :
sub (
1 ,
1 ) ==
'@' then
if item :
find (
'=' )
then
local addr ,
val =
unpack (
item :
split (
'=' ))
res.addr =
addr :
sub (
2 )
res.val =
val
end
elseif item :
find (
':' )
then
local key ,
val =
unpack (
item :
split (
':' ))
res [
key ] =
val
end
end
function parse (
data )
local res = {}
if not data :
find (
'#' )
then
return
end
res.type =
data :
sub (
1 ,
1 )
data =
data :
sub (
2 , -
2 )
local items =
data :
split (
',' )
for _ ,
item in ipairs (
items )
do
parseitem (
res ,
item )
end
log (
res )
end
end
data =
sock :
receive ()
if data then
log (
data )
parse (
data )
end
ctime =
os.time ()
if (
ctime -
ptime ) >=
3 then
ptime =
ctime
sock :
sendto (
'>V:1,C:152,@1.1.2.15#' ,
ip ,
50001 )
end
Posts: 95
Threads: 17
Joined: Jan 2020
Reputation:
2
07.05.2020, 08:42
(This post was last modified: 07.05.2020, 08:44 by victor.back .)
(21.04.2020, 14:59) admin Wrote: Try this script to check communication to HelvarNet. It will send query command every 3 seconds. If this works then status map to group address can be implemented.
Resident script, sleep time = 0. Change 192.168.1.1 to HelvarNet router IP. Change 1.1.2.15 to the address of the device you want to query. You will get raw and parsed replies in Logs tab.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
if not sock then
ip =
'192.168.1.1'
sock =
require (
'socket' ).
udp ()
sock :
setsockname (
'*' ,
60001 )
sock :
settimeout (
1 )
ptime =
os.time ()
function parseitem (
res ,
item )
if item :
sub (
1 ,
1 ) ==
'@' then
if item :
find (
'=' )
then
local addr ,
val =
unpack (
item :
split (
'=' ))
res.addr =
addr :
sub (
2 )
res.val =
val
end
elseif item :
find (
':' )
then
local key ,
val =
unpack (
item :
split (
':' ))
res [
key ] =
val
end
end
function parse (
data )
local res = {}
if not data :
find (
'#' )
then
return
end
res.type =
data :
sub (
1 ,
1 )
data =
data :
sub (
2 , -
2 )
local items =
data :
split (
',' )
for _ ,
item in ipairs (
items )
do
parseitem (
res ,
item )
end
log (
res )
end
end
data =
sock :
receive ()
if data then
log (
data )
parse (
data )
end
ctime =
os.time ()
if (
ctime -
ptime ) >=
3 then
ptime =
ctime
sock :
sendto (
'>V:1,C:152,@1.1.2.15#' ,
ip ,
50001 )
end First thanks for help.
Tried changed the IP and device address as followed but doesnt get any in log or error log. ?
I checked the push message in Helvar designer is set to True.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
if not sock then
ip =
'192.168.1.14'
sock =
require (
'socket' ).
udp ()
sock :
setsockname (
'*' ,
60001 )
sock :
settimeout (
1 )
ptime =
os.time ()
function parseitem (
res ,
item )
if item :
sub (
1 ,
1 ) ==
'@' then
if item :
find (
'=' )
then
local addr ,
val =
unpack (
item :
split (
'=' ))
res.addr =
addr :
sub (
2 )
res.val =
val
end
elseif item :
find (
':' )
then
local key ,
val =
unpack (
item :
split (
':' ))
res [
key ] =
val
end
end
function parse (
data )
local res = {}
if not data :
find (
'#' )
then
return
end
res.type =
data :
sub (
1 ,
1 )
data =
data :
sub (
2 , -
2 )
local items =
data :
split (
',' )
for _ ,
item in ipairs (
items )
do
parseitem (
res ,
item )
end
log (
res )
end
end
data =
sock :
receive ()
if data then
log (
data )
parse (
data )
end
ctime =
os.time ()
if (
ctime -
ptime ) >=
3 then
ptime =
ctime
sock :
sendto (
'>V:1,C:152,@1.14.1.61#' ,
ip ,
50001 )
end
Posts: 8199
Threads: 43
Joined: Jun 2015
Reputation:
473
Try changing local port from 60001 to 50001. If it still does not work then the example should be modified to use TCP instead of UDP.
Posts: 95
Threads: 17
Joined: Jan 2020
Reputation:
2
Great! changed the port 50001, and now I get information in log.
Posts: 35
Threads: 6
Joined: Dec 2023
Reputation:
0
Hi!
This story with Helvar, did you got some results or working solution?
Interested to use LM instead of Helvar BACNET gateway.