Page 1 of 2

Soma Smart Shades - Wazombi python script

Posted: Saturday 01 April 2017 21:51
by EdddieN
Hello,

Has someone had any luck with Soma Smart Shades from Wazombi?
http://wazombi.com/shades.html -> https://uk.somasmarthome.com/

I found this:
https://bitbucket.org/jeremynoel476/smartblinds-diy

but since it seems sometimes Bluetooth causes problems with Z-wave on the Pi I had it disabled (unless I missunderstood).

Any one tried this before I start to make a mess on my setup? :D

Re: Soma Smart Shades - Wazombi python script

Posted: Monday 03 April 2017 22:42
by deennoo
looks that you can got with a simple 6e usb btle dongle. Can be a good and easy way to made a plugin Python

Re: Soma Smart Shades - Wazombi python script

Posted: Monday 03 April 2017 23:06
by EdddieN
Yes still need to play a bit with. Want to try using the Pi 3 Bluetooth if I can.

I was thinking of linking bash (Python) to a virtual device, unless there's a better way?

Re: Soma Smart Shades - Wazombi python script

Posted: Wednesday 26 April 2017 11:53
by najtram
Maybe you find some answers here: http://www.instructables.com/id/Integra ... -Using-Ra/

I'm interested in buying a Soma. But only if I find someone who can verify if it's working with domoticz.... So please inform me if you make any progress!

Re: Soma Smart Shades - Wazombi python script

Posted: Wednesday 26 April 2017 15:00
by EdddieN
Nice finding!

I think the homekit part is out for me as I use the Razberry board which I believe disables the Bluetooth.... pity

Re: Soma Smart Shades - Wazombi python script

Posted: Friday 28 April 2017 15:07
by najtram
Model 3 has Bluetooth as far as I know... didn't know about disabling. Are you sure?

Meanwhile I found this: https://somasmarthome.com/products/soma ... le-homekit

Looks like the exact same thing!

Re: Soma Smart Shades - Wazombi python script

Posted: Friday 28 April 2017 19:51
by EdddieN
You don't have to disable Bluetooth, only if using a Razzberry board it gets disabled in order to work as per here, haven't tested though:
https://www.domoticz.com/forum/viewtopi ... 95#p117475

The link from Somasmarthome, yes that is the one. Interesting they are offering to pre-order a Pi in order to work with Amazon Echo and Siri? I wonder how they got around Apple's chip purchasing thing.... https://uk.somasmarthome.com/products/s ... le-homekit

Probably a Pi 3 with homebridge on it or similar... maybe even Domoticz!? :)

Re: Soma Smart Shades - Wazombi python script

Posted: Sunday 30 April 2017 0:07
by EdddieN
Ok, I have tested a bit more with a spare Pi Zero W I had.

I can see the blinds while scanning but when I try to interface with them (ie get a battery status), I get a

Code: Select all

connect error: connection refused (111)
I guess I need to play a bit more with it, maybe I was too far away. As far as I know BLE does not need pairing right?

Also a nice detailed link with further features:
https://github.com/SkyJohn/Homebridge-SOMA-Smart-Shades

Re: Soma Smart Shades - Wazombi python script

Posted: Sunday 30 April 2017 0:27
by EdddieN
Ok, I can confirm now it works :mrgreen: the problem was indeed distance. It seems it needs to be within a few meters in order to work, or it gives time outs and errors

Now I need to find a way to connect the commands from the python script to a dummy slider in domoticz. Any advice anyone?

Re: Soma Smart Shades - Wazombi python script

Posted: Sunday 30 April 2017 1:12
by EdddieN
Ok, this is how far I got, created a dummy switch blind control that links to two bash scripts to pull the blind up and down.

This part works ok.

The slider, how can I connect the % number of the slider to an external script? or bash script?
The way the python script works is something like this: 'python script.py -a 72' , 72 being the percentage height I want to set up the blinds at.

Any ideas?

Re: Soma Smart Shades - Wazombi python script

Posted: Tuesday 02 May 2017 0:22
by EdddieN
Right, finally got it working! It is not clean as I have no idea about LUA or similar and I'm making it as I go along...

1st I create a LUA script that triggers on event only (not idea how to do it directly inside the file system yet):

Code: Select all

local val_shades = otherdevices_svalues['Shades']
commandArray = {}

if val_shades ~= nil then
    cmd = "/usr/bin/python  /home/pi/domoticz/scripts/python/control.py  -t [your BT mac without the brackets] -c move_target -a "..val_shades
    os.execute(cmd)
end

return commandArray
Then on the virtual dummy switch I add the following for OFF:

Code: Select all

http://YourDomoticzIP:Port/json.htm?type=command&param=udevice&idx=deviceID&svalue=100
and similar for ON:

Code: Select all

http://YourDomoticzIP:Port/json.htm?type=command&param=udevice&idx=deviceID&svalue=0
or viceversa...

Now this creates an infinite loop that keep sending commands as my LUA script is triggering continuously... no idea how to fix that yet. But since it is a more common thing, maybe someone more experience with LUA and dummy devices can help me making it a bit more stable? ;)

I thought about updating a user variable to check before triggering but didn't manage to write to the variable inside Domoticz. Any lights would be welcome :D

The sliders and everything works.

Re: Soma Smart Shades - Wazombi python script

Posted: Tuesday 02 May 2017 12:31
by Chakkie
Hi EdddieN,

I am also interested in the SOMA system. However the Bluetooth range may be too small and not reliable. My RPI is on the first floor and blind on the second. I was wondering what is the working range between your RPI with bluetooth receiver and the SOMA motor?

