How to implement 2-step motion sensor controlled lighting

Is there a particular reason you use Functions for this? I would recommend using Design Pattern: Associated Items to simplify your rules. Besides, when looking at your first function and when you call it, the arguments doesn’t match? (argument no. 2 is a boolean but should be a SwitchItem)

As for the problem itself it has been discussed before, but I don’t know if anyone have solved it in a good way. Different dimmable lights (and different bindings) handle ON/OFF commands differently. Some restore the light to the last value when turned on while some interprets ON as 100 and OFF as 0. Search the forum for a solution you could be satisfied with.