Changes in / [1:3]


Ignore:
Location:
/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • /trunk/L_OWServer.lua

    r1 r3  
    1111local TEMPERATURE_SERVICE_FILE      = "S_TemperatureSensor1.xml" 
    1212local TEMPERATURE_VARIABLE          = "CurrentTemperature" 
     13 
     14local DOORSENSOR_DEVICE             = "urn:schemas-micasaverde-com:device:DoorSensor:1" 
     15local DOORSENSOR_SERVICE            = "urn:micasaverde-com:serviceId:SecuritySensor1" 
     16local DOORSENSOR_DEVICE_FILE        = "D_DoorSensor1.xml" 
     17local DOORSENSOR_SERVICE_FILE       = "S_SecuritySensor1.xml" 
     18local DOORSENSOR_VARIABLE           = "Tripped" 
    1319 
    1420local HUMIDITY_DEVICE               = "urn:schemas-micasaverde-com:device:HumiditySensor:1" 
     
    6773local   TYPE_PRESSURESENSOR             =   14 
    6874local   TYPE_COUNTER                    =   15 
     75local   TYPE_DOORSENSOR                 =   16 
    6976 
    7077 
     
    216223TypeTable[TYPE_LIGHTSENSOR_ENERGY].Variable     = LIGHTSENSOR_VARIABLE 
    217224TypeTable[TYPE_LIGHTSENSOR_ENERGY].Parameters   = OWSERVER_SERVICE..",DeviceWatts=0\n" 
     225 
     226TypeTable[TYPE_DOORSENSOR] = {} 
     227TypeTable[TYPE_DOORSENSOR].Name                 = "Door Sensor"; 
     228TypeTable[TYPE_DOORSENSOR].Average              = 1 
     229TypeTable[TYPE_DOORSENSOR].Device               = DOORSENSOR_DEVICE 
     230TypeTable[TYPE_DOORSENSOR].Service              = DOORSENSOR_SERVICE 
     231TypeTable[TYPE_DOORSENSOR].DeviceFile           = DOORSENSOR_DEVICE_FILE 
     232TypeTable[TYPE_DOORSENSOR].ServiceFile          = DOORSENSOR_SERVICE_FILE 
     233TypeTable[TYPE_DOORSENSOR].Variable             = DOORSENSOR_VARIABLE 
     234TypeTable[TYPE_DOORSENSOR].Parameters           = "" 
    218235 
    219236 
     
    249266local   DEVICE_DS2423_COUNTERB      =   25 
    250267 
     268local   DEVICE_EDS0067_TEMP         =   26 
     269local   DEVICE_EDS0067_LIGHT        =   27 
     270local   DEVICE_EDS0067_COUNTER1     =   28 
     271local   DEVICE_EDS0067_COUNTER2     =   29 
     272local   DEVICE_EDS0067_LED          =   30 
     273local   DEVICE_EDS0067_RELAY        =   31 
     274 
     275 
    251276 
    252277 
     
    272297DeviceTable[DEVICE_DS2406_INPUTA].Parameter     = "InputLevel_A" 
    273298DeviceTable[DEVICE_DS2406_INPUTA].Command       = "" 
    274 DeviceTable[DEVICE_DS2406_INPUTA].Services      = {TYPE_LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_IGNORE} 
     299DeviceTable[DEVICE_DS2406_INPUTA].Services      = {TYPE_LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_DOORSENSOR, TYPE_IGNORE} 
    275300 
    276301DeviceTable[DEVICE_DS2406_INPUTB] = {} 
     
    279304DeviceTable[DEVICE_DS2406_INPUTB].Parameter     = "InputLevel_B" 
    280305DeviceTable[DEVICE_DS2406_INPUTB].Command       = "" 
    281 DeviceTable[DEVICE_DS2406_INPUTB].Services      = {TYPE_LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_IGNORE} 
     306DeviceTable[DEVICE_DS2406_INPUTB].Services      = {TYPE_IGNORE, TYPE_LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_DOORSENSOR} 
    282307 
    283308DeviceTable[DEVICE_DS18B20_TEMP] = {} 
     
    435460DeviceTable[DEVICE_EDS0068_RELAY].Services      = {TYPE_IGNORE, TYPE_LIGHTSWITCH, TYPE_LIGHTSWITCH_ENERGY} 
    436461 
     462DeviceTable[DEVICE_EDS0067_TEMP] = {} 
     463DeviceTable[DEVICE_EDS0067_TEMP].Device         = "EDS0067" 
     464DeviceTable[DEVICE_EDS0067_TEMP].Name           = "Temperature" 
     465DeviceTable[DEVICE_EDS0067_TEMP].Parameter      = "Temperature" 
     466DeviceTable[DEVICE_EDS0067_TEMP].Command        = "" 
     467DeviceTable[DEVICE_EDS0067_TEMP].Services       = {TYPE_TEMP_C, TYPE_TEMP_F, TYPE_IGNORE} 
     468 
     469DeviceTable[DEVICE_EDS0067_LIGHT] = {} 
     470DeviceTable[DEVICE_EDS0067_LIGHT].Device        = "EDS0067" 
     471DeviceTable[DEVICE_EDS0067_LIGHT].Name          = "Light" 
     472DeviceTable[DEVICE_EDS0067_LIGHT].Parameter     = "Light" 
     473DeviceTable[DEVICE_EDS0067_LIGHT].Command       = "" 
     474DeviceTable[DEVICE_EDS0067_LIGHT].Services      = {TYPE_LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_IGNORE} 
     475 
     476DeviceTable[DEVICE_EDS0067_COUNTER1] = {} 
     477DeviceTable[DEVICE_EDS0067_COUNTER1].Device     = "EDS0067" 
     478DeviceTable[DEVICE_EDS0067_COUNTER1].Name       = "Counter 1" 
     479DeviceTable[DEVICE_EDS0067_COUNTER1].Parameter  = "Counter1" 
     480DeviceTable[DEVICE_EDS0067_COUNTER1].Command    = "" 
     481DeviceTable[DEVICE_EDS0067_COUNTER1].Services   = {TYPE_IGNORE, TYPE_COUNTER} 
     482 
     483DeviceTable[DEVICE_EDS0067_COUNTER2] = {} 
     484DeviceTable[DEVICE_EDS0067_COUNTER2].Device     = "EDS0067" 
     485DeviceTable[DEVICE_EDS0067_COUNTER2].Name       = "Counter 2" 
     486DeviceTable[DEVICE_EDS0067_COUNTER2].Parameter  = "Counter2" 
     487DeviceTable[DEVICE_EDS0067_COUNTER2].Command    = "" 
     488DeviceTable[DEVICE_EDS0067_COUNTER2].Services   = {TYPE_IGNORE, TYPE_COUNTER} 
     489 
     490DeviceTable[DEVICE_EDS0067_LED] = {} 
     491DeviceTable[DEVICE_EDS0067_LED].Device          = "EDS0067" 
     492DeviceTable[DEVICE_EDS0067_LED].Name            = "LED" 
     493DeviceTable[DEVICE_EDS0067_LED].Parameter       = "LED" 
     494DeviceTable[DEVICE_EDS0067_LED].Command         = "LEDState" 
     495DeviceTable[DEVICE_EDS0067_LED].Services        = {TYPE_IGNORE, TYPE_LIGHTSWITCH} 
     496 
     497DeviceTable[DEVICE_EDS0067_RELAY] = {} 
     498DeviceTable[DEVICE_EDS0067_RELAY].Device        = "EDS0067" 
     499DeviceTable[DEVICE_EDS0067_RELAY].Name          = "Relay" 
     500DeviceTable[DEVICE_EDS0067_RELAY].Parameter     = "Relay" 
     501DeviceTable[DEVICE_EDS0067_RELAY].Command       = "RelayState" 
     502DeviceTable[DEVICE_EDS0067_RELAY].Services      = {TYPE_IGNORE, TYPE_LIGHTSWITCH, TYPE_LIGHTSWITCH_ENERGY} 
     503 
    437504 
    438505local DEBUG_MODE = false 
     
    463530    SamplingPeriod = luup.variable_get( OWSERVER_SERVICE, "SamplingPeriod", lul_device ) 
    464531    if(SamplingPeriod == nil) then 
    465         SamplingPeriod = 60 
     532        SamplingPeriod = 20 
    466533        luup.variable_set(OWSERVER_SERVICE, "SamplingPeriod", SamplingPeriod, lul_device) 
    467534    end 
     
    523590    luup.log(OWSERVER_LOG_NAME.."STARTDL: "..dlTime) 
    524591 
     592    -- Poll the OW-SERVER and get details.xml 
    525593    local code, res = luup.inet.wget("http://"..luup.devices[ParentDevice].ip.."/details.xml", 3, "", "") 
    526594 
     
    533601    luup.log(OWSERVER_LOG_NAME.."START: "..startTime) 
    534602 
     603    -- Process the XML file into a table 
    535604    local Count = 0 
    536605    local ni,c,label,xarg, empty 
    537606    local i, j = 1, 1 
    538607    while true do 
    539         ni,j,c,label,xarg, empty = string.find(res, "<(%/?)(%w+)(.-)(%/?)>", i) 
     608        ni,j,c,label,xarg, empty = string.find(res, "<(%/?)([%w:_]+)(.-)(%/?)>", i) 
    540609        if not ni then 
    541610            break 
     
    551620        end 
    552621        if c == "" then   -- start tag 
    553             if(label == "owd") then 
     622            if(string.sub(label, 1, 3) == "owd") then 
    554623                Count = Count + 1 
    555624                OWDevices[Count] = {} 
     
    559628    end 
    560629 
    561     luup.variable_set(OWSERVER_SERVICE, "Devices", OWServer.DevicesConnected, ParentDevice) 
    562  
     630    luup.variable_set(OWSERVER_SERVICE, "Devices",    OWServer.DevicesConnected, ParentDevice) 
     631    luup.variable_set(OWSERVER_SERVICE, "DataErrors", OWServer.DataErrors,       ParentDevice) 
     632 
     633    -- Loop through all the One-Wire devices in the XML-file table 
    563634    local found 
    564635    local Value 
    565636    for Count = 1, #OWDevices do 
    566637        found = 0 
     638        -- Search all child devices to find any with the ROMId 
    567639        for k, v in pairs(ChildDevices) do 
    568640            if(v.ROMId == OWDevices[Count]["ROMId"]) then 
     641--luup.log(OWSERVER_LOG_NAME.."Processing: "..OWDevices[Count]["ROMId"].."::"..v.Param.." == "..OWDevices[Count][v.Param]) 
    569642                found = 1 
    570643 
     
    587660                end 
    588661 
     662                -- Keep a loop buffer to allow rolling average filter 
    589663                v.History[v.Counter] = round(OWDevices[Count][v.Param],1) 
    590664                v.Counter = v.Counter + 1 
     
    592666                    v.Counter = 1 
    593667                    v.Record  = 1 
     668                else 
     669                    v.Record  = 0 
    594670                end 
    595671 
     
    787863-- devices.htm?rom=4300000200AD1928&variable=UserByte1&value=75 
    788864function sendCommand(Device, Value) 
    789     luup.log( OWSERVER_LOG_NAME .. "sendCommand: Device " .. Device .. " to "..Value) 
     865--  luup.log( OWSERVER_LOG_NAME .. "sendCommand: Device " .. Device .. " to "..Value) 
    790866    local lul_cmd = 'http://' .. luup.devices[ParentDevice].ip .. '/devices.htm?rom=' .. ChildDevices[Device].ROMId .. "&variable=" .. ChildDevices[Device].Command .. "&value=".. Value 
    791     luup.log( OWSERVER_LOG_NAME .. "sendCommand --> " .. lul_cmd) 
     867--  luup.log( OWSERVER_LOG_NAME .. "sendCommand --> " .. lul_cmd) 
    792868    local code, res = luup.inet.wget(lul_cmd, 3, "", "") 
    793869 
  • /trunk/D_OWServer.json

    r1 r3  
    3636                    "ControlType":"label", 
    3737                    "Label":{ 
    38                         "lang_tag":"next", 
     38                        "lang_tag":"devices_lab", 
    3939                        "text":"Devices Attached:" 
    4040                    }, 
     
    5454                        "Variable":"Devices", 
    5555                        "Top":20, 
     56                        "Left":175, 
     57                        "Width":75, 
     58                        "Height":20 
     59                    } 
     60                }, 
     61                { 
     62                    "ControlGroup":"2", 
     63                    "ControlHeader":"2", 
     64                    "ControlType":"label", 
     65                    "Label":{ 
     66                        "lang_tag":"errors_lab", 
     67                        "text":"Data Errors:" 
     68                    }, 
     69                    "Display":{ 
     70                        "Top":45, 
     71                        "Left":50, 
     72                        "Width":120, 
     73                        "Height":20 
     74                    } 
     75                }, 
     76                { 
     77                    "ControlGroup":"2", 
     78                    "ControlHeader":"2", 
     79                    "ControlType":"variable", 
     80                    "Display":{ 
     81                        "Service":"urn:upnp-org:serviceId:OWServer1", 
     82                        "Variable":"DataErrors", 
     83                        "Top":45, 
    5684                        "Left":175, 
    5785                        "Width":75, 
Note: See TracChangeset for help on using the changeset viewer.