Page 1 of 1
Return dimmer to "normal" schedule after scene ends
Posted: Monday 05 March 2018 13:53
by username
Hi guys,
I hope you can help me with the following, as i have trouble getting this to work. I have outdoor lights and a Doorbird doorbell/camera. I want my outdoor lighting to go back to "normal" timer schedule after a scene/event has passed. I'm not a programmer, so this makes it very hard for me. I have tried it with blocky, but failed miserable...
What i have working is, using web interface only:
1. Outdoor lights are set to 80% during civil twilight, 60% during nautical twilight, 40% during astronomical twilight and 20% at night.
2. Doorbird sends a json http request when it detects motion/presence and triggers a scene, which in turn sets outdoor lights to 100%
3. If there is still motion detected after 2 minutes, Doorbird triggers the scene again and lights stay at 100%
4. Scene is set to turn off outdoor lighting after 135 seconds, so if no new triggers are received, outdoor lights go out.
5. At this point it is dark... I hoped it would resume normal civil/nautical/astronomical/nighttime operations.
I'm hoping you guys could help me with an example script which would set outdoor lighting back to normal operation after scene has ended. Could you give me some clues or an example please? Thnx!
Re: Return dimmer to "normal" schedule after scene ends
Posted: Monday 05 March 2018 22:16
by waaren
username wrote: ↑Monday 05 March 2018 13:53
Hi guys,
I hope you can help me with the following, as i have trouble getting this to work. I have outdoor lights and a Doorbird doorbell/camera. I want my outdoor lighting to go back to "normal" timer schedule after a scene/event has passed. ....
Can you check this and come back with results ?
Code: Select all
--[[
keepDimmerState.
dimmable light must be set by scene and also switched off by that scene after delay of nn seconds
set debug to false after testing / debugging
]]--
return {
on = { devices = { 'outdoor lights' } }, -- Change to your dimmable light name
data = { lastDimLevel = { initial = 0 } },
execute = function(domoticz, device)
local debug = true
function debug_print(MyLine)
if debug then print("keepDimmerState: ".. MyLine) end
end
debug_print("Previous Dimlevel: " .. device.lastLevel)
debug_print("Previous saved DimLevel: " .. domoticz.data.lastDimLevel)
if device.level == 100 and device.lastLevel ~= 100 then
debug_print("Dimlevel = 100 and saved Dimlevel <> 100 ==> Triggered first time by scene, setting saved Dimlevel to: " .. device.lastLevel )
domoticz.data.lastDimLevel = device.lastLevel
elseif device.state == "Off" and domoticz.time.isNightTime then
debug_print("state = Off and isNightTime dimming to: " .. domoticz.data.lastDimLevel)
device.dimTo(domoticz.data.lastDimLevel).silent()
end
end
}
Re: Return dimmer to "normal" schedule after scene ends
Posted: Tuesday 06 March 2018 9:56
by username
waaren wrote: ↑Monday 05 March 2018 22:16
Can you check this and come back with results ?
Thank you for your reply! I tried it, but no result. I started with dimlevel set to "11". Then moved my hand over motion sensor and the outdoor lights were set to "100". But after 135 seconds the lamps were off.
Here is the log output:
- Spoiler: show
-
2018-03-06 09:45:45.762 User: Admin initiated a scene/group command
2018-03-06 09:45:45.763 Activating Scene/Group: [Deurbel Beweging]
2018-03-06 09:45:45.764 Activating Scene/Group Device: Buitenlampen Voordeur (On)
2018-03-06 09:45:45.765 OpenZWave: Domoticz has send a Switch command!, Level: 99, NodeID: 11 (0x0b)
2018-03-06 09:45:45.775 (AeonLabs ZWave Plus stick) Light/Switch (Buitenlampen Voordeur)
2018-03-06 09:45:45.776 Delaying switch [Buitenlampen Voordeur] action (Off) for 135 seconds
2018-03-06 09:45:45.842 (AeonLabs ZWave Plus stick) Light/Switch (Buitenlampen Voordeur)
2018-03-06 09:45:46.020 dzVents: Info: Handling events for: "Buitenlampen Voordeur", value: "On"
2018-03-06 09:45:46.021 dzVents: Info: ------ Start internal script: KeepDimmerState Buitenlampen: Device: "Buitenlampen Voordeur (AeonLabs ZWave Plus stick)", Index: 72
2018-03-06 09:45:46.021 dzVents: keepDimmerState: Previous Dimlevel: 100
2018-03-06 09:45:46.021 dzVents: keepDimmerState: Previous saved DimLevel: 11
2018-03-06 09:45:46.022 dzVents: Info: ------ Finished KeepDimmerState Buitenlampen
2018-03-06 09:45:46.155 dzVents: Info: Handling events for: "Buitenlampen Voordeur", value: "On"
2018-03-06 09:45:46.155 dzVents: Info: ------ Start internal script: KeepDimmerState Buitenlampen: Device: "Buitenlampen Voordeur (AeonLabs ZWave Plus stick)", Index: 72
2018-03-06 09:45:46.156 dzVents: keepDimmerState: Previous Dimlevel: 100
2018-03-06 09:45:46.156 dzVents: keepDimmerState: Previous saved DimLevel: 11
2018-03-06 09:45:46.156 dzVents: Info: ------ Finished KeepDimmerState Buitenlampen
2018-03-06 09:45:51.716 (AeonLabs ZWave Plus stick) Usage (Unknown)
2018-03-06 09:45:51.717 (AeonLabs ZWave Plus stick) General/kWh (kWh Meter)
2018-03-06 09:48:00.802 OpenZWave: Domoticz has send a Switch command!, Level: 0, NodeID: 11 (0x0b)
2018-03-06 09:48:00.803 (AeonLabs ZWave Plus stick) Usage (Unknown)
2018-03-06 09:48:00.804 (AeonLabs ZWave Plus stick) General/kWh (kWh Meter)
2018-03-06 09:48:00.807 (AeonLabs ZWave Plus stick) Light/Switch (Buitenlampen Voordeur)
2018-03-06 09:48:00.879 dzVents: Info: Handling events for: "Buitenlampen Voordeur", value: "Off"
2018-03-06 09:48:00.879 dzVents: Info: ------ Start internal script: KeepDimmerState Buitenlampen: Device: "Buitenlampen Voordeur (AeonLabs ZWave Plus stick)", Index: 72
2018-03-06 09:48:00.880 dzVents: keepDimmerState: Previous Dimlevel: 100
2018-03-06 09:48:00.881 dzVents: keepDimmerState: Previous saved DimLevel: 11
2018-03-06 09:48:00.881 dzVents: Info: ------ Finished KeepDimmerState Buitenlampen
Re: Return dimmer to "normal" schedule after scene ends
Posted: Tuesday 06 March 2018 11:23
by waaren
As far as I understand this behaviour is as designed. My understanding of your requirement is that the light goes back to the original dimlevel during nighttime. If the light is switched off during daytime the script does not change it back to the original dimlevel but does nothing and the light stays off.
If you want it always to go back to the latest dimlevel then change the line
Code: Select all
elseif device.state == "Off" and domoticz.time.isNightTime then
to
Re: Return dimmer to "normal" schedule after scene ends
Posted: Tuesday 06 March 2018 12:05
by username
Ah, yes. You are right. It works perfect! Thnx a million! Just one last question/request? If, instead of remembering what the last dim level was, can i check what the dim level of another (fake) dim switch is at that moment and use this same level?
Thanks again!
Re: Return dimmer to "normal" schedule after scene ends
Posted: Tuesday 06 March 2018 12:37
by waaren
Sure,
change the part between elseif and end to:
Code: Select all
debug_print("state = Off and isNightTime dimming to: " .. domoticz.data.lastDimLevel)
local fakeDevice = domoticz.devices("fake dimmer") -- Change to your fake dimmer name
fakeDimLevel = fakeDevice.level
debug_print("fakeDimLevel = " .. fakeDimLevel)
-- device.dimTo(domoticz.data.lastDimLevel).silent()
device.dimTo(fakeDimLevel).silent()
}