Shelly 2.5 as roller blind controller

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
itguru
New user
Posts: 3
Joined: 05 Jan 2020, 14:35

Shelly 2.5 as roller blind controller

#1 Post by itguru » 26 Feb 2020, 20:43

Hi,
i have build a rule-set for a Shelly 2.5 to control a roller blind.
Maybe this is interessting for somebody.

DeviceConfig:
screenshot003.jpg
screenshot003.jpg (132.26 KiB) Viewed 12005 times
rules1.txt:

Code: Select all

// TaskVar 12:  name=control
//   Var1: name=state
//      Stopped         0
//      RunningUp       1  
//      RunningDown     2
//      Initializing    4
//   
//   Var2: name=limit
//      Seconds run: 3-20
//   
//   Var3: name=current
//      CurrentSec:  0=Rollo oben ; Var2=Rollo unten
//   
//   Var4: name=target


// GPIO 4  = up relais     name=relais1up
// GPIO 15 = down relais   name=relais2down

// sw1down
// sw2up

// Timer7 = 1sec timer on up mode
// Timer8 = 1sec timer on down mode

on System#Boot do
   event SystemInit 
endon

on SystemInit do
   // Setting the roller blind run time (in sec)
   TaskValueSet 12,2,10
   // ##################################################################### 
   event StopRunning      //ensure, all is stoped
   TaskValueSet,12,1,4    // start init procedure
   TaskValueSet 12,3,[control#limit]
   TaskValueSet 12,4,0
   event InitUp        //ensure blind is open afer powerswitch/boot
endon

//######################################################################
rules2.txt

Code: Select all


on sw1up#state=1 do
   if [control#state] <> 4   // on init, switches are not working
      if [control#state] <> 0
         event StopRunning
      else
         TaskValueSet,12,4,0
         if [control#current] > [control#target]
            event RunningUp
         endif
      endif
   endif
endon


on sw2down#state=1 do
   if [control#state] <> 4   // on init, switches are not working
      if [control#state] <> 0
         event StopRunning
      else
         TaskValueSet,12,4,[control#limit]
         if [control#current] < [control#target]
            event RunningDown
         endif
      endif
   endif
endon


on StopRunning do       // stopping a posible running up or down move
   timerSet,7,0
   timerSet,8,0
   TaskValueSet,12,1,0
   gpio,4,0 
   gpio,15,0 
endon


on RunningDown do
   TaskValueSet,12,1,2
   gpio,4,0   // ensure up is off 
   gpio,15,1  // activeate Down
   timerSet,7,0
   timerSet,8,1
endon


on RunningUp do
   TaskValueSet,12,1,1
   gpio,15,0  // ensure down is off
   gpio,4,1   // activeate Up
   timerSet,8,0
   timerSet,7,1
endon

on InitUp do
   gpio,15,0  // ensure down is off
   gpio,4,1   // activeate Up
   timerSet,8,0
   timerSet,7,1
endon



On Rules#Timer=8 do // Handle 1sec steps on blind up
   TaskValueSet 12,3,[control#current]+1 
   if [control#current] >= [control#target]
      timerSet,8,0
      event StopRunning
   else
      timerSet,8,1
   endif
endon


On Rules#Timer=7 do   // Handle 1sec steps on blind up
   TaskValueSet 12,3,[control#current]-1 
   if [control#current] <= [control#target]
      timerSet,7,0
      event StopRunning
   else
      timerSet,7,1
   endif
endon

rules3.txt

Code: Select all

// Remote Interface:
// =================
// http://<espeasyip>/control?cmd=event,RunTo=5 = 5 seconds from open
// http://<espeasyip>/control?cmd=event,RunTo=2 = 2 seconds from open
// http://<espeasyip>/control?cmd=event,RunTo=100   total close
// http://<espeasyip>/control?cmd=event,RunTo=0     total open
// http://<espeasyip>/control?cmd=event,RunToClose  total close
// http://<espeasyip>/control?cmd=event,RunToOpen   total open
//
// State-Informations from control device

on RunToClose do
   if [control#state] <> 4   // on init, no remote commands are allowed
      TaskValueSet,12,4,[control#limit]
      event RunningDown
   endif
endon 


on RunToOpen do
   if [control#state] <> 4   // on init, no remote commands are allowed
      TaskValueSet,12,4,0
      event RunningUp
   endif
endon 


on RunTo do
   if [control#state] <> 4   // on init, no remote commands are allowed
      if [control#limit] < %eventvalue%
         TaskValueSet,12,4,[control#limit]
      else
         if %eventvalue% < 0 
            TaskValueSet,12,4,0
         else
            TaskValueSet,12,4,%eventvalue%
         endif
      endif
      if [control#current] > %eventvalue%
         event RunningUp
      else
         if [control#current] < %eventvalue%
            event RunningDown
         endif
      endif
   endif
endon

//######################################################################

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: Shelly 2.5 as roller blind controller

#2 Post by megamarco83 » 26 Feb 2020, 22:19

wow, compliments!
you did a very good job!

some question from my side.
do you have normal blinds, or venetian?

maybe could be usefull to add the control of venetian blind, that is mainly the same, but with venetian you can control the inclination of venetian
simpy pressing the wall switch1 for 1 second => relay1 will activate in down direction only for 1second, so you can have the inclination.
if you press switch1 longpress (for example > 2000mseconds) you will have relay1 triggered till 100% down / close
same situation for switch2 related to open:
shortpress switch2 => relay2 trigered for 1second, inclication up / open
longpress switch2 => relay2 trigered till reach 100% up / open

second question what's appened if some one switch simmultaneusly switch1 and switch2 ?
the roller shutter motor should be protected to not have relay1 (down/close) and relay1(up/open) triggered simmultaneusly

thanks for replay, and again very very good job!

itguru
New user
Posts: 3
Joined: 05 Jan 2020, 14:35

Re: Shelly 2.5 as roller blind controller

#3 Post by itguru » 27 Feb 2020, 11:47

I have "normal" blinds like this ...
https://www.amazon.de/gp/product/B003BVENE4

A colleage of mine have rolers in kind of which you have descripted it. This will be my next job - but not in the next days.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: Shelly 2.5 as roller blind controller

#4 Post by megamarco83 » 27 Feb 2020, 12:01

hi, thanks for reply.
also the "venetian" blind has the same roller shutter motor, the difference is inside the blind itself.
the normal blind can only go up or down
the venetian blind can 1)inclinate up or down and 1)can go up or down as normal blind
the only differences is inside switch: a single press of 1second trygger relay for a second and give an inclination. longpress of switch trigger the relay continuosly and give the motion.

sure no problem, it's just an improvement of your code!
no hurry :-)

maybe another usefull implementation could be send the percentage of position blind to domoticz :-)
but i guess not so easy... :-(

itguru
New user
Posts: 3
Joined: 05 Jan 2020, 14:35

Re: Shelly 2.5 as roller blind controller

#5 Post by itguru » 27 Feb 2020, 13:07

megamarco83 wrote: 27 Feb 2020, 12:01 maybe another usefull implementation could be send the percentage of position blind to domoticz :-)
If you you "notify" (send) the "control" Dummy-Device to domoticz, this should send the "seconds from top" in the parameter [control#current]. In [control#limit] is the time (in sec) specifed, the blind need to complete open (or close). If you set these two both integers in relation, you should can calc in your homeautomation a percent value (i think).
I use fhem - and there it works.

hoeby
Normal user
Posts: 33
Joined: 19 Sep 2018, 21:03

Re: Shelly 2.5 as roller blind controller

#6 Post by hoeby » 05 Sep 2020, 18:54

hello Itguru,

Today i reflashed my shelly 2.5
The original fw i flashed with tasmota. But i didn't work proppely. Sometimes the output stopped but the software went on, which resulted in out of sync working.
I have multi espeasy flashed devices in house and they are working beautifull. So when i found your thread, i had to try it.

I flashed it and it works. only have 2 things which i would like to ask.

- The inputs are working like pulse buttons. I give a up command and if goes fully open, same for close.
But is it possible that it works like a normal shutter switch. When i give up i goes up, but stops when i stop controlling the normal switch?
It looks like it goes in a loop with the timers and therefor doesn't read the switch state. Untill it is full up or down. But how to solve this, because you also don't want it to close 1 second, then stop to read the switch state and then again move 1 second

- The control values are in seconds. but is it possible to make the steps smaller?
For ventilation i love to have it at 1,5 seconds from open. But i can't give that command.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 54 guests