HUE Scene "Go to sleep" and loop

Moderator: leecollings

Post Reply
olafmarcos
Posts: 17
Joined: Sunday 27 December 2015 1:09
Target OS: NAS (Synology & others)
Domoticz version: 9999
Location: Santander - Spain
Contact:

HUE Scene "Go to sleep" and loop

Post by olafmarcos »

Hi there,

I have very simple LUA script that was working well for years but i want to improve it a little.

When my childs switch on the light in the night, before i was switching off after 15 minutos. This is the script that was working well.

Now i want to invoke an option in the HUE bridge that is named "Go to sleep" function that itself go dimming down the light during 15 minutos and finally switch off.

The problem is that i am detecting the event of swith on the light by my childs with a "devicechanged" event, and that event is triggering again in an infinite loop when the HUE bridge itself is dimming down the light.

Code: Select all

commandArray = {}
if (devicechanged['Irina']) then
    if (devicechanged['Irina'] == 'Set Color) then
    	print('Luz Irina changed to ON')   
        date = os.date("*t")
--        print (date.hour)
        if (date.hour < 7 or date.hour >= 21) then
--            commandArray['Irina']='Off AFTER 900'   -- this was the first implementation
            commandArray['Dormir Irina']='On'		-- this is the new invoke to the funcion of HUE "Go to sleep".
        end
    end
end
return commandArray

This is the log of triggering the first event of switch on the light and entering in the loop:

2020-10-28 23:43:09.507 Status: EventSystem: Script event triggered: Apagar_Luz_Irina
2020-10-28 23:43:20.869 Status: LUA: Luz Irina changed to ON
2020-10-28 23:43:20.870 Status: EventSystem: Script event triggered: Apagar_Luz_Irina
2020-10-28 23:43:32.306 Status: LUA: Luz Irina changed to ON
2020-10-28 23:43:32.307 Status: EventSystem: Script event triggered: Apagar_Luz_Irina
2020-10-28 23:43:43.651 Status: LUA: Luz Irina changed to ON
2020-10-28 23:43:43.652 Status: EventSystem: Script event triggered: Apagar_Luz_Irina
2020-10-28 23:43:55.016 Status: LUA: Luz Irina changed to ON
2020-10-28 23:43:55.018 Status: EventSystem: Script event triggered: Apagar_Luz_Irina
2020-10-28 23:44:17.705 Status: LUA: Luz Irina changed to ON

I don't know why in that log is not appearing the events of (HUE) that is other times like this (switching manually the "Dormir Irina" switch):
2020-10-29 19:30:16.619 (HUE) Color Switch (Dormir Irina)
2020-10-29 19:30:16.489 Status: User: Admin initiated a switch command (179/Dormir Irina/On)
2020-10-29 19:30:20.999 (HUE) Color Switch (Irina)
2020-10-29 19:30:21.018 (HUE) Color Switch (Group Dormitorio Irina)

Thank you very much for any clue about how to resolve this issue....
Synology NAS ds215j, DSM 6.2
Domoticz Beta from Jadahl 9999
Z-wave (AEOTEC Aeotec Z-Stick Series GEN5,Fibaro FGRM222, FGS222, FGMS001-ZW5 Motion Sensor+)
Philips Hue Bridge
Nuki Lock Plugin
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest