Reset Light Level without it coming on?

Moderator: leecollings

Post Reply
jimtrout87
Posts: 16
Joined: Tuesday 12 April 2016 17:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Reset Light Level without it coming on?

Post by jimtrout87 »

I have a light in my kitchen which is only used by switch or voice control normally, so no auto turn on in the day, but i am now starting to go down at night (new baby) and between 11 pm & 6am want it to auto come on at 15%.

I can do this fine on motion but then the next day when i turn it on, it will come on at 15% when manually turned on. Is there a way to reset to 100% keeping the light off?

I realise i could set it back to 100 before turning off but sometimes i sit at the other end of the room (out of sight of the motion) so dont really want it flashing up to 100 and then off.

potential fix ?
commandArray['Kitchen Lights']='Set Level 100'
commandArray['Kitchen Lights']='Off'

Code: Select all

-- script_kitchen_Lights.lua

function timedifference(s)
   year = string.sub(s, 1, 4)
   month = string.sub(s, 6, 7)
   day = string.sub(s, 9, 10)
   hour = string.sub(s, 12, 13)
   minutes = string.sub(s, 15, 16)
   seconds = string.sub(s, 18, 19)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
   difference = os.difftime (t1, t2)
   return difference
end
 
commandArray = {}
 
if ((time.hour >= 23 or time.hour <= 5 and devicechanged['Kitchen Motion'] == 'On') and uservariables["Kitchen_Lights"] == 0 and (otherdevices['Sunset'] == 'On' or tonumber(otherdevices_svalues['Kitchen Light Level']) < 5)) then
	print("Setting Kitchen Lights to 15%")
--	commandArray['Kitchen Lights']='On'
	commandArray['Kitchen Lights']='Set Level 15'
	commandArray['Variable:Kitchen_Lights'] = '1'
elseif (uservariables["Kitchen_Lights"] == 1 and otherdevices['Kitchen Motion'] == 'Off' and timedifference(otherdevices_lastupdate['Kitchen Motion']) > 90 and otherdevices['Kitchen Lights'] ~='Off') then
	commandArray['Kitchen Lights']='Off'
	commandArray['Variable:Kitchen_Lights'] = '0'
	
end
zicht
Posts: 272
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Reset Light Level without it coming on?

Post by zicht »

Hi

I noticed no reply's on your post.

Code: Select all

commandArray['Kitchen Lights']='Set Level 100'
commandArray['Kitchen Lights']='Off'
The above code probably does not get the result your looking for, as commandarray only issues the same device once in a sequence.
So make it like this to issue both commands in one commandArray

Code: Select all

 commandArray[#commandArray +1]={['Lamp']='Set Level 100'}
 commandArray[#commandArray +1]={['Lamp']='0ff'}
By my knowledge this is the only way to solve your issue in basic lua.

You could also alter your voice script you are using for the "on" command to do the "set level 100" (you say "on" and the voicecontrol does "set level 100")

or if you other (pir) script is doing a "Set level x" you could make a device script

Code: Select all

if devicechanged['lamp'] == "On" then commandArray ["lamp"] = "Set Level 100" end 
The above triggers only on the ON command not on Set Level ... So if your voice command set "On" it wil be turned to 100%

There are a couple of options as you see,
but the solution you are looking for (reset the level without doing actual switching) is not possible as far as i know.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
Ittiz
Posts: 48
Joined: Tuesday 03 January 2017 0:37
Target OS: Linux
Domoticz version: 13939
Location: USA
Contact:

Re: Reset Light Level without it coming on?

Post by Ittiz »

I'd probably try to make a script that detected the on command when sent by a button press at the dimmer and then set it to 100%. So when you turned it on, it would come on at 15% then a few moments later go to full brightness. I'm not sure if your switch has a way to distinguish between manual on commands and commands sent from the crontoller, so you may have to figure out a way for it to do that. Maybe a a variable or something like that.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest