PLEG Scenario

I’m having some trouble with a scene–it’s probably doing exactly what I’m telling it to, but not what I want it to.

We have a geofence set up and linked to a virtual switch and a gate operator plugged into an appliance module. When the geofence turns the switch to “on” (home), I’d like to open our gate, but only if the gate is currently closed.

Then when the geofence switch is turned off, I’d like to trigger the appliance module to close the gate, but only if it’s currently open. If the gate doesn’t close in ~15seconds, I need to retrigger the appliance module until it registers as closed (it sometimes gets stuck).

For the first part, I’ve set up the following:

Input:
“Home”–geofence switch turned on
“GateClosed”–gate sensor not tripped

Conditions:
“OpenGate”–Home AND GateClosed

Action:
Trigger appliance module switch

Do I need to add a second condition, “HomeSwitchedOn” and then run the OpenGate condition off of HomeSwitchedOn AND GateClosed in order to have this fire only on entry?

Is there a straightforward way to handle the repeat firing until the gate is closed?