Tried the following after deleting all items and setup new:
Code: Select all
commandArray = {}
-- loop through all the changed devices
for deviceName,deviceValue in pairs(devicechanged) do
print ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'")
-- Auswertung des Mi Schalters ( links ) für die Abendlichter
if (deviceName == 'Mi GW Schalter' and deviceValue == 'Switch 1') then
if ( uservariables['Szenario_Abendlichter'] == 'Off' ) then
print('Abendlichter sind aus, schalte ein...')
commandArray['Scene:Abendlichter'] = "On"
commandArray['Variable:Szenario_Abendlichter'] = 'On'
elseif ( uservariables['Szenario_Abendlichter'] == 'On' ) then
print('Abendlichter sind an, schalte aus...')
commandArray['Scene:Abendlichter'] = "Off"
commandArray['Variable:Szenario_Abendlichter'] = 'Off'
end
elseif ( deviceName == 'Mi GW Schalter' and deviceValue == 'Switch 2') then
print('-- KLingel sollte angehen --')
--commandArray['Mi GW Klingel'] = 'Set level 40'
commandArray['Mi GW Klingel'] = 'On'
end
end
return commandArray
First If Block works with the Scene, but why is the Last Event fired if i set the 'Mi GW Klingel' to 'On'? Don't understand this....
2017-11-15 14:18:19.312 LUA: Device based event fired on 'Mi GW Schalter', value 'Switch 2'
2017-11-15 14:18:19.312 LUA: -- KLingel sollte angehen --
2017-11-15 14:18:19.312 EventSystem: Script event triggered: Switch_Test
2017-11-15 14:18:19.513 LUA: Device based event fired on 'Mi GW Klingel', value 'Off'
commandArray['Mi GW Esszimmer'] = 'On' works and the Light at the Gateway is on......