It's actually nothing much to it. Strange thing is it worked Sunday morning and without me doing anything (well, at least I'm not aware of changing anything related to this device template) I got the error.
Here's the code:
# #373 Private Method Listing
#
#
def log(line)
# This function logs a line to the log file of the device
log = File.open("/var/log/pluto/" + device_.devid_.to_s + "_Generic_Serial_Device.log", "a")
log.puts Time.now.to_s + " (Ruby script):" + line.to_s
log.close
end
###
# #384 Process Receive Command For Child
#
#
cmdId = cmd.id_ # Command ID: ON, OFF, SET LEVEL
cmdTo = cmd.devidto_ # Device ID in LinuxMCE
devPort = device_.childdevices_[cmdTo].devdata_[12] # 12 contains a port/channel
childType = device_.childdevices_[cmdTo].devtemplid_ # Template ID to know type of device: switch or dimmer
level = 0
log ("Command received for port " + devPort)
case cmdId
when 192 # ON
system('tdtool --on ' + devPort)
log ("Device set to ON")
when 193 # OFF
system('tdtool --off ' + devPort)
log ("Device set to OFF")
when 184 # Change level of dimmer
level = cmd.params_[76].to_i*255/100
system('tdtool --dimlevel ' + level.to_s + ' --dim ' + devPort)
log ("Dim level set to " + level.to_s)
end
###