“Sensor” is primarily used for things that return a numeric value such as a temperature value, humidity number, a percentage, etc. If you want On/Off. Open,Closed, Home/Away, etc. These are binary sensors as the word “Binary” should have registered as a clue because, it literally means, one or the other, ( On or Off, Open or closed) while “Sensor” is more of a generic generic term. The best thing you can do is go through the documentation. The examples are meant to be a clue as well. When all the exaples for “Sensor” are working with numbers and what you need a sensor that uses words. Thats a clue that your using the wrong sensor platform.
(using dutch to differ between a name and a “action”
lets say you buy 2 door sensors at the “ACtion” one is called “deur open”, the other one is called “deur closed”, place it on the bathroom door (example) if you would install them in such a way that the door is closed or open 1 is turned off
you would have 3 “states”
door is (fully) closed → the one called “deur closed” will give an alarm
door is (fully) open → the one called “deur open” will give an alarm
when you open or close, both “deur” alarms will go off since neither is switched.
you can exchange the deur(switch) name for “endstop”,
Door sensors are just switches that are closed by a magnet nearby.
in your post, you only have 0,015seconds (example) pointing at "max duration time " while in real life you give 60 seconds to either open/close the door
so the motor might stop after 15seconds, in this case if the deur sensor is not triggerd it will stop anyway.
the max duration should be a bit longer than the time it takes to open the door/cover a couple of seconds, (for example a bit of strong wind increases the time to close/open the door… or a chicken is stuck in the door (both deur sensors alarm bathroom example above) … to prevent motor burnout (to much current drawn or force applied) you limit the time, same happens when motors controll a solar screen/blinds or doors you will always hoor the motor humming a bit after its fully closed an turn off “automagicly”
i hope this makes sense and will give you new insight how to fix your code
we al start somewhere and best is to keep complex things small, break down in steps i having my own troubles with a 4x pwm to light thingy … I left it on the side for a bit .