Smart Shades and OpenHAB

This is a Tutorial how to control Wazombi Smart Shades with openHAB.

##What is Wazombi Smart Shades?
It is a small Bluetooth device that is attached to a window shade / jalousie / rollershutter / blinds that have a sidewinder chain. The product was founded via Indiogogo. With this nice Python script, Smart Shades can be controlled on the Linux console: http://bitbucket.org/jeremynoel476/smartblinds-diy It allows for commands like get_battery, get_position or move_target (from 0: up to 100: down).

##Downside
It is veeeery slow. I use aluminium blinds, maybe with others, it’s faster. But with my blinds, it needs four minutes (!!!) to open and close completely. So i decided to just have it always at the bottom (position: 100). To open it for sunlight, I set the position to 96, so the aluminium blinds open 90 degrees. Mind that this only works, when they are moved from 100 to 96. More to this problem later at “Move down and open blinds”.

##openHAB Item
I created an Number item in the openHAB 2 Paper UI: Jalousie_Bedroom

##openHAB Sitemap

Frame label="Jalousie Bedroom" 
     Switch item=Jalousie_Bedroom label="" mappings=[0="Up", 96="Down/open", 100="Down/closed"]
     Slider item=Jalousie_Bedroom
}

##visudo
I added the following lines to visudo to allow the openhab user calling the python script and enabling and disabling bluetooth. I know, this is a very bad solution, because openhab is now allowed to execute every Python script as root without a password.

openhab ALL=NOPASSWD: /usr/bin/python
openhab ALL=NOPASSWD: /bin/hciconfig

##openHAB jalousie.rules
For me, sometimes the python script raised an error. My stupid solution is, to shut down the bluetooth device and start it on every rule execution. Additionally, i send the move_target command three times.

 rule "Jalousie Bedroom"

 when
         Item Jalousie_Bedroom changed
 then
         executeCommandLine("sudo hciconfig hci0 down",1000)
         executeCommandLine("sudo hciconfig hci0 up",1000)
         logInfo("Jalousie_Bedroom","Position: "+Jalousie_Bedroom.state)
         var Number i = 0
         while(i < 3) {
                  executeCommandLine("sudo python /home/pi/smartblinds-diy/control.py -t C0:FF:EE:C0:FF:EE -c move_target -a "+Jalousie_Bedroom.state,5000)
              *    i = i+1
         }
 end

##openHAB rules
Now, you can use one of the following lines in your rules (light-switch, ical, cron, …) to open or close the blinds:

    sendCommand(Jalousie_Bedroom, 96)
    sendCommand(Jalousie_Bedroom, 100)

##openHAB astro.rules
Close blinds in the evening using the Astro Binding.

rule "Sunset"
when
    Channel 'astro:sun:11aaa888:set#event' triggered END
then
    sendCommand(Jalousie_Bedroom, 100)
end

##Move down and open blinds
When the blinds are at the very bottom (100), they open ninety degree and let in sunlight when the position is set to 96. When they are at the top (0) or somewhere in the middle (<96) and I set the position to 96, they move to almost the bottom, but of course, they are not opened. My solution is the following bash script, that moves the blinds to the very bottom (100), waits until this is finished, and then it moves the blinds to position 96. The variable i is just used for a timeout. If it does to reach the target within 300 position checks, it aborts.

#!/bin/bash

mac="C0:FF:EE:C0:FF:EE"
target=100

sudo python /home/pi/smartblinds-diy/control.py -t $mac -c move_target -a $target

i=1
until [[ $i -gt 300 || $position -gt $((target - 2)) ]]; do
  position=`sudo python /home/pi/smartblinds-diy/control.py -t $mac -c get_position | awk -F" " '{print $2}'`
  sleep 0.5
  let i=i+1
done

sudo python /home/pi/smartblinds-diy/control.py -t $mac -c move_target -a $((target - 4))

And here the new jalousie.rules:

rule "Jalousie Bedroom"

when
        Item Jalousie_Bedroom changed
then
        executeCommandLine("sudo hciconfig hci0 down",1000)
        executeCommandLine("sudo hciconfig hci0 up",1000)
        logInfo("Jalousie_Bedroom","Position: "+Jalousie_Bedroom.state)
        var Number i = 0
        if(Jalousie_Bedroom.state == 96 && previousState < 96) {
                logInfo("Jalousie_Bedroom","Down and open")
                executeCommandLine("/home/pi/smartblinds-diy/downandopen",300000)
        } else {
                while(i < 3) {
                        executeCommandLine("sudo python /home/pi/smartblinds-diy/control.py -t C0:FF:6E:80:DB:CB -c move_target -a "+Jalousie_Bedroom.state,5000)
                        i = i+1
                }
        }
end

The rule executes the script only if the position is set to 96 and the current position is smaller than 96.

3 Likes

Hi @yoshi

Will this just work on a PI3 using the builtin Bluetooth or would i need to make some changes?

Thanks

Hi, it works on the Raspberry Pi 3 due to its built-in Bluetooth. But you can also use another machine using a Bluetooth V4 (BLE) USB Stick.

Hi @yoshi

This is great. I plan to adapt this to my Smart Shades so I can make more complex trigger rules (than the app is able to) and also adapt to sunrise/sunset from day to day.

I’ve noticed the devices can’t be paired to more than one phone/tablet.
Will the python script be able to control the Smart Shade device if the device is paired to a smart phone also og should these be unpaired first? If so would this impact the device calibration?

Thanks

Hi @Estejod,
the Python script does not require a connection. You can simply send the commands. The calibration has to be done with the Smart Shades app. You can both use the app and the script.
– Yoshi

That looks pretty good, has anyone seen something similar but zwave instead of bluetooth?

Hi @Adam_E,
there is a product called MOVE that also uses Bluetooth, but they created a new Indiegogo campain for MOVEZ with Z-Wave. FlipFlic has Bluetooth and ZigBee. AXIS Gear offers three versions, one with Bluetooth, one with Bluetooth+ZigBee, one with Bluetooth+Z-Wave.