[error] Too many lines
Posted: Tuesday 09 July 2019 12:19
Hello,
Found a old post about this but it's a year back or so I guess the system has changed and better to start a new one
I get this error
But only when I call this function
it's part of my IKEA remote control script.
I added a selector switch to select the room(it's the part that isn't working) as well as I can see in the GUI which group that is correct active.
The function is to for matchning the selected name to the group to control.

Found a old post about this but it's a year back or so I guess the system has changed and better to start a new one
I get this error
Code: Select all
2019-07-09 12:09:10.372 Error: dzVents: Error: (2.4.24) IKEARemote: An error occurred when calling event handler IKEARemote
2019-07-09 12:09:10.372 Error: dzVents: Error: (2.4.24) IKEARemote: ...omoticz/scripts/dzVents/generated_scripts/IKEARemote.lua:179: Lua script execution exceeds maximum number of linesCode: Select all
local function findGroup(groupname)
local GroupNumber = 0
repeat
local GroupNumber = GroupNumber + 1
Group = groups[GroupNumber]
for device, attributes in pairs(control[Group]) do
if device == "name" then
if attributes == groupname then
selectedGroupNumber = GroupNumber
return
end
end
end
until GroupNumber == maxGroup
endI added a selector switch to select the room(it's the part that isn't working) as well as I can see in the GUI which group that is correct active.
The function is to for matchning the selected name to the group to control.
Code: Select all
groups = {'group1', 'group2', 'group3', 'group4', 'group5', 'group6' }
return {
on = { devices = { 'IKEA Remote*' }},
logging = { level = domoticz.LOG_DEBUG,
marker = "IKEARemote" },
data = { currentGroup = { initial = 1 }},
execute = function(dz, item)
control =
{
group3 = --Hallway
{
name = 'Taklampa Hall',
IKEAlamp = { idx = 40, blink = true },
IKEAlampGroup = { idx = 65, toggle = true, dimmer = true},
--spot2 = { idx = 17, toggle = true, dimmer = true},
--spot3 = { idx = 19, toggle = true, dimmer = true},
},
group1 = --Bedroom
{
name = 'Taklampa Sovrum',
IKEAlamp = { idx = 13, toggle = true, blink = true, dimmer = true}
},
group5 = --Lilvingroom
{
name = 'Taklampa Vardagsrum',
--spot1 = { idx = 65, toggle = true, dimmer = true},
IKEAlampGroup = { idx = 36, toggle = true, dimmer = true, blink = true}
--spot3 = { idx = 25, toggle = true, dimmer = true}
},
group4 = --Computeroom
{
name = 'Taklampa Datorrum',
IKEAlamp = { idx = 73, toggle = true, blink = true, dimmer = true}
},
group6 = --TvBench
{
name = 'Tv Bänk',
lamp = { idx = 42, toggle = true, blink = true},
TvGroup = { idx = 2, toggle = true, group = true}
},
group2 = --BedroomBlilnder
{
name = 'Rullgardin Sovrum',
blinder = { idx = 59, toggle = true, blinder = true },
},
}
local selectedGroupNumber = dz.data.currentGroup
local maxGroup = #groups
local dummyDimmer = dz.devices(82)
local function doAction(action, direction)
selectedGroup = groups[selectedGroupNumber]
dz.log("Current selected group is." .. selectedGroup)
dz.log("Current acction is........" .. action)
for device, attributes in pairs(control[selectedGroup]) do
if device == "name" then
dz.log('Name:.....................' .. attributes)
selectedGroupName = attributes
dz.devices('IKEA Remote Groups').switchSelector(attributes).silent()
else
dz.log("Current typ is............" .. device)
currentIDx = attributes["idx"]
dz.log("Current device IDx is....." .. currentIDx)
if attributes["group"] then currentDevice = dz.groups(currentIDx) else currentDevice = dz.devices(currentIDx) end
dz.log("Current device name is........." .. currentDevice.name)
for attribute, value in pairs(attributes) do
dz.log("Current attribute is......" .. attribute)
if attribute == action then
dz.log("Current acction is " .. action)
-- Blinking
if action == 'blink' then
local blinkDevice = dz.devices(currentDevice.name)
local blinkLevel = currentDevice.level
dz.log("Device " .. blinkDevice.name .. " will blink")
if blinkDevice.state == "Off" then
blinkDevice.switchOn()
blinkDevice.switchOff().afterSec(0.5)
else
blinkDevice.switchOff()
blinkDevice.switchOn().afterSec(0.5)
end
elseif action == 'dimmer' then
local dimDevice = dz.devices(currentDevice.name)
local dimLevel = dimDevice.level
local delay = 0
dz.log(dimDevice.name .. " direction is " .. direction)
if direction == "stop" then
dimDevice.cancelQueuedCommands()
dz.log('Stop dimming of ' .. dimDevice.name .. ' at ' .. dimLevel ..'%')
elseif direction == 'down' then
repeat
delay = delay + 0.1
if direction == "down" then dimLevel = dimLevel - 1 else dimLevel = dimLevel + 1 end
dz.log('Set ' .. dimDevice.name .. ' to dimLevel '.. dimLevel .. '%, after ' .. delay .. ' seconds', dz.LOG_INFO)
dimDevice.dimTo(dimLevel).afterSec(delay)
until dimLevel <= 0
elseif direction == 'up' then
repeat
delay = delay + 0.1
dimLevel = dimLevel + 1
dz.log('Set ' .. dimDevice.name .. ' to dimLevel '.. dimLevel .. '%, after ' .. delay .. ' seconds', dz.LOG_INFO)
dimDevice.dimTo(dimLevel).afterSec(delay)
until dimLevel >= 100
end
elseif action == 'toggle' then
local toggleDevice = currentDevice
if attributes["group"] then
toggleDevice.toggleGroup()
else
toggleDevice.toggleSwitch()
end
--if toggleState == 'On' then
-- dz.log("toggle device " .. toggleDevice.name)
-- toggleDevice.toggleSwitch()
-- end
end
end
end
end
end
end
local function findGroup(groupname)
local GroupNumber = 0
repeat
local GroupNumber = GroupNumber + 1
Group = groups[GroupNumber]
for device, attributes in pairs(control[Group]) do
if device == "name" then
if attributes == groupname then
selectedGroupNumber = GroupNumber
return
end
end
end
until GroupNumber == maxGroup
end
local action = 'blink'
local direction = 'up'
if item.state == 'Click' and item.name == 'IKEA Remote Left' then
selectedGroupNumber = selectedGroupNumber - 1
if selectedGroupNumber == 0 then selectedGroupNumber = maxGroup end
elseif item.state == 'Click' and item.name == 'IKEA Remote Right' then
selectedGroupNumber = selectedGroupNumber + 1
if selectedGroupNumber > maxGroup then selectedGroupNumber = 1 end
elseif item.name == 'IKEA Remote' then
action = 'toggle'
elseif item.state == 'Hold' and item.name == "IKEA Remote Up" then
action = 'dimmer'
elseif item.state == 'Hold' and item.name == 'IKEA Remote Down' then
action = 'dimmer'
direction = 'down'
elseif item.state == 'Release' and item.name == 'IKEA Remote Down' or item.name == 'IKEA Remote Up' then
action = 'dimmer'
direction = 'stop'
elseif item.name == 'IKEA Remote Groups' then
findGroup(item.levelName)
else
dz.log('Unknown action requested; ignored' )
return
end
if item.state == 'Click' then
dz.log('Turning off ' .. item.name)
dz.devices(item.name).switchOff().silent()
end
doAction(action, direction)
dz.data.currentGroup = selectedGroupNumber
end
}