Hello everybody
sorry for posting a newbie question but I'm stuck..
I have an anti intrusion system with a web page I can interact with it with curl (no json)
I had no problem to create a switch with on and off command that calls a script like:
script://alarm.sh 1
to turn on
and
script://alarm.sh 0
to turn off
my problem is: when I turn on/off the alarm system with its remote (obviously) the Domoticz switch is not updated.. I can read the status of the alarm with another curl command but I really have not idea how to integrate it with the "switch" I created...
to be more exhaustive the curl command to read the status is:
curl --user USER:PASSWORD -X GET http://IP/controlpage.htm|grep "option value\=\".\" selected=\"selected\""|head -n 1 |cut -d "\"" -f 2
and I get 1 if the system is armed and 3 if it's disarmed
with this I'd like to update the status of the switch so I always have it updated on my Domoticz web page and the phone app too.
I'm also not sure if LUA is the right way... Is there anybody so kind to help me?
thanks a lot, Leonardo
Anti intrusion interaction
Moderator: leecollings
-
- Posts: 251
- Joined: Sunday 11 May 2014 11:09
- Target OS: Windows
- Domoticz version: 2023.1+
- Location: NL
- Contact:
Re: Anti intrusion interaction
you need to build some script to "catch" the result of your call.
This can be done in lua, but it has some side effects --> Domoticz will freeze until this has been finished.
Openurl does not catch the result. So you need something on a different level of lua scripting.
I think this would be better done in Bash or python but i have not skills on that side.
Home someone can help you in the right direction. It is possible !
For lua you need something like
local f=assert(io.popen(cmd, 'r'))
local s=assert(f:read('*a'))
f:close()
But i woud avoid it if possible.
This can be done in lua, but it has some side effects --> Domoticz will freeze until this has been finished.
Openurl does not catch the result. So you need something on a different level of lua scripting.
I think this would be better done in Bash or python but i have not skills on that side.
Home someone can help you in the right direction. It is possible !
For lua you need something like
local f=assert(io.popen(cmd, 'r'))
local s=assert(f:read('*a'))
f:close()
But i woud avoid it if possible.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
-
- Posts: 14
- Joined: Sunday 21 July 2013 22:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Italy
- Contact:
Re: Anti intrusion interaction
Hello and thanks for answering
I already have the scripts I need, because at the moment I did this workaround:
turn on/off system:
Domoticz switch with "on/off command": bash script with a curl http post called by script://alarm.sh [on] [off]
update switch on Domoticz:
bash script on crontab (every 10 mins) that checks the system status with a curl http get and updates Domoticz switch with its json like:
curl -s 'http://DOMOTICZ:8080/json.htm?type=comm ... 5&nvalue=1' (or 0)
At this moment I really don't know if doing this with LUA it could be better except having everything on a single script (calling external scripts anyway)
I already have the scripts I need, because at the moment I did this workaround:
turn on/off system:
Domoticz switch with "on/off command": bash script with a curl http post called by script://alarm.sh [on] [off]
update switch on Domoticz:
bash script on crontab (every 10 mins) that checks the system status with a curl http get and updates Domoticz switch with its json like:
curl -s 'http://DOMOTICZ:8080/json.htm?type=comm ... 5&nvalue=1' (or 0)
At this moment I really don't know if doing this with LUA it could be better except having everything on a single script (calling external scripts anyway)
Who is online
Users browsing this forum: No registered users and 1 guest