Efficient code for controlling multiple blinds


#1

1) Give a description of the problem
The target is to control four windows blinds (Fibaro Roller shutter 2) with one Heatit Push8 controller. The controller has 8 buttons, four “on” four and “off”. The attached piston works for blind nr 1 by pressing button 1 and 2. I would like to create an efficient code doing what the attached piston does, but also does the same for blind 2-4 by pressing buttons 3-8.
The attached snapshot shows the blind as Dimmer since the DH is build from a Fibaro Dimmer2 DH.

2) What is the expected behaviour?
Instead of creating line 17-45 four times (which I think must be very unefficient) I would like to make
the code “dynamic” as the action (blind 1-4) changes with respect to which buttons are pressed. So button 3/4 applies to blind 2, button 5/6 applies to blind 3 and button 7/8 to blind 4.
I.e. I just want to create an efficient code and not making tons of lines.

3) What is happening/not happening?
The button 1 is closing and 2 opening the blinds. During closing/opening pressing button 1 or 2 will stop the blind
The attached piston works for blind 1, but I suppose there must be a better way of doing it without multiplying the code by 4.

4) Post a Green Snapshot


#2

some pros can help you better
but i would create 4 different pistons…
Less is more.


#3

Yeah I agree with less is more. I have blind 1 and 2 in two pistons at the moment and that works. But I have in all 11 blinds and after finishing the first blind I thought…there must be a better way…


#4

Are they all in the same room?
The best practice I’ve seen is, each room gets it’s own set of pistons.


#5

No they are in three different area of the house and I will use three Heatit button controllers.

The best practice I’ve seen is, each room gets it’s own set of pistons.

Thanks for the tip. But again, would like to see this solved in a more creative way seen from the coding side.


#6

The million dollar question is:

  • Are you trying to make code that looks pretty? (for your benefit)
    -or-
  • Are you trying to make code that runs as efficiently as possible? (for your SmartHome’s benefit)

Depending on your answer, the final piston(s) will be very different…


#7

For sure efficiency is the intent here!


#8

Well, then @ike2018 nailed it on the head. You definitely want separate pistons.

What I usually do is only work with one piston (one blind) for a day or two… Get it to 100% perfection, with lots of testing. Once you are happy, then just pic

This way, you only have to tweak the devices, without re-writing from scratch.


#9

Right! So basically I just continue where i left of:) Well thats good to know. I am very new to this and didnt know if I was on the wrong path.
Thanks guys


#10

I would want controlling the whole house with very complex 4-5 pistons only (currently 100+)
some of my pistons just 5-6 lines:))))
My house was working with 80% efficiency. After changing pistons to simpler pistons, efficiency went up to 97-98%

we are around, tag us anytime you need.