Okay, so I decided to give this another go - and got a bit further
The sensor node showed up with two devices:
#, Name, Type, SubType
1: IR send Lighting 2 AC
2: IR data General Text
I created a Dummy hardware device "Heatpump", and 3 virtual sensors on it:
#, Name, Type, Subtype
1: Heatpump Mode, Light/Switch, Selector Switch
2: Heatpump Fan Speed, Light/Switch, Selector Switch
3: Heatpump Temperature, Thermostat, SetPoint
For device 1 and 2 I added the needed "Selector levels" (matching them with the LUA script).
Lastly I created an "Events" called "heatpumpir" and copy/pasted the script
Code: Select all
-- These are the configuration variables, set them according to your system
modelCmd = '0' -- Panasonic CKP, see https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/HeatpumpIRController/HeatpumpIRController.ino#L68
textDev = 'IR data' -- Name of the 'IR data' MySensors device
irSendDev = 'IR send' -- Name of the 'IR send' MySensors device
commandArray = {}
for key, value in pairs(devicechanged) do
if (key == 'Heatpump Mode' or key == 'Heatpump Fan Speed' or key == 'Heatpump Temperature') then
mode = otherdevices['Heatpump Mode']
fanSpeed = otherdevices['Heatpump Fan Speed']
temperature = math.floor(otherdevices_svalues['Heatpump Temperature'])
if (mode == 'Off') then powerModeCmd = '00'
elseif (mode == 'Auto') then powerModeCmd = '11'
elseif (mode == 'Heat') then powerModeCmd = '12'
elseif (mode == 'Cool') then powerModeCmd = '13'
elseif (mode == 'Dry') then powerModeCmd = '14'
elseif (mode == 'Fan') then powerModeCmd = '15'
elseif (mode == 'Maint') then powerModeCmd = '16'
end
if (fanSpeed == 'Auto') then fanSpeedCmd = '0'
elseif (fanSpeed == 'Fan 1') then fanSpeedCmd = '1'
elseif (fanSpeed == 'Fan 2') then fanSpeedCmd = '2'
elseif (fanSpeed == 'Fan 3') then fanSpeedCmd = '3'
elseif (fanSpeed == 'Fan 4') then fanSpeedCmd = '4'
elseif (fanSpeed == 'Fan 5') then fanSpeedCmd = '5'
end
temperatureCmd = string.format("%02x", temperature)
modeCmd = '00' .. modelCmd .. powerModeCmd .. fanSpeedCmd .. temperatureCmd
print(string.format('Mode: %s, fan: %s, temp: %s, modeCmd: %s', mode, fanSpeed, temperature, modeCmd))
commandArray['UpdateDevice'] = otherdevices_idx[textDev] .. '|0|' .. modeCmd
commandArray['IR send'] = 'On'
end
end
return commandArray
Now, when I change one of the selectors or the temperature setpoint the log shows:
Code: Select all
2016-10-31 12:56:44.055 LUA: Mode: Cool, fan: Fan 4, temp: 18, modeCmd: 00013412
2016-10-31 12:56:44.055 Error: EventSystem: in heatpumpir: [string "-- These are the configuration variables, set..."]:40: attempt to concatenate field '?' (a nil value)
2016-10-31 12:56:44.042 (Heatpump) Thermostat (Heatpump Temperature)
and every minute I get this error:
Code: Select all
2016-10-31 12:57:00.114 Error: EventSystem: in heatpumpir: [string "-- These are the configuration variables, set..."]:10: bad argument #1 to 'pairs' (table expected, got nil)
So - my question is - what should I do to fix the "table expected, got nil" error?
And - will that also fix the "attempt to concatenate field '?' (a nil value)" error?
|| UPDATE || .. a reboot fixed the concatenate error...
new log looks like this (and the node receives and sends commands...)
Code: Select all
2016-10-31 14:39:07.605 User: Admin initiated a switch command (5/Heatpump Mode/Set Level)
2016-10-31 14:39:07.633 LUA: Mode: Auto, fan: Fan 5, temp: 22, modeCmd: 00111516
2016-10-31 14:39:07.641 EventSystem: Script event triggered: heatpumpir
2016-10-31 14:39:07.607 (Heatpump) Light/Switch (Heatpump Mode)
2016-10-31 14:39:07.768 (MySensors) Lighting 2 (IR send)
2016-10-31 14:39:08.373 (MySensors) Lighting 2 (IR send)
2016-10-31 14:40:00.683 Error: EventSystem: in heatpumpir: [string "-- These are the configuration variables, set..."]:10: bad argument #1 to 'pairs' (table expected, got nil)