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!
Return dimmer to "normal" schedule after scene ends
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Return dimmer to "normal" schedule after scene ends
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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 5
- Joined: Monday 05 March 2018 9:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Return dimmer to "normal" schedule after scene ends
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
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Return dimmer to "normal" schedule after scene ends
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
to
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
Code: Select all
elseif device.state == "Off" then
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 5
- Joined: Monday 05 March 2018 9:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Return dimmer to "normal" schedule after scene ends
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!
Thanks again!
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Return dimmer to "normal" schedule after scene ends
Sure,
change the part between elseif and end to:
}
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()
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest