- Files:
-
- 20 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
/trunk/L_DenonReceiver1.lua
r20 r30 12 12 local DEN_DID = "urn:denon-com:serviceId:Receiver1" 13 13 14 local DEVICETYPE_DENON_AVR_CONTROL = "urn:schemas-denon-com:device:receiver :1"15 local DEVICEFILE_DENON_AVR_CONTROL = "D_DenonReceiver 1.xml"14 local DEVICETYPE_DENON_AVR_CONTROL = "urn:schemas-denon-com:device:receiverZone:1" 15 local DEVICEFILE_DENON_AVR_CONTROL = "D_DenonReceiverZone1.xml" 16 16 17 17 local MAX_VOLUME = 98 … … 22 22 local childDeviceZone = {} 23 23 24 local modelName = { 25 ["3808"]={ zones=3, inputs=13 } 24 local receiverDetails = { 25 ["AVR-3808EUR"]={ zones={3}, inputs={}, names={} }, 26 ["AVR-2112USA"]={ zones={2}, inputs={}, names={} }, 27 ["default"]={ zones={3}, inputs={}, names={} } 26 28 } 27 29 28 30 local denonDevice 31 32 -------------------------------------------------------------------------------- 33 -------------------------------------------------------------------------------- 34 -- UTILITIES 35 -------------------------------------------------------------------------------- 36 -------------------------------------------------------------------------------- 37 38 ------------------------------------------------------------ 39 -- Used when running code not on Vera 40 function set_debug_vars() 41 denonDevice = 'AVR-3808USA' 42 childDeviceZone = { Z1 = 'main zone', Z2 = 'zone two', Z3 = 'zone three' } 43 end 29 44 30 45 ------------------------------------------------------------ … … 33 48 end 34 49 35 ------------------------------------------------------------------------------------------ 36 function setVolume(device, value) 37 sendZoneCommand(device, 'MV', string.format("%02d", ((value>MAX_VOLUME) and MAX_VOLUME or value)), 'Volume set') 38 end 39 40 ------------------------------------------------------------------------------------------ 41 function sendZoneCommand(device, prefix, command, commandNameString) 42 local zone = findZone(device) 43 log((commandNameString) .. zone) 44 -- If this is not the main zone we need to change the prefix to the zone string 45 if (zone ~= "") then 46 prefix = zone 47 end 48 log("(sendZoneCommand)" .. prefix .. command) 49 denon3800ReceiverSend(prefix .. command) 50 end 51 52 ------------------------------------------------------------------------------------------ 53 function denon3800ReceiverSend(command) 54 local cmd = command 55 local startTime, endTime 56 local dataSize = string.len(cmd) 57 assert(dataSize <= 135) 58 startTime = socket.gettime() 59 luup.sleep(200) 60 if (luup.io.write(cmd) == false) then 61 log("(denon3800ReceiverSend) cannot send command " .. command .. " communications error", 1) 62 luup.set_failure(true) 63 return false 64 end 65 endTime = socket.gettime() 66 log("Request returned in " .. math.floor((endTime - startTime) * 1000) .. "ms") 67 return true 68 end 69 ------------------------------------------------------------------------------------------ 70 function handleResponse(data) 71 log("(handleResponse) data received " .. data) 72 local msgFrom = data:sub(1,1) 73 local msgType = data:sub(1,2) 74 local completeData = data 75 local data = data:sub(3) 76 local msgZone = nil 77 78 if (msgFrom == "Z") then 79 msgZone = findChild(denonDevice, msgType) 80 log("(handleResponse) message from zone: " .. tostring(msgZone)) 81 if (tonumber(data) ~= nil) then 82 msgType = "MV" 83 elseif (data == "OFF" or data == "ON") then 84 msgType = "PW" 85 elseif (sourceName[data] ~= nil) then 86 msgType = "SI" 87 else 88 msgType = data:sub(1,2) 89 data = data:sub(3) 90 end 91 elseif (msgFrom == "R") then 92 msgType = "RZ" 93 data = completeData 94 end 95 96 if(msgZone == nil) then msgZone = denonDevice end 97 processMessage (data, msgType, msgZone) 98 return true 99 end 100 ------------------------------------------------------------------------------------------ 101 local RECEIVER_RESPONSES = { 102 103 ["MV"] = { 104 description = "Volume level change", 105 handlerFunc = function (self, data, msgZone) 106 log("(response) data received MV " .. data .. " " .. self.description) 107 if ((string.find(data, "MAX")) == nil) then 108 local volume = string.format("%d",data:match("(%d*)")) 109 if volume:len() == 3 then 110 volume = ((tonumber(volume))/10) 111 end 112 if ((tonumber(volume)) >= 99) then 113 volume = 0 114 end 115 luup.variable_set(VOS_VID,"Volume",volume,msgZone) 116 return true 117 else 118 return false 119 end 120 end 121 }, 122 123 ["MU"] = { 124 description = "MUTE status change", 125 handlerFunc = function (self, data, msgZone) 126 log("(handlerFunction) Data: " .. data) 127 if (data == "OFF") then 128 luup.variable_set(VOS_VID,"Mute","0",msgZone) 129 elseif (data == "ON") then 130 luup.variable_set(VOS_VID,"Mute","1",msgZone) 131 else 132 log("(response) unkown mute command" .. data .. " " .. self.description) 133 end 134 log("(response) data received MU " .. data .. " " .. self.description) 135 return true 136 end 137 }, 138 139 ["PW"] = { 140 description = "Power status change", 141 handlerFunc = function (self, data, msgZone) 142 log("(handlerFunction) Data: " .. data) 143 if ((string.find(data, "STANDBY")) ~= nil or (string.find(data, "OFF")) ~= nil) then 144 luup.variable_set(SWP_SID,SWP_STATUS,"0",msgZone) 145 else 146 luup.variable_set(SWP_SID,SWP_STATUS,"1",msgZone) 147 end 148 log("(response) data received PW " .. data .. " " .. self.description) 149 return true 150 end 151 }, 152 153 ["SI"] = { 154 description = "INPUT source change", 155 handlerFunc = function (self, data, msgZone) 156 log("(handlerFunction) Data: " .. data) 157 luup.variable_set(IPS_IID,"Input",data,msgZone) 158 log("(response) data received SI " .. data .. " " .. self.description) 159 return true 160 end 161 }, 162 163 ["SV"] = { 164 description = "VIDEO source change", 165 handlerFunc = function (self, data, msgZone) 166 log("(handlerFunction) Data: " .. data) 167 luup.variable_set(IPS_IID,"Video",data,msgZone) 168 log("(response) data received SV " .. data .. " " .. self.description) 169 return true 170 end 171 }, 172 173 ["MS"] = { 174 description = "SURROUND mode change", 175 handlerFunc = function (self, data, msgZone) 176 log("(handlerFunction) Data: " .. data) 177 luup.variable_set(IPS_IID,"Surround",data,msgZone) 178 log("(response) data received MS " .. data .. " " .. self.description) 179 return true 180 end 181 }, 182 183 ["SS"] = { 184 description = "SOURCE function name", 185 handlerFunc = function (self, data, msgZone) 186 if (data:sub(1,3) == "FUN") then 187 data = data:sub(4) 188 local source, name = data:match("^(.-)%s(.+)$") 189 log("(handlerFunction) data received SS source:" .. source .. ":source name:" .. name ..":") 190 sourceName[source] = name 191 end 192 return true 193 end 194 }, 195 196 ["SY"] = { 197 description = "Model number", 198 handlerFunc = function (self, data, msgZone) 199 if (data:sub(1,2) == "MO") then 200 local modelName = data:sub(3) 201 modelName = modelName:gsub ("(%s+)$", "") 202 local zone1 = zoneNameTable.R1 or '' 203 luup.attr_set("name",modelName .. " - " .. zone1,denonDevice) 204 end 205 return true 206 end 207 }, 208 209 ["RZ"] = { 210 description = "zone names", 211 handlerFunc = function (self, data, msgZone) 212 local zone = data:sub(1,2) 213 local zoneName = data:sub(3) 214 if (zoneName == nil) 215 then zoneName = ("Zone" .. data:sub(2,2)) 216 end 217 zoneNameTable[zone] = zoneName 218 return true 219 end 220 } 221 222 } 223 224 ------------------------------------------------------------------------------------------ 225 function processMessage (data, msgType, msgZone) 226 227 log("(processMessage)" .. data .. ' ' .. msgType .. ' ' .. msgZone) 228 229 if (not msgType) then 230 msgType, data = checkMessage (data) 231 if (not msgType or tostring (msgType) == "") then 232 return false 233 end 234 end 235 236 local response = RECEIVER_RESPONSES[msgType] 237 238 if (response == nil) then 239 log("(processMessage) Unhandled message type '" .. msgType .. "'") 240 return false 241 end 242 243 if (type (response.handlerFunc) ~= "function") then 244 log("(processMessage) ERROR: Unknown message type, or message type handled incorrectly.") 245 return false 246 end 247 248 return response:handlerFunc (data, msgZone) 249 250 end 251 252 ------------------------------------------------------------------------------------------ 253 local function checkMessage (msg) 254 if (not msg or msg == "") then 255 log("(checkMessage) ERROR: Empty message.") 256 return nil 257 end 258 end 259 260 ------------------------------------------------------------------------------------------ 261 function findZone (lul_device) 50 -------------------------------------------------------------------------------- 51 function findZone(lul_device) 262 52 log("Trying to find zone for device " .. lul_device) 263 53 local DeviceId = tostring(luup.devices[lul_device].id) … … 272 62 return zone 273 63 end 274 ------------------------------------------------------------------------------------------ 275 64 65 -------------------------------------------------------------------------------- 66 function findChild(label) 67 return childDeviceZone[label] 68 end 69 70 -------------------------------------------------------------------------------- 71 -- make sure that variables have reasonable default values 72 local function check_var (var, default) 73 if (var == '' or var == nil) then 74 var = default 75 end 76 return var 77 end 78 79 -------------------------------------------------------------------------------- 80 -------------------------------------------------------------------------------- 81 -- OUTGOING COMMANDS 82 -------------------------------------------------------------------------------- 83 -------------------------------------------------------------------------------- 84 85 -------------------------------------------------------------------------------- 86 function setVolume(device, value) 87 sendZoneCommand(device, 'MV', string.format("%02d", ((value>MAX_VOLUME) and MAX_VOLUME or value)), 'Volume set') 88 end 89 90 -------------------------------------------------------------------------------- 91 function sendZoneCommand(device, prefix, command, commandNameString) 92 local zone = findZone(device) 93 log((commandNameString) .. zone) 94 -- If this is not the main zone we need to change the prefix to the zone string 95 if (zone ~= "Z1") then 96 prefix = zone 97 end 98 log("(sendZoneCommand)" .. prefix .. command) 99 denon3800ReceiverSend(prefix .. command) 100 end 101 102 -------------------------------------------------------------------------------- 103 function denon3800ReceiverSend(command) 104 local cmd = command 105 local startTime, endTime 106 local dataSize = string.len(cmd) 107 assert(dataSize <= 135) 108 startTime = socket.gettime() 109 luup.sleep(200) 110 if (luup.io.is_connected == false) then 111 log("(denon3800ReceiverSend) cannot send command " .. command .. " receiver not connected", 1) 112 luup.set_failure(true) 113 return false 114 end 115 if (luup.io.write(cmd, denonDevice) == false) then 116 log("(denon3800ReceiverSend) cannot send command " .. command .. " communications error", 1) 117 luup.set_failure(true) 118 return false 119 end 120 endTime = socket.gettime() 121 log("Request returned in " .. math.floor((endTime - startTime) * 1000) .. "ms") 122 return true 123 end 124 125 -------------------------------------------------------------------------------- 126 -------------------------------------------------------------------------------- 127 -- STARTUP FUNCTIONS 128 -------------------------------------------------------------------------------- 129 -------------------------------------------------------------------------------- 130 131 -------------------------------------------------------------------------------- 276 132 local function initialParameters(denonDevice) 277 278 luup.variable_set(IPS_IID,"Surround","0",denonDevice) 133 luup.variable_set(SWP_SID,SWP_STATUS,"0",denonDevice) 134 denon3800ReceiverSend("PW?") 135 136 for k, v in pairs(childDeviceZone) do 137 local child_id = k 138 luup.variable_set(SWP_SID, SWP_STATUS, "0",denonDevice) 139 luup.variable_set(IPS_IID, "Surround", "0" ,child_id) 140 luup.variable_set(IPS_IID, "Input", "0", child_id) 141 luup.variable_set(IPS_IID, "Video", "0", child_id) 142 luup.variable_set(VOS_VID, "Mute", "0", child_id) 143 luup.variable_set(VOS_VID, "Volume", "0", child_id) 144 end 145 279 146 denon3800ReceiverSend("MS?") 280 281 luup.variable_set(IPS_IID,"Input","0",denonDevice)282 147 denon3800ReceiverSend("SI?") 283 284 luup.variable_set(IPS_IID,"Video","0",denonDevice)285 148 denon3800ReceiverSend("SV?") 286 287 luup.variable_set(VOS_VID,"Mute","0",denonDevice)288 149 denon3800ReceiverSend("MU?") 289 290 luup.variable_set(VOS_VID,"Volume","0",denonDevice)291 150 denon3800ReceiverSend("MV?") 292 293 end 294 295 ------------------------------------------------------------------------------------------ 151 end 152 153 -------------------------------------------------------------------------------- 296 154 local function findChildren(ParentDevice) 297 155 for k, v in pairs(luup.devices) do … … 303 161 end 304 162 305 ------------------------------------------------------------------------------------------ 306 function findChild(ParentDevice, label) 307 return childDeviceZone[label] 308 end 309 310 ------------------------------------------------------------------------------------------ 311 local function createChildren(denonDevice) 163 -------------------------------------------------------------------------------- 164 function createChildren() 312 165 log("(createChildren) Starting") 313 166 child_devices = luup.chdev.start(denonDevice) 314 167 for k, v in pairs(zoneNameTable) do 315 log('(createChildren) k=' .. k .. 'v=' .. v) 316 if(k ~= "R1") then 317 local zoneNumber = k:sub(2,2) 318 local zoneName = v:gsub ("(%s+)$", "") 319 if (zoneName == "" or zoneName == nil) then 320 zoneName = "Denon AVR Zone: " .. zoneNumber 321 end 322 luup.chdev.append(denonDevice,child_devices, "Z" .. zoneNumber,zoneName,DEVICETYPE_DENON_AVR_CONTROL,DEVICEFILE_DENON_AVR_CONTROL,"","",true) 323 log("(createChildren) Zone number:" .. k .. " Zone name:" .. zoneName .. ".") 324 elseif(k == "R1") then 325 log("(createChildren) Zone number:" .. k .. " skipping main zone.") 326 else 327 log("(createChildren) should not get here.") 328 end 329 end 330 331 luup.chdev.sync(denonDevice,child_devices) 332 168 local zoneNumber = k:sub(2,2) 169 local zoneName = v:gsub ("(%s+)$", "") 170 zoneName = check_var(zoneName, "Denon AVR Zone: " .. zoneNumber) 171 luup.chdev.append(denonDevice,child_devices, "Z" .. zoneNumber, zoneName, 172 DEVICETYPE_DENON_AVR_CONTROL, DEVICEFILE_DENON_AVR_CONTROL, "", "", true) 173 log("(createChildren) Zone number:" .. k .. " Zone name:" .. zoneName .. ".") 174 end 175 176 luup.chdev.sync(denonDevice, child_devices) 333 177 334 178 -- setup lookup table from zone -> child … … 336 180 end 337 181 338 -------------------------------------------------------------------------------- ----------182 -------------------------------------------------------------------------------- 339 183 function receiverStartup(lul_device) 340 184 341 185 local ipAddress, trash, ipPort = string.match(luup.devices[lul_device].ip, "^([%w%.%-]+)(:?(%d-))$") 342 186 187 343 188 if (ipAddress and ipAddress ~= "") then 344 if (ipPort==nil) or (ipPort == "") then 345 ipPort = "23" 346 end 189 ipPort = check_var (ipPort, "23") 347 190 log(string.format ("(receiverStartup) ipAddress=%s, ipPort=%s", tostring (ipAddress), tostring (ipPort))) 348 191 luup.io.open (lul_device, ipAddress, ipPort) … … 352 195 denonDevice = lul_device 353 196 354 --Set initial power status 355 luup.variable_set(SWP_SID,SWP_STATUS,"0",denonDevice) 356 357 197 --Returns custom source names, creates table but names are not currently used. 198 deviceAvail = denon3800ReceiverSend("SSFUN ?") 199 200 --get zone names 201 local getZoneNames = 'http://' .. ipAddress .. '/ZONERENAME/r_zonerename.asp' 202 log("(receiverStartup) force AVR to send zone names" .. getZoneNames) status, response = luup.inet.wget(getZoneNames) 358 203 359 204 if (deviceAvail == false) then … … 361 206 return false 362 207 else 363 --Returns custom source names, creates table but names are not currently used.364 denon3800ReceiverSend("SSFUN ?")365 366 208 --main zone initial parameters 367 209 initialParameters(denonDevice) 368 369 --get zone names 370 local getZoneNames = 'http://' .. ipAddress .. '/ZONERENAME/r_zonerename.asp' 371 log("(receiverStartup) force AVR to send zone names" .. getZoneNames) 372 status, response = luup.inet.wget(getZoneNames) 373 --if (response == nil) then 374 --log("Problem receiving data from Denon AVR, this means that zone names have not been detected and will not be created") 375 --end 376 377 createChildren(denonDevice) 378 379 for k, v in pairs(zoneNameTable) do 380 if(k ~= "R1") then 381 local zoneNumber = k:sub(2,2) 382 denon3800ReceiverSend("Z" .. zoneNumber .. "?") 383 end 384 end 385 386 --Returns power status. 387 local deviceAvail = denon3800ReceiverSend("PW?") 210 211 -- we want to make sure we have time for the child zones to be filled in the zoneNameTable 212 luup.call_delay('add_children', 10, denonDevice) 213 214 for k, v in pairs(zoneNameTable) do 215 if(k ~= "R1") then 216 local zoneNumber = k:sub(2,2) 217 denon3800ReceiverSend("Z" .. zoneNumber .. "?") 218 end 219 end 388 220 389 221 --Returns model. … … 392 224 end 393 225 end 226 227 -------------------------------------------------------------------------------- 228 -------------------------------------------------------------------------------- 229 -- HANDLE INCOMING DATA 230 -------------------------------------------------------------------------------- 231 -------------------------------------------------------------------------------- 232 233 -------------------------------------------------------------------------------- 234 local function set_volume(dev, vol) 235 if vol:len() == 3 then 236 vol = ((tonumber(vol))/10) 237 end 238 if ((tonumber(vol)) >= 99) then 239 vol = 0 240 end 241 luup.variable_set(VOS_VID, "Volume", vol, dev) 242 end 243 244 -------------------------------------------------------------------------------- 245 local function set_mute(dev, val) 246 local mute_map = { OFF = '0', ON = '1' } 247 luup.variable_set(VOS_VID, "Mute", mute_map[val], dev) 248 end 249 250 -------------------------------------------------------------------------------- 251 local function set_power(dev, val) 252 local pw_map = { OFF = '0', ON = '1' } 253 luup.variable_set(SWP_SID, SWP_STATUS, pw_map[val], dev) 254 log("Power" .. val .. tostring(dev)) 255 end 256 257 -------------------------------------------------------------------------------- 258 local function set_source(dev, source) 259 luup.variable_set(IPS_IID, "Input", source, dev) 260 end 261 262 -------------------------------------------------------------------------------- 263 local function set_source_name(source, name) 264 log("(handlerFunction) data received SS source:" .. source .. ":source name:" .. name ..":") 265 sourceName[source] = name 266 end 267 268 -------------------------------------------------------------------------------- 269 local function set_surround_mode(dev, mode) 270 luup.variable_set(IPS_IID, "Surround", mode, dev) 271 end 272 273 -------------------------------------------------------------------------------- 274 local function set_model(modelName) 275 local zone1 = zoneNameTable.R1 or '' 276 luup.attr_set("name", modelName, denonDevice) 277 log('Setting Model To' .. modelName); 278 end 279 280 -------------------------------------------------------------------------------- 281 local function set_zone_name(zone, name) 282 zoneNameTable[zone] = name 283 end 284 285 -------------------------------------------------------------------------------- 286 local function set_video_source(dev, source) 287 luup.variable_set(IPS_IID,"Video", source, dev) 288 end 289 290 -------------------------------------------------------------------------------- 291 local cmds = { 292 293 -- MAIN ZONE: 294 {'^MV([%d]+)', function (...) set_volume (findChild('Z1'), ...) end}, -- MV<VOL> 295 {'^MU([%w]+)', function (...) set_mute (findChild('Z1'), ...) end}, -- MUON / MUOFF 296 {'^ZM([%w]+)', function (...) set_power (findChild('Z1'), ...) end}, -- ZMON / ZMOFF 297 {'^SI(.+)', function (...) set_source (findChild('Z1'), ...) end}, -- SI<source> 298 {'^MS(.+)', function (...) set_surround_mode (findChild('Z1'), ...) end}, -- MS<surround_mode> 299 {'^SV(.+)', function (...) set_video_source (findChild('Z1'), ...) end}, -- SV<video_source> 300 301 -- Other Zones: 302 {'^(Z[%d])([%d]+)', function (d, ...) set_volume (findChild(d), ...) end}, -- Z?<VOL> 303 {'^(Z[%d])(ON)', function (d, ...) set_power (findChild(d), ...) end}, -- Z?ON 304 {'^(Z[%d])(OFF)', function (d, ...) set_power (findChild(d), ...) end}, -- Z?OFF 305 {'^(Z[%d])MU([%w]+)', function (d, ...) set_mute (findChild(d), ...) end}, -- Z?MUON / Z?MUOFF 306 {'^(Z[%d])SI(.+)', function (d, ...) set_source (findChild(d), ...) end}, -- Z?SI<source> 307 {'^(Z[%s])MS(.+)', function (d, ...) set_surround_mode(findChild(d), ...) end}, -- Z?MS<surround_mode> 308 {'^(Z[%s])SV(.+)', function (d, ...) set_video_source (findChild(d), ...) end}, -- Z?SV<video_source> 309 310 -- Generic Receiver: 311 {'^SSFUN([%w]+)%s(.+)', set_source_name}, -- note: source names can have spaces! 312 {'^SYMO([%S]+)', set_model}, -- I'm assuming no spaces, but some special chars 313 {'^(R[%d])([%S].+)', set_zone_name}, -- note: zone names can have spaces! 314 {'^PWON', function(...) set_power(denonDevice, 'ON') end}, 315 {'^PWSTANDBY', function(...) set_power(denonDevice, 'OFF') end}, 316 317 } 318 319 -------------------------------------------------------------------------------- 320 local function try (func, m, ...) 321 if nil == m then return false end 322 -- luup.log ('match: '..table.concat ({m,...}, ' ')) 323 func (m, ...) 324 return true 325 end 326 327 -------------------------------------------------------------------------------- 328 function incoming_data(data) 329 -- log("(incoming_data) received " .. data) 330 331 for _,cmd in ipairs (cmds) do 332 if try (cmd[2], data:match(cmd[1])) then 333 return 334 end 335 end 336 337 log("UNHANDLED RETURN: " .. data) 338 end -
/trunk/D_DenonReceiver1.json
r20 r30 1 1 { 2 "flashicon": "icons/Binary_Light.swf", 3 "imgIconBody": "", 4 "imgIconDimmable": "", 5 "imgIconTurnable": "", 6 "imgIconMin": "pics/devices/Light_OFF.png", 7 "imgIconMax": "pics/devices/Light_ON.png", 8 "halloIconsDir": "pics/hallo", 9 "DisplayStatus": { 10 "Service": "urn:upnp-org:serviceId:SwitchPower1", 11 "Variable": "Status", 12 "MinValue": "0", 13 "MaxValue": "1" 14 }, 15 "doc_url": { 16 "doc_language": 1, 17 "doc_manual": 1, 18 "doc_version": 1, 19 "doc_platform": 0, 20 "doc_page": "devices" 21 }, 22 "ToggleButton": 1, 23 "Tabs": [{ 24 "Label": { 25 "lang_tag": "tabname_control", 26 "text": "Settings" 27 }, 28 "Position": "0", 29 "TabType": "flash", 30 "ControlGroup": [{ 31 "id": "1", 32 "isSingle": "1" 33 }, { 34 "id": "2", 35 "isSingle": "1" 36 }, { 37 "id": "3", 38 "type": "slider" 39 }, { 40 "id": "4", 41 "type": "info" 42 },], 43 "Control": [{ 44 "ControlGroup": "1", 45 "ControlType": "button", 46 "Label": { 47 "lang_tag": "cmd_off", 48 "text": "Off" 49 }, 50 "Display": { 51 "Service": "urn:upnp-org:serviceId:SwitchPower1", 52 "Variable": "Status", 53 "Value": "0", 54 "Top": 60, 55 "Left": 10, 56 "Width": 70, 57 "Height": 35 58 }, 59 "Command": { 60 "Service": "urn:upnp-org:serviceId:SwitchPower1", 61 "Action": "SetTarget", 62 "Parameters": [{ 63 "Name": "newTargetValue", 64 "Value": "0" 65 }] 66 } 67 }, { 68 "ControlGroup": "2", 69 "ControlType": "button", 70 "Label": { 71 "lang_tag": "cmd_on", 72 "text": "On" 73 }, 74 "Display": { 75 "Service": "urn:upnp-org:serviceId:SwitchPower1", 76 "Variable": "Status", 77 "Value": "1", 78 "Top": 60, 79 "Left": 100, 80 "Width": 70, 81 "Height": 35 82 }, 83 "Command": { 84 "Service": "urn:upnp-org:serviceId:SwitchPower1", 85 "Action": "SetTarget", 86 "Parameters": [{ 87 "Name": "newTargetValue", 88 "Value": "1" 89 }] 90 } 91 }, { 92 "ControlGroup": "3", 93 "ControlHeader": "1", 94 "ControlType": "slider", 95 "Display": { 96 "Service": "urn:micasaverde-com:serviceId:Volume1", 97 "Variable": "Volume", 98 "ID": "Volume", 99 "MinValue": "00", 100 "MaxValue": "98", 101 "Top": 40, 102 "Left": 10, 103 "Width": 200, 104 "Height": 35 105 }, 106 "Command": { 107 "Service": "urn:denon-com:serviceId:Receiver1", 108 "Action": "SetVolumeTarget", 109 "Parameters": [{ 110 "Name": "newTargetValue", 111 "ID": "Volume" 112 }] 113 } 114 }, { 115 "ControlGroup": "4", 116 "ControlHeader": "1", 117 "ControlType": "variable", 118 "Display": { 119 "Service": "urn:micasaverde-com:serviceId:Volume1", 120 "Variable": "Volume", 121 "Top": 10, 122 "Left": 200, 123 "Width": 70, 124 "Height": 35 125 } 126 }, { 127 "ControlType": "label", 128 "Label": { 129 "lang_tag": "lblMsg", 130 "text": "Input:" 131 }, 132 "Display": { 133 "Top": 10, 134 "Left": 10, 135 "Width": 75, 136 "Height": 35 137 } 138 }, { 139 "ControlGroup": "5", 140 "ControlType": "variable", 141 "Display": { 142 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 143 "Variable": "Input", 144 "Top": 10, 145 "Left": 100, 146 "Width": 70, 147 "Height": 35 148 } 149 }, { 150 "ControlType": "button", 151 "Label": { 152 "lang_tag": "volume_down", 153 "text": "- Volume" 154 }, 155 "Display": { 156 "Top": 85, 157 "Left": 10, 158 "Width": 70, 159 "Height": 35 160 }, 161 "Command": { 162 "Service": "urn:micasaverde-com:serviceId:Volume1", 163 "Action": "Down", 164 "Parameters": [] 165 } 166 }, { 167 "ControlType": "button", 168 "Label": { 169 "lang_tag": "volume_up", 170 "text": "+ Volume" 171 }, 172 "Display": { 173 "Top": 85, 174 "Left": 100, 175 "Width": 70, 176 "Height": 35 177 }, 178 "Command": { 179 "Service": "urn:micasaverde-com:serviceId:Volume1", 180 "Action": "Up", 181 "Parameters": [] 182 } 183 }, { 184 "ControlType": "button", 185 "Label": { 186 "lang_tag": "unmute", 187 "text": "Unmute" 188 }, 189 "Display": { 190 "Top": 115, 191 "Left": 10, 192 "Width": 70, 193 "Height": 35 194 }, 195 "Command": { 196 "Service": "urn:micasaverde-com:serviceId:Volume1", 197 "Action": "Mute", 198 "Parameters": [{ 199 "Name": "newTargetValue", 200 "Value": "0" 201 }] 202 } 203 }, { 204 "ControlType": "button", 205 "Label": { 206 "lang_tag": "mute", 207 "text": "Mute" 208 }, 209 "Display": { 210 "Top": 115, 211 "Left": 100, 212 "Width": 70, 213 "Height": 35 214 }, 215 "Command": { 216 "Service": "urn:micasaverde-com:serviceId:Volume1", 217 "Action": "Mute", 218 "Parameters": [{ 219 "Name": "newTargetValue", 220 "Value": "1" 221 }] 222 } 223 }, { 224 "ControlType": "button", 225 "Label": { 226 "lang_tag": "Input1", 227 "text": "TV/CBL" 228 }, 229 "Display": { 230 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 231 "Variable": "Input", 232 "Value": "TV/CBL", 233 "Top": 145, 234 "Left": 10, 235 "Width": 65, 236 "Height": 35 237 }, 238 "Command": { 239 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 240 "Action": "Input1", 241 "Parameters": [] 242 } 243 }, { 244 "ControlType": "button", 245 "Label": { 246 "lang_tag": "Input2", 247 "text": "Boxee" 248 }, 249 "Display": { 250 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 251 "Variable": "Input", 252 "Value": "HDP", 253 "Top": 145, 254 "Left": 100, 255 "Width": 65, 256 "Height": 35 257 }, 258 "Command": { 259 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 260 "Action": "Input2", 261 "Parameters": [] 262 } 263 }, { 264 "ControlType": "button", 265 "Label": { 266 "lang_tag": "Input3", 267 "text": "DVD" 268 }, 269 "Display": { 270 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 271 "Variable": "Input", 272 "Value": "DVD", 273 "Top": 145, 274 "Left": 190, 275 "Width": 65, 276 "Height": 35 277 }, 278 "Command": { 279 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 280 "Action": "Input3", 281 "Parameters": [] 282 } 283 }, { 284 "ControlType": "button", 285 "Label": { 286 "lang_tag": "Input4", 287 "text": "NET/USB" 288 }, 289 "Display": { 290 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 291 "Variable": "Input", 292 "Value": "NET/USB", 293 "Top": 145, 294 "Left": 280, 295 "Width": 65, 296 "Height": 35 297 }, 298 "Command": { 299 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 300 "Action": "Input4", 301 "Parameters": [] 302 } 303 }, { 304 "ControlType": "button", 305 "Label": { 306 "lang_tag": "Input5", 307 "text": "TUNER" 308 }, 309 "Display": { 310 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 311 "Variable": "Input", 312 "Value": "TUNER", 313 "Top": 170, 314 "Left": 10, 315 "Width": 65, 316 "Height": 35 317 }, 318 "Command": { 319 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 320 "Action": "Input5", 321 "Parameters": [] 322 } 323 }, { 324 "ControlType": "button", 325 "Label": { 326 "lang_tag": "Input6", 327 "text": "CD" 328 }, 329 "Display": { 330 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 331 "Variable": "Input", 332 "Value": "CD", 333 "Top": 170, 334 "Left": 100, 335 "Width": 65, 336 "Height": 35 337 }, 338 "Command": { 339 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 340 "Action": "Input6", 341 "Parameters": [] 342 } 343 }, { 344 "ControlType": "button", 345 "Label": { 346 "lang_tag": "Input7", 347 "text": "PHONO" 348 }, 349 "Display": { 350 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 351 "Variable": "Input", 352 "Value": "PHONO", 353 "Top": 170, 354 "Left": 190, 355 "Width": 65, 356 "Height": 35 357 }, 358 "Command": { 359 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 360 "Action": "Input7", 361 "Parameters": [] 362 } 363 }, { 364 "ControlType": "button", 365 "Label": { 366 "lang_tag": "Input8", 367 "text": "SAT" 368 }, 369 "Display": { 370 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 371 "Variable": "Input", 372 "Value": "SAT", 373 "Top": 170, 374 "Left": 280, 375 "Width": 65, 376 "Height": 35 377 }, 378 "Command": { 379 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 380 "Action": "Input8", 381 "Parameters": [] 382 } 383 }, { 384 "ControlType": "button", 385 "Label": { 386 "lang_tag": "Input9", 387 "text": "VCR" 388 }, 389 "Display": { 390 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 391 "Variable": "Input", 392 "Value": "VCR", 393 "Top": 195, 394 "Left": 10, 395 "Width": 65, 396 "Height": 35 397 }, 398 "Command": { 399 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 400 "Action": "Input9", 401 "Parameters": [] 402 } 403 }, { 404 "ControlType": "button", 405 "Label": { 406 "lang_tag": "Input10", 407 "text": "DVR" 408 }, 409 "Display": { 410 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 411 "Variable": "Input", 412 "Value": "DVR", 413 "Top": 195, 414 "Left": 100, 415 "Width": 65, 416 "Height": 35 417 }, 418 "Command": { 419 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 420 "Action": "Input10", 421 "Parameters": [] 422 } 423 }, { 424 "ControlType": "button", 425 "Label": { 426 "lang_tag": "DiscreteinputPC", 427 "text": "V.AUX" 428 }, 429 "Display": { 430 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 431 "Variable": "Input", 432 "Value": "V.AUX", 433 "Top": 195, 434 "Left": 190, 435 "Width": 65, 436 "Height": 30 437 }, 438 "Command": { 439 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 440 "Action": "DiscreteinputPC", 441 "Parameters": [] 442 } 443 }, { 444 "ControlType": "button", 445 "Label": { 446 "lang_tag": "DiscreteinputVCR", 447 "text": "XM" 448 }, 449 "Display": { 450 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 451 "Variable": "Input", 452 "Value": "XM", 453 "Top": 195, 454 "Left": 280, 455 "Width": 65, 456 "Height": 30 457 }, 458 "Command": { 459 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 460 "Action": "DiscreteinputVCR", 461 "Parameters": [] 462 } 463 }, { 464 "ControlType": "button", 465 "Label": { 466 "lang_tag": "DiscreteinputDVI", 467 "text": "IPOD" 468 }, 469 "Display": { 470 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 471 "Variable": "Input", 472 "Value": "IPOD", 473 "Top": 220, 474 "Left": 10, 475 "Width": 65, 476 "Height": 30 477 }, 478 "Command": { 479 "Service": "urn:micasaverde-com:serviceId:InputSelection1", 480 "Action": "DiscreteinputDVI", 481 "Parameters": [] 482 } 483 }] 484 }, { 485 "Label": { 486 "lang_tag": "settings", 487 "text": "Settings" 488 }, 489 "Position": "1", 490 "TabType": "javascript", 491 "ScriptName": "shared.js", 492 "Function": "simple_device" 493 }, { 494 "Label": { 495 "lang_tag": "advanced", 496 "text": "Advanced" 497 }, 498 "Position": "2", 499 "TabType": "javascript", 500 "ScriptName": "shared.js", 501 "Function": "advanced_device" 502 }, { 503 "Label": { 504 "lang_tag": "device_options", 505 "text": "Device Options" 506 }, 507 "Position": "3", 508 "TabType": "javascript", 509 "ScriptName": "shared.js", 510 "Function": "device_zwave_options" 511 }, { 512 "Label": { 513 "lang_tag": "logs", 514 "text": "Logs" 515 }, 516 "Position": "4", 517 "TabType": "javascript", 518 "ScriptName": "shared.js", 519 "Function": "device_logs" 520 }, { 521 "Label": { 522 "lang_tag": "notifications", 523 "text": "Notifications" 524 }, 525 "Position": "5", 526 "TabType": "javascript", 527 "ScriptName": "shared.js", 528 "Function": "device_notifications" 529 }], 530 "sceneList": { 531 "group_1": { 532 "cmd_1": { 533 "label": "ON", 534 "serviceId": "urn:upnp-org:serviceId:SwitchPower1", 535 "action": "SetTarget", 536 "arguments": { 537 "newTargetValue": "1" 538 }, 539 "display": { 540 "service": "urn:upnp-org:serviceId:SwitchPower1", 541 "variable": "Status", 542 "value": "1" 543 } 544 }, 545 "cmd_2": { 546 "label": "OFF", 547 "serviceId": "urn:upnp-org:serviceId:SwitchPower1", 548 "action": "SetTarget", 549 "arguments": { 550 "newTargetValue": "0" 551 }, 552 "display": { 553 "service": "urn:upnp-org:serviceId:SwitchPower1", 554 "variable": "Status", 555 "value": "0" 556 } 557 } 558 } 559 }, 560 "eventList": { 561 "event_1": { 562 "label": "A device is turned on or off", 563 "serviceId": "urn:upnp-org:serviceId:SwitchPower1", 564 "argumentList": { 565 "argument_1": { 566 "dataType": "boolean", 567 "defaultValue": "1", 568 "allowedValueList": { 569 "Off": "0", 570 "On": "1" 571 }, 572 "name": "Status", 573 "comparisson": "=", 574 "prefix": "Which mode", 575 "suffix": "" 576 } 577 } 578 } 579 }, 580 "DeviceType": "urn:schemas-denon-com:device:receiver:1", 581 "device_type": "urn:schemas-denon-com:device:receiver:1" 2 "flashicon": "icons/IR_Transmitter.swf", 3 "imgIconBody": "", 4 "imgIconDimmable": "", 5 "imgIconTurnable": "", 6 "imgIconMin": "", 7 "imgIconMax": "", 8 "halloIconsDir": "pics/hallo", 9 "inScene": "1", 10 "DisplayStatus": { 11 }, 12 "doc_url": { 13 "doc_language": 1, 14 "doc_manual": 1, 15 "doc_version": 1, 16 "doc_platform": 0, 17 "doc_page": "devices" 18 }, 19 "Tabs": [ 20 { 21 "Label": { 22 "lang_tag": "tabname_control", 23 "text": "Settings" 24 }, 25 "Position": "0", 26 "TabType": "flash", 27 "SceneGroup": [ 28 { 29 "id": "1", 30 "top": "0.5", 31 "left": "0", 32 "x": "2", 33 "y": "2.5" 34 } 35 ], 36 "ControlGroup": [ 37 { 38 "id": "1", 39 "isSingle": "1", 40 "scenegroup": "1" 41 }, 42 { 43 "id": "2", 44 "isSingle": "1", 45 "scenegroup": "1" 46 }, 47 { 48 "id": "3", 49 "isSingle": "1", 50 "scenegroup": "1" 51 } 52 ], 53 "Control": [ 54 { 55 "ControlGroup": "1", 56 "ControlType": "button", 57 "top": "1.5", 58 "left": "0", 59 "Label": { 60 "lang_tag": "cmd_off", 61 "text": "Off" 62 }, 63 "Display": { 64 "Service": "urn:upnp-org:serviceId:SwitchPower1", 65 "Variable": "Status", 66 "Value": "0", 67 "Top": 25, 68 "Left": 50, 69 "Width": 75, 70 "Height": 20 71 }, 72 "Command": { 73 "Service": "urn:upnp-org:serviceId:SwitchPower1", 74 "Action": "SetTarget", 75 "Parameters": [ 76 { 77 "Name": "newTargetValue", 78 "Value": "0" 79 } 80 ] 81 } 82 }, 83 { 84 "ControlGroup": "1", 85 "ControlType": "button", 86 "Label": { 87 "lang_tag": "cmd_on", 88 "text": "On" 89 }, 90 "top": "1.5", 91 "left": "1", 92 "Display": { 93 "Service": "urn:upnp-org:serviceId:SwitchPower1", 94 "Variable": "Status", 95 "Value": "1", 96 "Top": 25, 97 "Left": 145, 98 "Width": 75, 99 "Height": 20 100 }, 101 "Command": { 102 "Service": "urn:upnp-org:serviceId:SwitchPower1", 103 "Action": "SetTarget", 104 "Parameters": [ 105 { 106 "Name": "newTargetValue", 107 "Value": "1" 108 } 109 ] 110 } 111 }, 112 ] 113 }, 114 { 115 "Label": { 116 "lang_tag": "settings", 117 "text": "Settings" 118 }, 119 "Position": "1", 120 "TabType": "javascript", 121 "ScriptName": "shared.js", 122 "Function": "simple_device" 123 }, 124 { 125 "Label": { 126 "lang_tag": "advanced", 127 "text": "Advanced" 128 }, 129 "Position": "2", 130 "TabType": "javascript", 131 "ScriptName": "shared.js", 132 "Function": "advanced_device" 133 } 134 ], 135 "DeviceType": "urn:schemas-denon-com:device:receiver:1", 136 "device_type": "urn:schemas-denon-com:device:receiver:1" 582 137 } -
/trunk/I_DenonReceiver1.xml
r20 r30 7 7 local denonLib 8 8 9 function add_children() 10 denonLib.createChildren() 11 end 12 9 13 function startup(lul_device) 10 14 if (package.path:find ("/etc/cmh-ludl/?.lua;/etc/cmh-lu/?.lua", 1, true) == nil) then … … 12 16 end 13 17 package.loaded.L_DenonLib1 = nil 14 denonLib = require("L_DenonReceiver1") 18 denonLib = require("L_DenonReceiver1") 15 19 denonLib.receiverStartup(lul_device) 16 20 end 17 21 18 22 </functions> 19 23 <incoming> … … 23 27 dataLength = string.len(data) 24 28 if (dataLength ~= "") then 25 denonLib. handleResponse(data)29 denonLib.incoming_data(data) 26 30 else 27 31 denonLib.log("(incoming) No response received.") … … 179 183 if (zone == "") then 180 184 cmd = (value == "1") and "PWON" or "PWSTANDBY" 185 elseif (zone == "Z1") then 186 cmd = "ZM" .. ((value == "1") and "ON" or "OFF") 181 187 else 182 188 cmd = zone .. ((value == "1") and "ON" or "OFF") 183 end 189 end 184 190 denonLib.denon3800ReceiverSend(cmd) 185 191 </run>
Note: See TracChangeset
for help on using the changeset viewer.