I have a PIR sensor which should trigger the light. But the light can also be set manually (this is the main issue). It is the RGBW switch (it's the second).
The most common answer on the forum for forMin issues:
Code: Select all
light.switchOff().checkFirst().afterMin(2)
light.switchOn().checkFirst().forMin(2)
afterMin isn't a similar function to forMin, so in my opinion this is not a solution and I'm afraid that in most cases forMin is useless as the same can be achieved with:
Code: Select all
light.switchOn()
light.switchOff().afterMin(2)
Please correct me, if I'm wrong, but I understand that it should work the following way:
1. RGBW is set to 50% red colour
2. PIR event is triggered and the brightness is set to 100% and colour to white with forMin(2)
3. After 2 minutes light is restored to previous state (50% red)
But when another PIR event is triggered then command:
Code: Select all
light.switchOff().afterMin(2)
So the questions are:
1) is there any way to reset the forMin timer after motion is detected (it would be the perfect solution which I think would address 99% of issues with forMin)
2) is there any way to read and then store RGBW device status (for simple switch it's easy: light.state, but how can I read rgbw settings) - with it the solution will be to store with local variable the state before first action and the restore it after some time).