Mikey wrote:Thanks for your reply. Actually I would like to do two things:
1. Trigger a switch to turn on at this time to make a back up. I want to turn on the switch at a time and turn the switch off again after two minutes.
For this I would add the minute condition mentioned in the previous post. Lua time scripts run every minute (usually right after the minute changes). You can add an off delay of two minutes to the switch or use the same script to accomplish the "off" command. However, cannot see any benefit of having the dummy switch in Domoticz for this. I'd just run the backup script and that's that. If you want to keep the dummy, you can add a schedule for the switch as well (turn on/off at certain time)
Mikey wrote:2. I want to trigger a motion sensor and turn on a light when there's motion. But I want to do different scenes if there's different daytime. I already have this script, but I only trigger it with days and hours like:
Code: Select all
if (globalvariables['Security']) == 'Disarmed' or devicechanged['Dummy Disarmed'] == 'On' then
if ((otherdevices['Bewegungssensor_WZ'] == 'On' and tonumber(w) < 20) and otherdevices['Licht_WZ'] == 'Off') then
commandArray['Licht_WZ'] = 'On'
print('Erste Moeglichkeit')
elseif ((otherdevices['Bewegungssensor_WZ'] == 'Off' and tonumber(w) < 20) and otherdevices['Licht_WZ'] == 'On') then
print('Zweite Moeglichkeit')
if (((dayNow > 0) and (dayNow < 6)) and ((hourNow >= 7) and (hourNow < 23))) then
commandArray['Licht_WZ'] = 'Off AFTER 3600'
print('Es ist Wochentag zwischen 7 und 23 Uhr')
elseif ((dayNow > 0) and (dayNow < 6)) and (((hourNow > 23) and (hourNow < 0)) or ((hourNow >= 0) and (hourNow < 7))) then
commandArray['Licht_WZ'] = 'Off AFTER 300'
print('Es ist Wochentag zwischen 23 und 7 Uhr')
elseif (((dayNow == 0) or (dayNow == 6)) and ((hourNow >= 7) and (hourNow < 23))) then
commandArray['Licht_WZ'] = 'Off AFTER 3600'
print('Es ist Wochenende zwischen 7 und 23 Uhr')
elseif ((dayNow == 0) or (dayNow == 6)) and (((hourNow > 23) and (hourNow < 0)) or ((hourNow >= 0) and (hourNow < 7))) then
commandArray['Licht_WZ'] = 'Off AFTER 1200'
print('Es ist Wochenende zwischen 23 und 7 Uhr')
end
But I would like to trigger it more exactly.
Do you have any idea
Probably you mean the trigger is a motion sensor and action is turning on the light? This needs a
device script that triggers exactly when the motion sensor turns on (/ or off in case you need). It would be something like:
Code: Select all
if devicechanged['Bewegungssensor_W'] == 'On' and otherdevices['Licht_WZ'] == 'Off' then
if dayNow > 0 and dayNow < 6 and hourNow >= 7 and hourNow < 23 and minuteNow > XX and minuteNow < XX then
...
end
end
Maybe you do not need the minute condition anymore when the script runs only when motion sensor is active?
So, if you want to react on device change use a device script with "if devicechanged..." condition at the start and additional time based condition to have a different action based on the current time. Then if you want to run or check something each minute, use a time script....