And can you explain or show us how your set up is?

Do you have a RPI 3 with build in bluetooth? Since I own a RPI 2. I need to buy a seperate bluetooth dongle.

Re: Soma Smart Shades - Wazombi python script

Posted: Tuesday 02 May 2017 16:07
by EdddieN
Hi Chakkie,

You are right, the BT range is less than desirable. I had a RPI under the ceiling below next to the room where the shades are and it was struggling a fair bit.

I ended up buying a RPI zero W which has also BT (€10) and put it in the same room with a second instance of Domoticz.

I still need to fine tune this ON/OFF switch script within Domoticz, but doing this more for proof of concept and fun than anything else. I probably will end up replacing it with a proper motor and a Z-wave blind controller. That said, for retro-fitting, the Soma devices are quite nice, pity it does not have local override... again with Domoticz and a Z-wave wall switch?

Re: Soma Smart Shades - Wazombi python script

Posted: Wednesday 17 May 2017 15:51
by najtram
Thanks for this info!

Meanwhile I found this project: http://torsten-traenkner.de/wissen/smarthome/blinds.php
Not of any use anymore, because you seems to be right there where you want to be. Except for the percentage slider.

For me this would be exactly what I want. Use domoticz for triggered up and down with timer. For special situations I'd find it fine to use provided smart shades app.

Nevertheless I'm still curious if you manage to get it working with slider as well!

Re: Soma Smart Shades - Wazombi python script

Posted: Wednesday 17 May 2017 19:50
by EdddieN
Yes, using this code:

Code: Select all

local val_shades = otherdevices_svalues['Shades']
commandArray = {}

if val_shades ~= nil then
    cmd = "/usr/bin/python  /home/pi/domoticz/scripts/python/control.py  -t [your BT mac without the brackets] -c move_target -a "..val_shades
    os.execute(cmd)
end

return commandArray
Shades is your virtual sensor you create to control the Soma BT shades
Make sure the trigger for the lua script (I use it inside domoticz GUI) is set to device, otherwise is going to be sending messages to the Soma blinds every 1 minute.

You will need to put the control.py file inside your python scripts folder (see inside the code for folder structure).

I could do a guide on how to get it working but to me because I did not manage to get the fully up or fully down working with the virtual switch (it was causing conflicts with the slider), it feels not a finish process, but as far as working, it does work. Probably best to read since the beginning of the thread so you can get an idea of my steps.

Re: Soma Smart Shades - Wazombi python script

Posted: Monday 29 May 2017 22:48
by najtram
Ok, this is how far I got, created a dummy switch blind control that links to two bash scripts to pull the blind up and down.

This part works ok.
Hi EddieN

I got my smart shades. Good part is, I got it (the scripts) working in Terminal, (SSH).
Bad part is I didn't get it working in the switch on/off script, as suggested in your image...

Do you have any ideas?

Re: Soma Smart Shades - Wazombi python script

Posted: Tuesday 30 May 2017 16:30
by EdddieN
Hi,

The ON / OFF is a bit of a hit an miss. Basically the slider works with the code above.

The OFF (or the ON, cannot remember now) works ok but the other one sends the system repeated commands. The way I did it it is to call the API directly from the virtual switch for ON and OFF

Code: Select all

http://YourDomoticzIP:Port/json.htm?type=command&param=udevice&idx=deviceID&svalue=100
and OFF

Code: Select all

http://YourDomoticzIP:Port/json.htm?type=command&param=udevice&idx=deviceID&svalue=0


Keep an eye on the logs (make sure to put debug info) and you'll see what I mean. I'm sure there's a more elegant way to do this... with a bit of patience. viewtopic.php?f=17&t=16952#p132085

Re: Soma Smart Shades - Wazombi python script

Posted: Tuesday 30 May 2017 17:13
by najtram
Ok, thanks for your answers.
The Lua script and json approach you are using/suggesting is after the solution of using the .sh scripts in the switch. In the posts above the .sh script is working if I'm understanding your post correctly. For me it does work in terminal, but not in switch. I'm thinking in this direction: viewtopic.php?f=6&t=12345&p=136457#p136457

Re: Soma Smart Shades - Wazombi python script

Posted: Tuesday 30 May 2017 18:27
by EdddieN
Let me boot up my Pi zero tonight and I'll see what I did. But basically yes, you need the SH script, the Lua and... I need to look at it again tonight. I'll post later

Re: Soma Smart Shades - Wazombi python script

Posted: Tuesday 30 May 2017 18:56
by EdddieN
Ok, I just had a look at it. This is what I have:

The control.py file inside the scripts folders for domoticz. then I have a LUA script like this:

Code: Select all

local val_shades = otherdevices_svalues['Shades']
local status_shades = otherdevices['Shades']
print ("S value " ..val_shades)
print ("status " ..status_shades)

commandArray = {}

    if status_shades ~= nil then
        val_shades = otherdevices_svalues['Shades']
        print ("Trigger value " ..val_shades)
        cmd = "/usr/bin/python  /home/pi/domoticz/scripts/python/control.py  -t ED:3D:C0:F7:07:FB -c move_target -a "..val_shades
        os.execute(cmd)
    end 

return commandArray
Notice that the "ED:3D:C0:F7:07:FB" is the bluetooth mac of the soma shades. Make sure the LUA under envents is set to trigger with device only. with the above you should be able to use the slider. I called my virtual device "Shades".

for the ON and OFF: on ON action I edite the virtual device to call this API:

Code: Select all

http://DomoticzIP:Port/json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=100
or svalue=0 depending if inverted.

Hope this help. Otherwise paste some code here and I'll try my best.