Blinds Sync?


(Marc) #1

I have a Somfy 5 blinds channel setup for my 5 bay window. Channel 5 controls all of my blinds and the the other 4 channels control the other window individually. 90% of the time I use the “All Blinds” channel to control my blinds but when I do so, the other blinds status doesn’t sync. (See below). I know one way to work around this to create a Rule Machine rule to duplicate the commands to the other blinds a minute after I issue a command to the All blinds channel but it’s messy and sometimes move my blinds back and forth. It also prevents me from changing their state quickly if I issue the wrong command by accident. I am looking for a way to copy the status of my All Blinds channel to the others without actual issuing commands to my blind controller. Does anyone have any suggestions?


Somfy Motorized Shades Install Success Stories?
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

If the DTH code for the Blinds controller is open source, make a personal copy (if you don’t already have one) and add ad hoc custom Commands, such as “command syncAllOn, syncAllOff” which can issue sendEvent() calls for each of the blinds to update their States, bypassing actual Z-Wave or ZigBee commands.

Make any sense… It’s probably easier to describe by giving sample or full code.


(Jason "The Enabler" as deemed so by @Smart) #3

You could also, if the device supports it, run a custom command on them.

See if they support refresh()


(Marc) #4

Thanks.

The code is here:
Somfy shades

Please let me know if have an idea where to stick this suggestion in the code.


(Marc) #5

Refresh won’t work because the controller doesn’t update its status. Each blind channel works independently of the other. Thanks though.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #6

Thanks for the code pointer … still too busy at the moment to completely flesh this out, but here’s the idea for you to consider if practical or even try to implement:

  1. Add commands “syncOpen”, “syncClosed” (around line 46).
  2. The commands do a sendEvent() to themselves ...sendEvent( name: “windowShade”, value: “open”)(andvalue: “closed”`, respectively).
  3. Create a simple SmartApp that subscribes to on/off events from the Channel 5 device instance (i.e., accept input of any capability Window Shade, multiple: false.
  4. Also input the list of shades whose state needs to be synced (input Windows Shade, multiple: true).
  5. When #3 subscription is caught, the SmartApp calls the Command syncOpen or syncClosed for each of the Devices of #4.

Sound like it will work?


(Marc) #7

Possibly. Just keep in mind, there is 3 states, open, closed and tilted. I’ll try and work on this when I have time. Thanks.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #8

Yup… I think you can just enhance my idea by adding the third Command (syncTilted), and/or use a single sync Command with parameter(s).


(Marc) #9

Just to clarify, so I add those commands after line 46, but do I need to add anything else? You mentioned the sendevent, but not sure if I have to define those anywhere or they just do it automatically.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #10

No… you need to do a bit more than that! The “commands” section just declares the commands… you need to define the command methods like any other command method.

The methods should be pretty simple though… i.e., they just call sendEvent(...) as I outlined.

NB: As usual… I try to just outline the possible solution, not give the full and tested code, so that this is an educational and mutual “teach to fish” experience. If you want to book some affordable paid tutorial or development services, please send me a PM.


(Marc) #11

Ok, I am a little stuck but feel like I am getting close.

Here is my code for the actual DTH:

def OpenSync() {
sendEvent (name:“windowShade”, value: “open”)
}

def CloseSync() {
sendEvent (name:“windowShade”, value: “closed”)
}

def TiltSync() {
sendEvent(name: “windowShade”, value: “partially open”)
}

Here is my code for the smartapp where I am getting errors: (I havent sent the commands yet, just debugging. I am getting IDE errors:

groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.call() is applicable for argument types: (script1462069587075522441560$_shadestate_closure2) values: [script1462069587075522441560$_shadestate_closure2@7b95280e]
Possible solutions: wait(), any(), wait(long), and(java.lang.Boolean), any(groovy.lang.Closure), each(groovy.lang.Closure) @ line 66

def shadestate(evt) {
if (evt.value == “open”) {
log.debug “Blinds are open!”
}
else {
if (evt.value == “closed”) {
log.debug “Blinds are closed!”
}
else {
(evt.value == “tilted open”) {
log.debug “Blinds are titled!”
}
}
}
}


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #12

Could you paste the full SmartApp please? I don’t see for certain what might cause the errors.


(Marc) #13

definition(
name: “Blinds Sync”,
namespace: “mbhforum”,
author: “mbhforum”,
description: “Syncs blind status with other blinds”,
category: “My Apps”,
iconUrl: “http://cdn.device-icons.smartthings.com/alarm/beep/beep@2x.png”,
iconX2Url: “http://cdn.device-icons.smartthings.com/alarm/beep/beep@2x.png
)

preferences {
page(name: “mainPage”, title: “Blind Sync Setup”, install: true, uninstall:true) {
section(“Blind Sync Setup” )
{
input(“MasterBlind”, “capability.windowShade”, title: “Pick the master blind”, multiple: false)


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #14

Still missing a lot of code…?


(Marc) #16

I got it working! Thank you so much @tgauchat for guiding me! Below is the smartapp for those that are interested, You also have to make minor changes to @E_Sch’s latest Somfy device type.(PM me if you want). In the past week, I’ve gotten now Alexa to open/close blinds by saying “Alexa, Close Blinds” or “Alexa, Open Blinds” and now have all my channels sync properly.

/**

  • Copyright 2015 SmartThings
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.

*/

definition(
name: “Blinds Sync”,
namespace: “mbhforum”,
author: “mbhforum”,
description: “Syncs blind status with other blinds”,
category: “My Apps”,
iconUrl: “http://cdn.device-icons.smartthings.com/alarm/beep/beep@2x.png”,
iconX2Url: “http://cdn.device-icons.smartthings.com/alarm/beep/beep@2x.png
)

preferences {
page(name: “mainPage”, title: “Blind Sync Setup”, install: true, uninstall:true) {
section(“Blind Sync Setup” )
{
input(“MasterBlind”, “capability.windowShade”, title: “Pick the master blind”, multiple: false)
input(“ReplicaBlind”, “capability.windowShade”, title: “Pick your replica blind(s)”, multiple: true)
}
}

}

def commands(){
command "OpenSync"
command "CloseSync"
command “TiltSync”
}

def installed() {
initialize()
}

def updated() {
unsubscribe()
initialize()
}

def initialize() {
subscribe(MasterBlind, “windowShade”, shadestate)
}

def shadestate(evt) {
if (evt.value == “open”) {
log.debug "Blinds are open!"
ReplicaBlind.OpenSync()
}
else {
if (evt.value == “closed”) {
log.debug "Blinds are closed!"
ReplicaBlind.CloseSync()
}
else {
if (evt.value == “partially open”) {
log.debug "Blinds are titled"
ReplicaBlind.TiltSync()
}

}
  		}
     }    

def OpenSync() {
sendEvent (name:“windowShade”, value: “open”)
}

def CloseSync() {
sendEvent (name:“windowShade”, value: “closed”)
}

def TiltSync() {
sendEvent(name:“windowShade”, value: “partially open”)
}


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #17

I don’t think the above function is needed in the SmartApp… Actually I’m surprised it compiles!(?).


(Marc) #18

You are correct, I forgot to remove that when I was troubleshooting. I was learning this as I go. It works out well now but probably could be made more elaborate as a lot of people have different blind setups.