Sunscreen motor control

Hi everyone,

I've just made my first Node Red sequence and I would love to get some tips/feedback on how I did and if my sequence is monkey proof (I got a 1 year old :slight_smile:)

So lets start with some explanation: I want to control my sunscreen with a remote. I do have a "curtain switch" but it can't be calibrated (yet), plus I actually don't need the % control it provides if the calibration would have worked, so I'm switching to a "simple" 2 gang switch.
The only danger I foresee with this switch is that, when not programmed correctly, power could be "on" to both the "In" and "Out" terminal which might blow up the motor :frowning:

The remote I'm using (Osram Switch Mini) has actions: "up", "up hold", "up release", "down", "down hold" and "down release" (there is a "middle" button with same three functions but I'm planning on using that to toggle a LED strip in my sunscreen). "up" would be to fully extend the sunscreen, "down" to fully retract, "hold" and "release" functions to adjust the sunscreen to where ever you want it.

Currently the sequence is rigged to the 2 LED strips in the kitchen for testing purposes (plus they don't mind being "on" at the same time :wink:) and the 5s delay will be adjusted once I know the full travel duration of the sunscreen. It all works fine, but as it's my first sequence, please let me know if there is anything wrong with it!

Hello and welcome to the forum

First, I do not recognize those nodes... are you wanting to control this via a dashboard "button" or are those nodes the backend for some form of WiFi remote?

Dashboard buttons can be "disabled" when other actions are happening and "enabled" when safe.

Otherwise I would suggest incorporating some form of if() logic with triggers/flags etc. inside a function node that only allows one action at a time.

Hi Gunner,

Thanks for your response. I'm indeed controlling this via a remote, it seems to be working fine (with the remote button actions, both kitchen lights are never on at the same time).

The current state node works more or less like an "if", if I'm not mistaken: for instance, when pushing the "Up" button, it first checks whether the left lights are "on", if they are "on" -> turn "off" left lights -> return to "if", if they are "off", continue to turn "on" the right lights.
So in theory, I would say that right & left lights can never be "on" at the same moment, but as I don't have any further experience with NR, maybe I'm missing how this could fail / be overruled. I've played around with the remote trying to get both lights on at the same moment, couldn't get it done, but there might be an edge case where this happens?

I too am still learning NR basics, and dusting off my limited JavaScript experience, but what I meant was something like global flags.. in pseudocode:

Press UP - if DOWN Flag already active do nothing, else set UP Flag active and process UP, once finished set UP Flag to inactive.

You always can use FLOW or GLOBAL variables to store information .. Steve did a good write-up for that !