Antti wrote:but it doesn't work as it is necessary to me
You probably should explain what exactly is necessary to you first
I see two possible problems with your code:
1) it might be never called in case you have incorrect association groups setup
2) it might be called too many times, because calling Set() would result in changing level value and executing your handler once again. It even might get into a permanent "off" state after a minute or so.
Thank you that you answered.
Yes, you are right, I have the second problem.
The algorithm wanted to realize the following.
1. At inclusion of a dimmer the switch it is necessary to check time and if it between12 and 15 o'clock, to include a dimmer for 30%, to include in other time for 100%.
2. After inclusion of a dimmer to wait five minutes and to reduce brightness to 10% or 30% respectively.
3. After reduction of brightness to wait a minute more and if not I was the switch button (it didn't turn out to realize) is pressed, to turn off the light completely.
Unfortunately I am a beginner in js...