if [time set in switch <> "0:00"
If actual time >= [time set in switch]
do actions..
[time set in switch] = "0:00"
endif
endif
The only thing my wife needs to do is setting the time in the timer

Moderator: leecollings
For the dzVents script below you will need a selector switch. Level 0 should be named 'Off' and other levels can be times in hh:mm format. When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Code: Select all
-- Alarm clock [ dzVents >= 2.4 ]
scriptVar = '20191030 Alarmclock'
return
{
on =
{
timer = { "at 00:07" }, -- daily run once to pick up target time
httpResponses = { scriptVar }, -- Trigger the handle Json part
},
logging = { level = domoticz.LOG_DEBUG },
execute = function(dz, item)
local alarmTime = dz.devices('Alarm clock').levelName
local minutesIn24Hours = 24 * 60
local now = dz.time -- Get current time into time object
local Time = require('Time')
local targetTime = Time(dz.time.rawDate .. ' ' .. alarmTime .. ':00') -- Create target time object
local function triggerAlarm(delay)
local message = 'tring, trrring, trrring alarmclock ringing now. Was set on '.. dz.time.rawDate .. ', at ' .. dz.time.rawTime
local url = dz.settings['Domoticz url'] .. "/json.htm?type=command¶m=addlogmessage&message=" .. dz.utils.urlEncode(message)
dz.openURL({ url = url, callback = scriptVar }).afterMin(math.floor(delay))
end
if not(item.isHTTPResponse) then
dz.log('Alarm time is set at : ' .. alarmTime)
local deltaMinutes = math.floor(now.compare(targetTime).minutes)
if now.compare(targetTime).compare < 1 then -- targetTime is in future
deltaMinutes = minutesIn24Hours - deltaMinutes
end
dz.log('Alarmactions will be triggered in ' .. deltaMinutes .. ' minutes' ,dz.LOG_DEBUG)
triggerAlarm(deltaMinutes)
else
-- do wakeup actions.. here
dz.log('wake up actions here....' ,dz.LOG_DEBUG)
end
end
}
Code: Select all
2020-10-31 14:05:00.484 Error: dzVents: Error: (3.0.2) sDate was invalid. Reset to 2020-10-31 14:5:0.320
Code: Select all
-- Alarm clock [ dzVents >= 2.4 ]
scriptVar = '20191030 Alarmclock'
return
{ active = true,
on =
{
timer = { 'every hour' }, -- hourly run once to pick up target time
httpResponses = { scriptVar }, -- Trigger the handle Json part
},
logging = { level = domoticz.LOG_DEBUG },
execute = function(dz, item)
local alarmTime = dz.devices('Wekker').levelName
local minutesIn24Hours = 24 * 60
local now = dz.time -- Get current time into time object
local Time = require('Time')
local targetTime = Time(dz.time.rawDate .. ' ' .. alarmTime .. ':00') -- Create target time object
local function triggerAlarm(delay)
local message = 'tring, trrring, trrring alarmclock ringing now. Was set on '.. dz.time.rawDate .. ', at ' .. dz.time.rawTime
local url = dz.settings['Domoticz url'] .. "/json.htm?type=command¶m=addlogmessage&message=" .. dz.utils.urlEncode(message)
dz.openURL({ url = url, callback = scriptVar }).afterMin(math.floor(delay))
end
if not(item.isHTTPResponse) then
dz.log('Alarm time is set at : ' .. alarmTime)
local deltaMinutes = math.floor(now.compare(targetTime).minutes)
if now.compare(targetTime).compare < 1 then -- targetTime is in future
deltaMinutes = minutesIn24Hours - deltaMinutes
end
dz.log('Alarmactions will be triggered in ' .. deltaMinutes .. ' minutes' ,dz.LOG_DEBUG)
triggerAlarm(deltaMinutes)
else
-- do wakeup actions.. here
dz.log('wake up actions here....' ,dz.LOG_DEBUG)
dz.devices('Kachel badkamer').switchOn()
dz.devices('Kachel badkamer').switchOff().afterMin(15)
dz.openURL('http://192.xxx.x.xxx:5005/Slaapkamer/volume/10')
dz.openURL('http://192.xxx.x.xxx:5005/Slaapkamer/unmute')
dz.openURL('http://192.xxx.x.xxx:5005/Slaapkamer/favorite/ClassicFM')
dz.scenes('Awaken').switchOn()
end
end
}
That seems indeed to be the issue. Should be fixed in below modified script.
Code: Select all
-- Alarm clock [ dzVents >= 2.4 ]
scriptVar = '20191030 Alarmclock'
return
{ active = true,
on =
{
timer = { 'every hour' }, -- hourly run once to pick up target time
httpResponses = { scriptVar }, -- Trigger the handle Json part
},
logging = { level = domoticz.LOG_DEBUG },
execute = function(dz, item)
local alarmTime = dz.devices('Wekker').levelName
if alarmTime ~= 'Off' then
local minutesIn24Hours = 24 * 60
local now = dz.time -- Get current time into time object
local Time = require('Time')
local targetTime = Time(dz.time.rawDate .. ' ' .. alarmTime .. ':00') -- Create target time object
local function triggerAlarm(delay)
local message = 'tring, trrring, trrring alarmclock ringing now. Was set on '.. dz.time.rawDate .. ', at ' .. dz.time.rawTime
local url = dz.settings['Domoticz url'] .. "/json.htm?type=command¶m=addlogmessage&message=" .. dz.utils.urlEncode(message)
dz.openURL({ url = url, callback = scriptVar }).afterMin(math.floor(delay))
end
if not(item.isHTTPResponse) then
dz.log('Alarm time is set at : ' .. alarmTime)
local deltaMinutes = math.floor(now.compare(targetTime).minutes)
if now.compare(targetTime).compare < 1 then -- targetTime is in future
deltaMinutes = minutesIn24Hours - deltaMinutes
end
dz.log('Alarmactions will be triggered in ' .. deltaMinutes .. ' minutes' ,dz.LOG_DEBUG)
triggerAlarm(deltaMinutes)
else
-- do wakeup actions.. here
dz.log('wake up actions here....' ,dz.LOG_DEBUG)
dz.devices('Kachel badkamer').switchOn()
dz.devices('Kachel badkamer').switchOff().afterMin(15)
dz.openURL('http://192.xxx.x.xxx:5005/Slaapkamer/volume/10')
dz.openURL('http://192.xxx.x.xxx:5005/Slaapkamer/unmute')
dz.openURL('http://192.xxx.x.xxx:5005/Slaapkamer/favorite/ClassicFM')
dz.scenes('Awaken').switchOn()
end
end
end
}
Users browsing this forum: No registered users and 1 guest