thehookup / Motorized_MQTT_Blinds

Motorized_MQTT_Blinds
292 stars 75 forks source link

Feature Request: Nudge for calibration? #77

Open knissdesign opened 9 months ago

knissdesign commented 9 months ago

Would there be any way to program a "nudge" command that could be used for calibration? For example, set the blind/motor to 50%, and then be able to nudge the motor a few steps at a time in either direction until the blinds physically match the 50% in Home Assistant, without actually changing the 50% set point. I have frequent power outages and the blinds tend to lose where they are, and it's a huge pain to get them back to correct.

knissdesign commented 8 months ago

Alright, if anyone is following this, I've found a solution. Since I am using this on tilting horizontal blinds, the "open" and "close" functions that moved the blinds all the way up, and all the way down, respectively, never made sense, as "open" just closed them in the upward direction. I know this control is designed for lifting blinds, not tilting them. Nonetheless, I never used those controls. So, my solution was to modify those commands to move the motor 1 step at a time, without reporting the change to the "current position" so as to allow the calibration I'm looking for. I did this by replacing the "open" and "close" code with the following:

if (newTopic == USER_MQTT_CLIENT_NAME"/blindsCommand") 
  {
    if (newPayload == "OPEN")
    {
    #if DRIVER_INVERTED_SLEEP == 1
    shadeStepper.sleepON();
    #endif
    #if DRIVER_INVERTED_SLEEP == 0
    shadeStepper.sleepOFF();
    #endif
    shadeStepper.move(80, FORWARD);
    moving = true;
    #if DRIVER_INVERTED_SLEEP == 1
    shadeStepper.sleepOFF();
    #endif
    #if DRIVER_INVERTED_SLEEP == 0
    shadeStepper.sleepON();
    #endif
    moving = false;
    }
    else if (newPayload == "CLOSE")
    {
    #if DRIVER_INVERTED_SLEEP == 1
    shadeStepper.sleepON();
    #endif
    #if DRIVER_INVERTED_SLEEP == 0
    shadeStepper.sleepOFF();
    #endif
    shadeStepper.move(80, BACKWARD);
    moving = true;
    #if DRIVER_INVERTED_SLEEP == 1
    shadeStepper.sleepOFF();
    #endif
    #if DRIVER_INVERTED_SLEEP == 0
    shadeStepper.sleepON();
    #endif
    moving = false;
    }

Hope this can help someone else!