- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
/I_FoscamPTZ.xml
r1 r3 49 49 50 50 function lug_startup (lul_device) 51 52 -- Check if we have the correct category number. 53 if (luup.devices[lul_device].category_num ~= 6) then 54 luup.attr_set("category_num", "6", lul_device) 55 end 56 51 57 lug_username = luup.devices[lul_device].user or luup.variable_get(CAM_SID, "Username", lul_device) or "" 52 58 lug_password = luup.devices[lul_device].pass or luup.variable_get(CAM_SID, "Password", lul_device) or "" … … 78 84 local ver = luup.version_branch * 10000 + luup.version_major * 1000 + luup.version_minor 79 85 if (ver < 15390) then 86 luup.log("(".. luup.devices[lul_device].description ..") Version ".. luup.version .." is too old.") 80 87 return 81 88 end 82 89 83 -- The camera was alreadyconfigured for motion detection.90 -- Check if the camera was configured for motion detection. 84 91 local configuredMd = luup.variable_get(CMD_SID, "ConfiguredMD", lul_device) or "0" 85 92 if (configuredMd == "0") then 86 93 94 luup.log("(".. luup.devices[lul_device].description ..") ComfiguredMD = ".. configuredMd) 95 87 96 -- We can't configure the camera for motion detection if we don't know its URL/IP address. 88 97 if (lug_ip == "") then 89 return 98 luup.log("(".. luup.devices[lul_device].description .."::ComfiguredMD/".. configuredMd ..") Missing camera IP.") 99 return false, "Missing camera IP address.", luup.devices[lul_device].description 90 100 end 91 101 … … 118 128 end 119 129 120 -- Set the configured flag now because the Luup engine is restarted after 'sync'.130 -- Set the ConfiguredMD variable here, because no value can be saved in the user_data after luup.chdev.sync has run. 121 131 luup.variable_set(CMD_SID, "ConfiguredMD", "1", lul_device) 122 132 … … 128 138 elseif (configuredMd == "1") then 129 139 140 luup.log("(".. luup.devices[lul_device].description ..") ComfiguredMD = ".. configuredMd) 141 130 142 -- We can't configure the camera if we don't know Vera's URL / IP address. 131 local veraAddress = luup.variable_get(CMD_SID, "VeraAddress", lul_device) 143 local veraAddress = luup.variable_get(CMD_SID, "VeraAddress", lul_device) or "" 132 144 if (veraAddress == "") then 133 return 145 luup.log("(".. luup.devices[lul_device].description .."::ComfiguredMD/".. configuredMd ..") VeraAddress is empty.") 146 return false, "Missing Vera IP address.", luup.devices[lul_device].description 134 147 end 135 148 … … 144 157 end 145 158 159 -- We haven't created the motion sensor. Reset the ConfiguredMD variable. 160 if (sensorId == 0) then 161 luup.log("(".. luup.devices[lul_device].description .."::ComfiguredMD/".. configuredMd ..") Motion sensor doesn't exist.") 162 luup.variable_set(CMD_SID, "ConfiguredMD", "0", lul_device) 163 return 164 end 165 146 166 -- Configure the camera: 147 167 -- 1. Enable motion detection. … … 151 171 luup.inet.wget("http://".. lug_ip .."/set_alarm.cgi?motion_armed=1&http=1&http_url=".. urlEncode(url) .."&user=".. lug_username .."&pwd=".. lug_password, 5) 152 172 153 if (sensorId ~= 0) then 154 -- Get and set the time until the sensor is considered untripped. 155 local onTime = luup.variable_get(SES_SID, "OnTime", sensorId) or "" 156 if (onTime:find("^%d+$") ~= nil) then 157 ON_TIME = tonumber(onTime, 10) or ON_TIME 158 else 159 luup.variable_set(SES_SID, "OnTime", tostring(ON_TIME), sensorId) 160 end 173 -- Get and set the time until the sensor is considered untripped. 174 local onTime = luup.variable_get(SES_SID, "OnTime", sensorId) or "" 175 if (onTime:find("^%d+$") ~= nil) then 176 ON_TIME = tonumber(onTime, 10) or ON_TIME 177 else 178 luup.variable_set(SES_SID, "OnTime", tostring(ON_TIME), sensorId) 161 179 end 162 180 163 181 luup.variable_set(CMD_SID, "ConfiguredMD", "2", lul_device) 164 182 else 183 luup.log("(".. luup.devices[lul_device].description ..") ComfiguredMD = ".. configuredMd) 165 184 -- Run the 'trip' function when notified. 166 185 luup.register_handler("trip", "foscam_tripped")
Note: See TracChangeset
for help on using the changeset viewer.