Changes in / [1:3]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • /L_sPhoneUI.lua

    r1 r3  
    1111luup.register_handler("lug_sPhoneRequest_job_status","sPhone_job_status") 
    1212luup.register_handler("lug_sPhoneRequest_camimg","sPhone_camimg") 
    13 luup.register_handler("lug_sPhoneRequest_camstream","sPhone_camstream") 
    1413luup.register_handler("lug_sPhoneRequest_action_js","sPhone_action_js") 
    1514 
     
    257256function lug_sPhoneRequest_sensor(lul_device,lul_description,lul_js) 
    258257    local lul_Armed = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",lul_device) 
     258        lul_Tripped = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",lul_device) 
     259     
     260    if( lul_Tripped~="1") then 
     261        status_tripped='green' 
     262    else 
     263        status_tripped='red' 
     264    end  
    259265     
    260266    if( lul_Armed~="1") then 
     
    267273     
    268274    lul_html_no_js = '<img src="/cmh/iphone_file/icons/security.gif" alt="" width="44" height="43" align="absmiddle" class="icon" />' .. lul_description .. '<br>\n' .. 
     275        '<a href="data_request?id=lu_variableset&DeviceNum=' .. tostring(lul_device) .. '&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Tripped&time=' .. tostring(os.clock()) .. '"><img src="/cmh/images/' .. status_tripped .. '_circle.gif" alt="" border="0"/></a> ' .. 
    269276        '<a href="data_request?id=lu_variableset&DeviceNum=' .. tostring(lul_device) .. '&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Armed&Value=1&time=' .. tostring(os.clock()) .. '"><img src="/cmh/iphone_file/buttons/arm' .. status_arm .. '.gif" alt="" border="0"/></a> ' .. 
    270277        '<a href="data_request?id=lu_variableset&DeviceNum=' .. tostring(lul_device) .. '&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Armed&Value=0&time=' .. tostring(os.clock()) .. '"><img src="/cmh/iphone_file/buttons/bypass' .. status_bypass .. '.gif" alt="" border="0"/></a> ' 
     
    273280    local lul_html_js = '<img src="/cmh/iphone_file/icons/security.gif" alt="" width="44" height="43" align="absmiddle" class="icon" id="pic_device_' .. tostring(lul_device) .. '" />' .. lul_description .. '<br>\n' .. 
    274281        '<img src="/cmh/images/spacer.gif" border="0" width="20" height="20" id="action_icon_' .. tostring(lul_device) .. '">' .. 
     282        '<a href="javascript:void(0);" onClick="set_device_icon(' .. tostring(lul_device) .. ',1);send_command(\'data_request?id=lu_variableset&DeviceNum=' .. tostring(lul_device) .. '&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Tripped&Value=1&time=' .. tostring(os.clock()) .. '\',' .. tostring(lul_device) .. ')"><img src="/cmh/images/' .. status_tripped .. '_circle.gif" alt="" border="0"/></a> ' .. 
    275283        '<a href="javascript:void(0);" onClick="set_device_icon(' .. tostring(lul_device) .. ',1);send_command(\'data_request?id=lu_variableset&DeviceNum=' .. tostring(lul_device) .. '&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Armed&Value=1&time=' .. tostring(os.clock()) .. '\',' .. tostring(lul_device) .. ')"><img src="/cmh/iphone_file/buttons/arm' .. status_arm .. '.gif" alt="" border="0"/></a> ' .. 
    276284        '<a href="javascript:void(0);" onClick="set_device_icon(' .. tostring(lul_device) .. ',1);send_command(\'data_request?id=lu_variableset&DeviceNum=' .. tostring(lul_device) .. '&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Armed&Value=0&time=' .. tostring(os.clock()) .. '\',' .. tostring(lul_device) .. ')"><img src="/cmh/iphone_file/buttons/bypass' .. status_bypass .. '.gif" alt="" border="0"/></a> ' 
     
    283291end 
    284292 
     293function lug_sPhoneRequest_temp(lul_device,lul_description,lul_js) 
     294    local lul_Temp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",lul_device) 
     295     
     296    if( lul_Temp==nil ) then 
     297        lul_Temp='N/A' 
     298    end  
     299 
     300    lul_html_no_js = '<img src="/cmh/iphone_file/icons/thermostat.gif" alt="" width="44" height="43" align="absmiddle" class="icon" />' .. lul_description .. '<br>\n' .. 
     301        'Temperature: ' .. lul_Temp ..'&deg;<br/>' 
     302 
     303    local lul_html_js = '<img src="/cmh/iphone_file/icons/thermostat.gif" alt="" width="44" height="43" align="absmiddle" class="icon" id="pic_device_' .. tostring(lul_device) .. '" />' .. lul_description .. '<br>\n' .. 
     304        '<img src="/cmh/images/spacer.gif" border="0" width="20" height="20" id="action_icon_' .. tostring(lul_device) .. '">' .. 
     305        'Temperature: ' .. lul_Temp ..'&deg;<br/>' 
     306 
     307    if( lul_js=='1' ) then 
     308        return lul_html_js 
     309    else 
     310        return lul_html_no_js 
     311    end          
     312end 
     313 
     314function lug_sPhoneRequest_bright(lul_device,lul_description,lul_js) 
     315    local lul_Level = luup.variable_get("urn:micasaverde-com:serviceId:LightSensor1","CurrentLevel",lul_device) 
     316     
     317    if( lul_Level==nil ) then 
     318        lul_Level='N/A' 
     319    end  
     320 
     321    lul_html_no_js = '<img src="/cmh/iphone_file/icons/brightness.gif" alt="" width="44" height="43" align="absmiddle" class="icon" />' .. lul_description .. '<br>\n' .. 
     322        'Light level: ' .. lul_Level ..'<br/>' 
     323 
     324    local lul_html_js = '<img src="/cmh/iphone_file/icons/brightness.gif" alt="" width="44" height="43" align="absmiddle" class="icon" id="pic_device_' .. tostring(lul_device) .. '" />' .. lul_description .. '<br>\n' .. 
     325        '<img src="/cmh/images/spacer.gif" border="0" width="20" height="20" id="action_icon_' .. tostring(lul_device) .. '">' .. 
     326        'Light level: ' .. lul_Level ..'<br/>' 
     327 
     328    if( lul_js=='1' ) then 
     329        return lul_html_js 
     330    else 
     331        return lul_html_no_js 
     332    end          
     333end 
    285334 
    286335function lug_sPhoneRequest_thermostat(lul_device,lul_description,lul_js) 
     
    509558        '   <tr>' .. 
    510559        '       <td></td>' .. 
    511         '       <td><img src="/cmh/images/set_deasupra.gif" border="0" onClick="set_device_icon(' .. tostring(lul_device) .. ',1);send_command(\'data_request?id=lr_sPhone_action_js&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&device=' .. tostring(lul_device) .. '&service=urn:micasaverde-com:serviceId:DoorLock1&action=SetPin&UserCodeName=\'+document.getElementById(\'UserCodeName_' .. tostring(lul_device) .. '\').value+\'&newPin=\'+document.getElementById(\'newPin_' .. tostring(lul_device) .. '\').value+\'&time=' .. tostring(os.clock()) .. '\',' .. tostring(lul_device) .. ')"></td>' .. 
     560        '       <td><img src="/cmh/images/set_deasupra.gif" border="0" onClick="set_device_icon(' .. tostring(lul_device) .. ',1);send_command(\'data_request?id=lr_sPhone_action_js&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&device=' .. tostring(lul_device) .. '&service=urn:micasaverde-com:serviceId:DoorLock1&action=SetPin&UserCodeName=\'+document.getElementById(\'UserCodeName_' .. tostring(lul_device) .. '\').value+\'&newPin=\'+document.getElementById(\'UserCodeName_' .. tostring(lul_device) .. '\').value+\'&time=' .. tostring(os.clock()) .. '\',' .. tostring(lul_device) .. ')"></td>' .. 
    512561        '   </tr>' ..                
    513562        '</table>' .. 
     
    529578        lul_js = 0; 
    530579    end 
    531  
    532     local lul_streaming,lul_vtime = luup.variable_get("urn:micasaverde-com:serviceId:Camera1","DirectStreamingURL",tonumber(lul_device)) 
    533  
     580     
    534581    local lul_html_no_js = '<div id="toolbar" class="toolbar"> <a href="data_request?id=lr_sPhone_room&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&time=' .. tostring(os.clock()) .. '"><img src="/cmh/iphone_file/images/backButton.gif" border="0"></a> </div>' .. 
    535582        '<div align="center">View camera <br/>' .. 
     
    555602        '<br><a href="data_request?id=lr_sPhone_camimg&device=' .. lul_device .. '&js=' .. lul_js .. '&time=' .. tostring(os.clock()) .. '&js=' .. lul_js ..'">Refresh</a> ' 
    556603 
    557     if( lul_streaming~=nill and #lul_streaming>1 ) then 
    558         lul_html_no_js = lul_html_no_js .. '<a href="data_request?id=lr_sPhone_camstream&device=' .. lul_device .. '&time=' .. tostring(os.clock()) .. '&js=' .. lul_js ..'">Stream</a>' 
    559     end 
    560  
    561     if( lul_js=='1' ) then 
    562         return html_header .. lul_html_js .. html_footer 
    563     else 
    564         return html_header .. lul_html_no_js .. html_footer 
    565     end          
    566      
    567 end 
    568  
    569 function lug_sPhoneRequest_camstream(lul_request,lul_parameters,lul_outputformat) 
    570     local lul_device = lul_parameters["device"] 
    571     local lul_js = lul_parameters["js"] 
    572     if( lul_js==nill or tonumber(lul_js)==0 ) then 
    573         lul_js = 0; 
    574     end 
    575  
    576     local lul_streaming,lul_vtime = luup.variable_get("urn:micasaverde-com:serviceId:Camera1","DirectStreamingURL",tonumber(lul_device)) 
    577     local lul_user,lul_vtime = luup.variable_get("urn:micasaverde-com:serviceId:Camera1","Username",tonumber(lul_device)) 
    578     local lul_pass,lul_vtime = luup.variable_get("urn:micasaverde-com:serviceId:Camera1","Password",tonumber(lul_device)) 
    579     local lul_ip = luup.devices[tonumber(lul_device)].ip 
    580  
    581     local lul_html_no_js = '<div id="toolbar" class="toolbar"> <a href="data_request?id=lr_sPhone_room&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&time=' .. tostring(os.clock()) .. '"><img src="/cmh/iphone_file/images/backButton.gif" border="0"></a> </div>' .. 
    582         '<div align="center">View camera <br/>' .. 
    583         '<img src="http://' .. lul_user .. ':' .. lul_pass .. '@' .. lul_ip .. lul_streaming .. '"><br>' .. 
    584         '<a href="data_request?id=lr_sPhone_action&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&device=' .. lul_device .. '&service=urn:micasaverde-com:serviceId:PanTiltZoom1&action=MoveUp"><img src="/cmh/images/buupdeasupra.gif" border="0"></a>' .. 
    585         '<a href="data_request?id=lr_sPhone_action&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&device=' .. lul_device .. '&service=urn:micasaverde-com:serviceId:PanTiltZoom1&action=MoveDown"><img src="/cmh/images/budowndeasupra.gif" border="0"></a>' .. 
    586         '<a href="data_request?id=lr_sPhone_action&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&device=' .. lul_device .. '&service=urn:micasaverde-com:serviceId:PanTiltZoom1&action=MoveLeft"><img src="/cmh/images/buldeasupra.gif" border="0"></a>' .. 
    587         '<a href="data_request?id=lr_sPhone_action&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&device=' .. lul_device .. '&service=urn:micasaverde-com:serviceId:PanTiltZoom1&action=MoveRight"><img src="/cmh/images/burdeasupra.gif" border="0"></a>' .. 
    588         '<a href="data_request?id=lr_sPhone_action&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&device=' .. lul_device .. '&service=urn:micasaverde-com:serviceId:PanTiltZoom1&action=ZoomIn"><img src="/cmh/images/buplusdeasupra.gif" border="0"></a>' .. 
    589         '<a href="data_request?id=lr_sPhone_action&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&device=' .. lul_device .. '&service=urn:micasaverde-com:serviceId:PanTiltZoom1&action=ZoomOut"><img src="/cmh/images/buminusdeasupra.gif" border="0"></a>' .. 
    590         '<br><a href="data_request?id=lr_sPhone_camimg&device=' .. lul_device .. '&time=' .. tostring(os.clock()) .. '&js=' .. lul_js ..'">Still Image</a> ' 
    591      
    592     local lul_html_js = '<div id="toolbar" class="toolbar"> <a href="data_request?id=lr_sPhone_room&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&time=' .. tostring(os.clock()) .. '"><img src="/cmh/iphone_file/images/backButton.gif" border="0"></a> </div>' .. 
    593         '<div align="center">View camera <br/>' .. 
    594         '<img src="data_request?id=cam_image&Device_Num=' .. lul_device .. '&room=' .. luup.devices[tonumber(lul_device)].room_num .. '&time=' .. tostring(os.clock()) .. '" id="view_' .. tostring(lul_device) .. '"><br>' .. 
    595         '<img src="/cmh/images/spacer.gif" border="0" width="20" height="20" id="action_icon_' .. tostring(lul_device) .. '"><br>' .. 
    596         '<a href="javascript:void(0)" onClick="sp_move_camera(' .. lul_device .. ',\'MoveUp\');"><img src="/cmh/images/buupdeasupra.gif" border="0"></a>' .. 
    597         '<a href="javascript:void(0)" onClick="sp_move_camera(' .. lul_device .. ',\'MoveDown\');"><img src="/cmh/images/budowndeasupra.gif" border="0"></a>' .. 
    598         '<a href="javascript:void(0)" onClick="sp_move_camera(' .. lul_device .. ',\'MoveLeft\');"><img src="/cmh/images/buldeasupra.gif" border="0"></a>' .. 
    599         '<a href="javascript:void(0)" onClick="sp_move_camera(' .. lul_device .. ',\'MoveRight\');"><img src="/cmh/images/burdeasupra.gif" border="0"></a>' .. 
    600         '<a href="javascript:void(0)" onClick="sp_move_camera(' .. lul_device .. ',\'ZoomIn\');"><img src="/cmh/images/buplusdeasupra.gif" border="0"></a>' .. 
    601         '<a href="javascript:void(0)" onClick="sp_move_camera(' .. lul_device .. ',\'ZoomOut\');"><img src="/cmh/images/buminusdeasupra.gif" border="0"></a>' .. 
    602         '<br><a href="data_request?id=lr_sPhone_camimg&device=' .. lul_device .. '&js=' .. lul_js .. '&time=' .. tostring(os.clock()) .. '&js=' .. lul_js ..'">Still Image</a> ' 
    603  
    604604    if( lul_js=='1' ) then 
    605605        return html_header .. lul_html_js .. html_footer 
     
    652652            elseif( v.category_num==6 ) then -- DEVICE_CATEGORY_CAMERA 
    653653                lul_html = lul_html .. '<li class="bg">' .. lug_sPhoneRequest_camera(k,v.description,lul_js) .. "</li>\n" 
     654            elseif( v.category_num==17 ) then -- DEVICE_CATEGORY_TEMPERATURE 
     655                lul_html = lul_html .. '<li class="bg">' .. lug_sPhoneRequest_temp(k,v.description,lul_js) .. "</li>\n" 
     656            elseif( v.category_num==18 ) then -- DEVICE_CATEGORY_LIGHT 
     657                lul_html = lul_html .. '<li class="bg">' .. lug_sPhoneRequest_bright(k,v.description,lul_js) .. "</li>\n" 
    654658            elseif( v.category_num==4 or v.category_num==9) then -- DEVICE_CATEGORY_SENSOR, DEVICE_CATEGORY_REMOTE_CONTROL 
    655659                lul_html = lul_html .. '<li class="bg">' .. lug_sPhoneRequest_sensor(k,v.description,lul_js) .. "</li>\n" 
Note: See TracChangeset for help on using the changeset viewer.