Hello!
My goal is to get the status of my home alarm into a selector switch.
When I enter this in the browser
https://webehome.com/Public/login.aspx? ... onOnly=yes
then I get one of the following words in response: disarm, home or away
Is there any way to get this status into a selector switch?
Thanks in advance!
Get alarm status
Moderators: leecollings, remb0
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Get alarm status
can you show the exact response (screenshot) ? Not clear now if the response if json or xml or other formatEmil wrote: ↑Friday 07 December 2018 16:51 Hello!
My goal is to get the status of my home alarm into a selector switch.
When I enter this in the browser
https://webehome.com/Public/login.aspx? ... onOnly=yes
then I get one of the following words in response: disarm, home or away
Is there any way to get this status into a selector switch?
Thanks in advance!
What do you mean the get the status into a selector switch ? Should the selector switch switch to the level named disarm, home or away or do you mean something else ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 3
- Joined: Friday 07 December 2018 16:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.97
- Location: Sverige
- Contact:
Re: Get alarm status
Yes, i want the selector switch to show the level named disarm, home or away.
/Emil
/Emil
- Attachments
-
- Skärmklipp 2018-12-08 08.25.16.jpg (49.96 KiB) Viewed 378 times
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Get alarm status
The script below does react to the httpResponse and set the selector switch accordingly but there is no translation in it yet.
So for now the selector labels should be exactly the same as the possible returns from the alarm system.
If you need to translate the strings to home, disarm and and away, I need the exact words that you can get from the http call.
Code: Select all
local alarmResponse = "_alarmResponse"
return {
on = { timer = { 'every minute' },
httpResponses = { alarmResponse }},
logging = { level = domoticz.LOG_DEBUG,
marker = "älarmResponse" },
execute = function(dz, item )
local alarmSelectorIDX = nnn -- Change to the IDX of your selector
local url = 'https://webehome.com/Public/login.aspx?LoginName=username&Password=password&Action=status&ActionOnly=yes' -- Change to real HTTP
local alarmStatus = dz.devices(alarmSelectorIDX)
local levels = {}
local function logWrite(str,level)
dz.log(str,level or dz.LOG_DEBUG)
end
local function findLevel(label)
local level = false
for i = 1,#alarmStatus.levelNames do
logWrite(alarmStatus.levelNames[i])
if alarmStatus.levelNames[i] == label then
level = i * 10 - 10
logWrite("Found: ".. alarmStatus.levelNames[i])
end
end
return level
end
local function getAlarmStatus(url)
dz.openURL ( {
url = url,
method = 'GET',
callback = alarmResponse
} )
end
local function xml2Table(xml)
local dataStart = "<body>"
local dataEnd = "</body>"
local i, j = string.find(xml, dataStart)
local k, i = string.find(xml, dataEnd)
local payLoad= xml:sub(j+1,k-1)
logWrite("payLoad is: " ..payLoad)
return payLoad
end
-- Main code
if not item.isHTTPResponse then
getAlarmStatus(url)
else
logWrite("data from HTTPcall: " .. item.data)
if item.ok then -- statusCode == 2xx
newLevel = findLevel(xml2Table(item.data))
if newLevel and newLevel ~= alarmStatus.level then
alarmStatus.dimTo(newLevel)
end
else
logWrite("Problem with the XML response")
end
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 3
- Joined: Friday 07 December 2018 16:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.97
- Location: Sverige
- Contact:
Re: Get alarm status
I will try this, thank you for taking the time to share your knowledge with me.
Who is online
Users browsing this forum: No registered users and 1 guest