I’m exploring options for raising a DIY roman shade. Can you say what you are using? It might be useful for me.
Anyway, to your questions. Easiest answers first:
You can put all your Items representing each curtain into a Group and put the Group on your sitemap/habpanel as a Switch and any command sent to the Group will get forwarded to all the members of the Group.
The other part is more challenging. First I’ll assume we are using a sitemap based UI and not HABPanel because I don’t think HABPanel supports something akin to the visibility tag.
You will need to create a new Item that represents the state of the curtains: OPEN, OPENING, CLOSING, CLOSED. Make it a String Item since there are four states and let’s call it Robo500_State.
Next you need to create a proxy Item that you put on your sitemap. Do not put the Robo500 on your sitemap. Let’s call the proxy Item Robo500_Proxy.
Now you need a Rule that takes the command to the proxy Item, updates the state Item and forward’s the right command to the Robo500 Rule.
rule "Robo500"
when
Item Robo500_Proxy received command
then
if(Robo500_State.toString == "OPENING" || Robo500_State.state.toString == "CLOSING") return; // ignore commands if the curtains are moving
// Update the State Item
val newState = if(Robo500_State.toString == "OPEN") "CLOSING" else "OPENING"
Robo500_State.postUpdate(newState)
// Send the command to the motor
Robo500.sendCommand(ON)
// Set a Timer to set the state back after the amount of time if takes for the curtains to fully open/close
createTimer(now.plusSeconds(???), [ |
Robo500_State.postUpdate(if(Robo500_State.state("OPENING")) "OPEN" else "CLOSED")
])
end
I just typed in the above. I’m sure there are errors and edge cases not handled (e.g. what if Robo500_State is NULL?).
Finally, you need to use the visibility tag on the sitemap to show a separate line based on the State Item.
Switch item=Robo500_Proxy mappings=[ON=Open] visibility=[Robo500_State == CLOSED]
Switch item=Robo500_Proxy mappings=[ON=Close] visibility=[Robo500_State == OPEN]
Text item=Robo500_Proxy label="Robo500 is opening" visibility=[Robo500_State == OPENING]
Text item=Robo500_Proxy label="Robo500 is closing" visibility=[Robo500_State == CLOSING]
Again, I just typed this in and there may be errors.