- Location:
- /trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
/trunk/L_OWServer.lua
r1 r3 11 11 local TEMPERATURE_SERVICE_FILE = "S_TemperatureSensor1.xml" 12 12 local TEMPERATURE_VARIABLE = "CurrentTemperature" 13 14 local DOORSENSOR_DEVICE = "urn:schemas-micasaverde-com:device:DoorSensor:1" 15 local DOORSENSOR_SERVICE = "urn:micasaverde-com:serviceId:SecuritySensor1" 16 local DOORSENSOR_DEVICE_FILE = "D_DoorSensor1.xml" 17 local DOORSENSOR_SERVICE_FILE = "S_SecuritySensor1.xml" 18 local DOORSENSOR_VARIABLE = "Tripped" 13 19 14 20 local HUMIDITY_DEVICE = "urn:schemas-micasaverde-com:device:HumiditySensor:1" … … 67 73 local TYPE_PRESSURESENSOR = 14 68 74 local TYPE_COUNTER = 15 75 local TYPE_DOORSENSOR = 16 69 76 70 77 … … 216 223 TypeTable[TYPE_LIGHTSENSOR_ENERGY].Variable = LIGHTSENSOR_VARIABLE 217 224 TypeTable[TYPE_LIGHTSENSOR_ENERGY].Parameters = OWSERVER_SERVICE..",DeviceWatts=0\n" 225 226 TypeTable[TYPE_DOORSENSOR] = {} 227 TypeTable[TYPE_DOORSENSOR].Name = "Door Sensor"; 228 TypeTable[TYPE_DOORSENSOR].Average = 1 229 TypeTable[TYPE_DOORSENSOR].Device = DOORSENSOR_DEVICE 230 TypeTable[TYPE_DOORSENSOR].Service = DOORSENSOR_SERVICE 231 TypeTable[TYPE_DOORSENSOR].DeviceFile = DOORSENSOR_DEVICE_FILE 232 TypeTable[TYPE_DOORSENSOR].ServiceFile = DOORSENSOR_SERVICE_FILE 233 TypeTable[TYPE_DOORSENSOR].Variable = DOORSENSOR_VARIABLE 234 TypeTable[TYPE_DOORSENSOR].Parameters = "" 218 235 219 236 … … 249 266 local DEVICE_DS2423_COUNTERB = 25 250 267 268 local DEVICE_EDS0067_TEMP = 26 269 local DEVICE_EDS0067_LIGHT = 27 270 local DEVICE_EDS0067_COUNTER1 = 28 271 local DEVICE_EDS0067_COUNTER2 = 29 272 local DEVICE_EDS0067_LED = 30 273 local DEVICE_EDS0067_RELAY = 31 274 275 251 276 252 277 … … 272 297 DeviceTable[DEVICE_DS2406_INPUTA].Parameter = "InputLevel_A" 273 298 DeviceTable[DEVICE_DS2406_INPUTA].Command = "" 274 DeviceTable[DEVICE_DS2406_INPUTA].Services = {TYPE_LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_ IGNORE}299 DeviceTable[DEVICE_DS2406_INPUTA].Services = {TYPE_LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_DOORSENSOR, TYPE_IGNORE} 275 300 276 301 DeviceTable[DEVICE_DS2406_INPUTB] = {} … … 279 304 DeviceTable[DEVICE_DS2406_INPUTB].Parameter = "InputLevel_B" 280 305 DeviceTable[DEVICE_DS2406_INPUTB].Command = "" 281 DeviceTable[DEVICE_DS2406_INPUTB].Services = {TYPE_ LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_IGNORE}306 DeviceTable[DEVICE_DS2406_INPUTB].Services = {TYPE_IGNORE, TYPE_LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_DOORSENSOR} 282 307 283 308 DeviceTable[DEVICE_DS18B20_TEMP] = {} … … 435 460 DeviceTable[DEVICE_EDS0068_RELAY].Services = {TYPE_IGNORE, TYPE_LIGHTSWITCH, TYPE_LIGHTSWITCH_ENERGY} 436 461 462 DeviceTable[DEVICE_EDS0067_TEMP] = {} 463 DeviceTable[DEVICE_EDS0067_TEMP].Device = "EDS0067" 464 DeviceTable[DEVICE_EDS0067_TEMP].Name = "Temperature" 465 DeviceTable[DEVICE_EDS0067_TEMP].Parameter = "Temperature" 466 DeviceTable[DEVICE_EDS0067_TEMP].Command = "" 467 DeviceTable[DEVICE_EDS0067_TEMP].Services = {TYPE_TEMP_C, TYPE_TEMP_F, TYPE_IGNORE} 468 469 DeviceTable[DEVICE_EDS0067_LIGHT] = {} 470 DeviceTable[DEVICE_EDS0067_LIGHT].Device = "EDS0067" 471 DeviceTable[DEVICE_EDS0067_LIGHT].Name = "Light" 472 DeviceTable[DEVICE_EDS0067_LIGHT].Parameter = "Light" 473 DeviceTable[DEVICE_EDS0067_LIGHT].Command = "" 474 DeviceTable[DEVICE_EDS0067_LIGHT].Services = {TYPE_LIGHTSENSOR, TYPE_LIGHTSENSOR_ENERGY, TYPE_IGNORE} 475 476 DeviceTable[DEVICE_EDS0067_COUNTER1] = {} 477 DeviceTable[DEVICE_EDS0067_COUNTER1].Device = "EDS0067" 478 DeviceTable[DEVICE_EDS0067_COUNTER1].Name = "Counter 1" 479 DeviceTable[DEVICE_EDS0067_COUNTER1].Parameter = "Counter1" 480 DeviceTable[DEVICE_EDS0067_COUNTER1].Command = "" 481 DeviceTable[DEVICE_EDS0067_COUNTER1].Services = {TYPE_IGNORE, TYPE_COUNTER} 482 483 DeviceTable[DEVICE_EDS0067_COUNTER2] = {} 484 DeviceTable[DEVICE_EDS0067_COUNTER2].Device = "EDS0067" 485 DeviceTable[DEVICE_EDS0067_COUNTER2].Name = "Counter 2" 486 DeviceTable[DEVICE_EDS0067_COUNTER2].Parameter = "Counter2" 487 DeviceTable[DEVICE_EDS0067_COUNTER2].Command = "" 488 DeviceTable[DEVICE_EDS0067_COUNTER2].Services = {TYPE_IGNORE, TYPE_COUNTER} 489 490 DeviceTable[DEVICE_EDS0067_LED] = {} 491 DeviceTable[DEVICE_EDS0067_LED].Device = "EDS0067" 492 DeviceTable[DEVICE_EDS0067_LED].Name = "LED" 493 DeviceTable[DEVICE_EDS0067_LED].Parameter = "LED" 494 DeviceTable[DEVICE_EDS0067_LED].Command = "LEDState" 495 DeviceTable[DEVICE_EDS0067_LED].Services = {TYPE_IGNORE, TYPE_LIGHTSWITCH} 496 497 DeviceTable[DEVICE_EDS0067_RELAY] = {} 498 DeviceTable[DEVICE_EDS0067_RELAY].Device = "EDS0067" 499 DeviceTable[DEVICE_EDS0067_RELAY].Name = "Relay" 500 DeviceTable[DEVICE_EDS0067_RELAY].Parameter = "Relay" 501 DeviceTable[DEVICE_EDS0067_RELAY].Command = "RelayState" 502 DeviceTable[DEVICE_EDS0067_RELAY].Services = {TYPE_IGNORE, TYPE_LIGHTSWITCH, TYPE_LIGHTSWITCH_ENERGY} 503 437 504 438 505 local DEBUG_MODE = false … … 463 530 SamplingPeriod = luup.variable_get( OWSERVER_SERVICE, "SamplingPeriod", lul_device ) 464 531 if(SamplingPeriod == nil) then 465 SamplingPeriod = 60532 SamplingPeriod = 20 466 533 luup.variable_set(OWSERVER_SERVICE, "SamplingPeriod", SamplingPeriod, lul_device) 467 534 end … … 523 590 luup.log(OWSERVER_LOG_NAME.."STARTDL: "..dlTime) 524 591 592 -- Poll the OW-SERVER and get details.xml 525 593 local code, res = luup.inet.wget("http://"..luup.devices[ParentDevice].ip.."/details.xml", 3, "", "") 526 594 … … 533 601 luup.log(OWSERVER_LOG_NAME.."START: "..startTime) 534 602 603 -- Process the XML file into a table 535 604 local Count = 0 536 605 local ni,c,label,xarg, empty 537 606 local i, j = 1, 1 538 607 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) 540 609 if not ni then 541 610 break … … 551 620 end 552 621 if c == "" then -- start tag 553 if( label== "owd") then622 if(string.sub(label, 1, 3) == "owd") then 554 623 Count = Count + 1 555 624 OWDevices[Count] = {} … … 559 628 end 560 629 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 563 634 local found 564 635 local Value 565 636 for Count = 1, #OWDevices do 566 637 found = 0 638 -- Search all child devices to find any with the ROMId 567 639 for k, v in pairs(ChildDevices) do 568 640 if(v.ROMId == OWDevices[Count]["ROMId"]) then 641 --luup.log(OWSERVER_LOG_NAME.."Processing: "..OWDevices[Count]["ROMId"].."::"..v.Param.." == "..OWDevices[Count][v.Param]) 569 642 found = 1 570 643 … … 587 660 end 588 661 662 -- Keep a loop buffer to allow rolling average filter 589 663 v.History[v.Counter] = round(OWDevices[Count][v.Param],1) 590 664 v.Counter = v.Counter + 1 … … 592 666 v.Counter = 1 593 667 v.Record = 1 668 else 669 v.Record = 0 594 670 end 595 671 … … 787 863 -- devices.htm?rom=4300000200AD1928&variable=UserByte1&value=75 788 864 function 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) 790 866 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) 792 868 local code, res = luup.inet.wget(lul_cmd, 3, "", "") 793 869 -
/trunk/D_OWServer.json
r1 r3 36 36 "ControlType":"label", 37 37 "Label":{ 38 "lang_tag":" next",38 "lang_tag":"devices_lab", 39 39 "text":"Devices Attached:" 40 40 }, … … 54 54 "Variable":"Devices", 55 55 "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, 56 84 "Left":175, 57 85 "Width":75,
Note: See TracChangeset
for help on using the changeset viewer.