Help with withings rule

So I am trying to setup a rule based off withings mat and I cant get it to work properly. What i want is when the mode is night and presence is detected to turn off all the lights in the house and turn on bed lights and fan but i only want it to run once in a night. this is what i have so far.

If I understand, I think I would set the predicate as Mode is night. That way it only runs the rule at night.

I don't think you need the first IF. If either mat shows presence you want the rule to run. That would be handled by the trigger, it would only trigger if one of the mats show present.

You can use you counter to determine if the rule has been run or use a private Boolean. On the first line of the rule set if counter = 1 exit rule. SO if it triggers again it just exits and doesn't do anything.

You need someway to reset the counter for the next day. Set it back to 0 with a delay of some number of hours. Or maybe use a hub variable that you can reset once mode switches from night.

thank you, i will start there.