Not sure how to translate into a piston

Hi. I am new to webCoRE… very new. I am having a hard time wrapping my below psuedo code into what needs to go into the dashboard. I have been able to test individual snipets/commands, but cannot tie it together. Any assistance would be great!

My “device” is a GE Z-Wave Dimming Switch and is wired directly to my garage lights. I want to dictate when and how the lights come on.

Part1

  • if device physically transitions to the on position
    • then ignore everything below but the physical switch to ensure the light stays on and set to the level physically commanded
  • elseif device currently turned off and time is between sunset-30min and 9pm or 5am and sunrise+30
    • then turn on the device and set the level to 50

Part 2

  • if anyone arrives home and time is between sunset and next sunrise
    • then capture the current state of the switch (as in physically on vs. programmed on and its level)
    • then turn on if required and set the level to 100
    • then after 10 minutes restore the previous state of the switch

Part 3

  • if the device physically transitions to off
    • if it was physically turned on and between sunset-30min and 9pm or 5am and sunrise+30
      • then turn the device back on and set the level to 50
    • else leave the light off until the next time or arrival trigger.

Pop on over to here https://community.webcore.co/ and re-post for help.
This is the webC0RE forum.