Page 1 of 1

Devicechanged script not triggered

Posted: Friday 07 September 2018 22:43
by Piacco
Hello, i have a Itho ventilation system with a remote control en Itho ESP.
When i press a button on my remote control i want to update a selector switch in Domoticz.
To update the selector switch i use a LUA script, only this script won't run, in my devices tab i see that when i press a button on the remote control that Itho_actuele_stand is updated, what do i wrong?

Code: Select all

commandArray = {}
if (devicechanged['Itho_actuele_stand'] == '1.00' and otherdevices['Ihto Ventilatie'] ~= 'Low') then
commandArray['UpdateDevice'] = '290|10|10'
elseif (devicechanged['Itho_actuele_stand'] == '2.00' and otherdevices['Ihto Ventilatie'] ~= 'Medium') then
commandArray['UpdateDevice'] = '290|20|20'
elseif (devicechanged['Itho_actuele_stand'] == '3.00' and otherdevices['Ihto Ventilatie'] ~= 'High') then
commandArray['UpdateDevice'] = '290|30|30'
elseif (devicechanged['Itho_actuele_stand'] == '13.00' and otherdevices['Ihto Ventilatie'] ~= 'Timer1') then
commandArray['UpdateDevice'] = '290|40|40'
elseif (devicechanged['Itho_actuele_stand'] == '23.00' and otherdevices['Ihto Ventilatie'] ~= 'Timer2') then
commandArray['UpdateDevice'] = '290|50|50'
elseif (devicechanged['Itho_actuele_stand'] == '33.00' and otherdevices['Ihto Ventilatie'] ~= 'Timer3') then
commandArray['UpdateDevice'] = '290|60|60'
end
return commandArray

Re: Devicechanged script not triggered

Posted: Saturday 08 September 2018 15:52
by SweetPants
Try to add some print statements so you know if/where your script fails.

Re: Devicechanged script not triggered

Posted: Sunday 09 September 2018 13:04
by Piacco
I have changed the script into:

Code: Select all

return {
	on = {
		devices = {
			'Itho_actuele_stand'
		}
	},
	execute = function(domoticz, device)
	    
if (device['Itho_actuele_stand'] == '1.00' and otherdevices['Ihto Ventilatie'] ~= 'Low') then
        domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
        commandArray['UpdateDevice'] = '290|10|10'
    elseif (device['Itho_actuele_stand'] == '2.00' and otherdevices['Ihto Ventilatie'] ~= 'Medium') then
        domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
        commandArray['UpdateDevice'] = '290|20|20'
    elseif (device['Itho_actuele_stand'] == '3.00' and otherdevices['Ihto Ventilatie'] ~= 'High') then
        domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
        commandArray['UpdateDevice'] = '290|30|30'
    elseif (device['Itho_actuele_stand'] == '13.00' and otherdevices['Ihto Ventilatie'] ~= 'Timer1') then
        domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
        commandArray['UpdateDevice'] = '290|40|40'
    elseif (device['Itho_actuele_stand'] == '23.00' and otherdevices['Ihto Ventilatie'] ~= 'Timer2') then
        domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
        commandArray['UpdateDevice'] = '290|50|50'  
    elseif (device['Itho_actuele_stand'] == '33.00' and otherdevices['Ihto Ventilatie'] ~= 'Timer3') then
        domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
        commandArray['UpdateDevice'] = '290|60|60'
end
return commandArray	
	end
}

Now i can see that the script is triggerd, but the selector switch won't update :( i have (checked the idx of the selector switch)

Re: Devicechanged script not triggered

Posted: Sunday 09 September 2018 13:50
by HansieNL
Your nValues and sValues are the same. Have you tried to change the nValue to 1.

Code: Select all

commandArray['UpdateDevice'] = '290|1|10'