Changes in / [1:3]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • /I_MythTVFrontend1.xml

    r1 r3  
    4747        local MYTH_FRONTEND_SEND_ACTION_CMD = "http://%s/Frontend/SendAction?Action=%s" 
    4848        local MYTH_FRONTEND_GET_STATUS_CMD = "http://%s/Frontend/GetStatus" 
    49         local MYTH_FRONTEND_GET_SCREENSHOT_CMD = "http://%s/MythFE/GetScreenShot?format=jpg&width=%d" 
     49        local MYTH_FRONTEND_GET_SCREENSHOT_CMD = "http://%s/MythFE/GetScreenShot?format=jpg&width=%d" 
    5050 
    5151        local FRONTEND_SERVICE = "urn:mythttv-org:serviceId:Frontend1" 
     52        local HADEVICE_SID = "urn:micasaverde-com:serviceId:HaDevice1" 
    5253        local PARENT_DEVICE 
    5354 
     
    129130        end 
    130131 
     132    local function toboolean(v) 
     133            return (type(v) == "string" and v == "true") or (type(v) == "number" and v ~= 0) or (type(v) == "boolean" and v) 
     134        end 
     135 
    131136        function mythfrontendPoll() 
    132137            local resp = cmdGetStatus() 
     
    136141 
    137142        function mythfrontendRefreshPoll() 
    138             local pollingEnabled = luup.variable_get(HADEVICE_SID, "PollingEnabled", PARENT_DEVICE) 
    139             local pollMinDelay = luup.variable_get(HADEVICE_SID, "PollMinDelay", PARENT_DEVICE) 
     143            local pollingEnabled = toboolean(luup.variable_get(HADEVICE_SID, "PollingEnabled", PARENT_DEVICE)) 
     144            local pollMinDelay = tonumber(luup.variable_get(HADEVICE_SID, "PollMinDelay", PARENT_DEVICE), 10) 
    140145            mythfrontendLog("PollingEnabled=" .. tostring(pollingEnabled) .. ", PollMinDelay=" .. tostring(pollMinDelay) ) 
    141146            if (pollingEnabled) then    
     
    158163 
    159164            -- make sure we have the polling defined 
    160             local pollingEnabled = luup.variable_get(HADEVICE_SID, "PollingEnabled", PARENT_DEVICE) 
    161             local pollMinDelay = luup.variable_get(HADEVICE_SID, "PollMinDelay", PARENT_DEVICE) 
    162  
    163             if (pollMinDelay == nil or type(pollMinDelay) ~= "number") then 
     165            local pollingEnabled = toboolean(luup.variable_get(HADEVICE_SID, "PollingEnabled", PARENT_DEVICE)) 
     166            local pollMinDelay = tonumber(luup.variable_get(HADEVICE_SID, "PollMinDelay", PARENT_DEVICE), 10) 
     167 
     168            if (pollMinDelay == nil) then 
    164169                luup.variable_set(HADEVICE_SID, "PollMinDelay", 60, PARENT_DEVICE) 
    165170            end 
    166171 
    167             if (pollingEnabled == nil or type(pollMinDelay) ~= "boolean") then 
    168                 -- according to spec and to bypass bug #0002058, use 1 instead of true 
    169                 luup.variable_set(HADEVICE_SID, "PollingEnabled", 1, PARENT_DEVICE) 
    170             end 
     172            if (pollingEnabled == nil) then 
     173                luup.variable_set(HADEVICE_SID, "PollingEnabled", "true", PARENT_DEVICE) 
     174            end 
     175            mythfrontendLog("PollingEnabled=" .. tostring(pollingEnabled) .. ", PollMinDelay=" .. tostring(pollMinDelay) ) 
    171176            -- 
    172177            -- Avoid blocking startup 
    173178            -- 
    174             luup.call_delay("mythfrontendPoll", 5) 
     179            if (pollingEnabled) then 
     180                luup.call_delay("mythfrontendPoll", 5) 
     181            end 
    175182            return true, "Good to go", "MythFrontend" 
    176183        end 
Note: See TracChangeset for help on using the changeset viewer.