Icon does not change whatever I do - CURTAINS

Posted on
Sat Jul 06, 2019 2:37 pm
Mirko offline
Posts: 79
Joined: Dec 04, 2014

Icon does not change whatever I do - CURTAINS

Hi Jay,

I use your latest Indigo 7.3 on my macmini running 10.12.6

To open/close my curtains I use the ZWave curtain-rails by Forestgroup.com
This works fine.

But I have a problem with the device state, especially in combination with my control page.
When the device state is not exactly #0 (zero) but #1 because the curtain rails is not that exact, Indigo sees the curtain as ‘closed’ because the device state is stil ‘ON’.
This has some consequences for my triggers, but I can work around it. But not for the Control Page.
The Icon shows the ‘closed’ position when in fact it the curtain is open. Since the icon reacts at the Device State. When the device state is #1 it still sees the device(curtain) as ‘ON’ (=CLOSED).
If it is the opposite and the curtain is ‘OPEN’ (and also not precise) I can write a trigger saying that between 95 - 100 it means ‘OPEN’. And this works for the triggers through Variables. But not if I write a trigger saying that between #1 - #5 means ‘ON’. It still reacts if it is ‘OFF’ because that part uses the Device State.

When I write in Indigo a Virtual Device the Icon works by showing the right ON / OFF but then the icon does not work to toggle through the Popup UI Controls in order to open or close the curtains. Also when I put two actions into the Server action (Edit Actions on the control page) it reacts only to the Display: Device State

If I try it with the Display: VariableValue it does not work by the use of the Icon and the right display of the icon. Right now I use the text: OPEN or CLOSED next to the icon because that works with triggers I wrote. But it is confusing especially for the others living with me in my house.

Could you help me out here? It would be really very much appreciated.

Kind Regards,

Mirko
Attachments
Curtain1+on.png
Curtain1+on.png (3.28 KiB) Viewed 4050 times
Curtain1.png
Curtain1.png (2.65 KiB) Viewed 4050 times

Posted on
Sat Jul 06, 2019 4:22 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Icon does not change whatever I do - CURTAINS

What are the exact device type in Indigo for those curtain rails? Do they show up as dimmers or something else? If they aren't dimmers, then please explain exactly how they present themselves in Indigo and what states are necessary to understand.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Jul 06, 2019 4:45 pm
Mirko offline
Posts: 79
Joined: Dec 04, 2014

Re: Icon does not change whatever I do - CURTAINS

If I hit the icon a slider appeares so I will be able to open/close the curtains at any percentage I like.
As a Device it looks like a dimmer

Posted on
Sun Jul 07, 2019 11:25 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Icon does not change whatever I do - CURTAINS

OK, so it's a dimmer and we can look at the brightness of the dimmer to determine if it's open or closed.. Now, let's clearly define the goals you're trying to accomplish:

  1. On a control page, you want to display the state of the curtains using this formula: when the curtain's "openness"N (i.e. brightness) is between 0 and 5, you want the "closed" icon to show, otherwise show the "open" icon
  2. When you tap/click on the icon in a control page, you want it to toggle the state of your curtain device between 100% (open) and 0% (closed)

Do I have those right? And is that list complete? Make adjustments as necessary then we'll get on with offering solutions.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jul 08, 2019 3:14 am
Mirko offline
Posts: 79
Joined: Dec 04, 2014

Re: Icon does not change whatever I do - CURTAINS

On a control page, you want to display the state of the curtains using this formula: when the curtain's "openness"N (i.e. brightness) is between 0 and 5, you want the "closed" icon to show, otherwise show the "open" icon


It is exact the opposite: 0...5 = OPEN (the curtains folded together one can view the garden)
Thats when I need to show the 'open' icon
Attachments
Curtain1.png
Curtain1.png (2.65 KiB) Viewed 3943 times

Posted on
Mon Jul 08, 2019 8:41 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Icon does not change whatever I do - CURTAINS

Ok, so, using these as the assumptions:

  1. On a control page, you want to display the state of the curtains using this formula: when the curtain's "openness"N (i.e. brightness) is between 0 and 5, you want the "open" icon to show, otherwise show the "closed" icon
  2. When you tap/click on the icon in a control page, you want it to toggle the state of your curtain device between 100% (open) and 0% (closed)

There are a variety of options for solving this issue. I'm just going to randomly pick one, which uses a variable to maintain a boolean representing the logic represented in #1 and a small script action that handles #2.

So, to solve part 1 you need a variable (say, curtain_open) that will have a value of "true" or "false", and a trigger that maintains that state. The trigger will be configured to fire on any change in the curtain device's brightness and the action will be the following python script:

Code: Select all
curtain_device = indigo.devices[1234567890]  # Your curtain controller device
if curtain_device.brightness > 5:
    indigo.variable.updateValue(9876543210, value="false")  # Your curtain_open variable ID
else:
    indigo.variable.updateValue(9876543210, value="true")  # Your curtain_open variable ID


So, whenever the brightness of your curtain device changes, the script looks at the new brightness value and determines the value of the variable. Name your images Curtain1+.png for the closed image and Curtain1+true.png as the open image. You can now put a page element on a control page pointing to that variable and using the Curtain1+.png base image and have the right value reflected. Note that you could do it without a script by having 2 triggers: one with a condition of brightness between less than 6 and the other with a brightness greater than 5 and then add the appropriate set variable actions.

Next, we want to handle the toggling of the device when you click/tap the variable page element you created above. As the action for the page element, use the following script:

Code: Select all
curtain_device = indigo.devices[1234567890]  # Your curtain controller device
if curtain_device.brightness > 5:
    indigo.dimmer.setBrightness(curtain_device, value=0)
else:
    indigo.dimmer.setBrightness(curtain_device, value=100)


This script will set the brightness of your curtain device appropriately. A side effect is that the variable will be updated when the device reports the new brightness back to Indigo which will cause the icon to update. Note that there may be a delay depending on how/when the device reports the updated brightness back to Indigo. If, for instance, the device doesn't report the new brightness until the cycle completes and it takes 10 seconds to complete, then the variable won't be updated for 10 seconds and therefore the icon won't change for 10 seconds. That's probably the correct behavior - just wanted to point that out.

I haven't tested the above, so I might have gotten something slightly wrong, but it's a sound design that should get you to your solution. Note that you could get really clever and have a variable with 4 states (open, closed, opening, closing) and in the second script also change the variable value to "opening" or "closing" (you'd need to adjust the image names appropriately) so that the icon on the control page would indicate if the curtains are in the process of changing (assuming your curtain device doesn't report the new brightness until after it's finished doing the work).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jul 08, 2019 2:01 pm
Mirko offline
Posts: 79
Joined: Dec 04, 2014

Re: Icon does not change whatever I do - CURTAINS

So, to solve part 1 you need a variable (say, curtain_open) that will have a value of "true" or "false", and a trigger that maintains that state. The trigger will be configured to fire on any change in the curtain device's brightness and the action will be the following python script:

Code: Select all
curtain_device = indigo.devices[1234567890] # Your curtain controller device
if curtain_device.brightness > 5:
indigo.variables.updateValue(9876543210, value="false") # Your curtain_open variable ID
else:
indigo.variables.updateValue(9876543210, value="true") # Your curtain_open variable ID


I made a Trigger:
Device State Changed
Device: 139 - Gordijnen 2hg BADkamer LICHT - Motor Control Class C (= the name of the curtain device)
Brightness level
Has Any Change

ACTIONS
Embedded Python:
curtain_device = indigo.devices[49076382] # 139 - Gordijnen 2hg BADkamer LICHT - Motor Control Class C
if curtain_device.brightness > 5:
indigo.variables.updateValue(9876543210, value="false") # 1575789550
else:
indigo.variables.updateValue(9876543210, value="true") # 1575789550

When I tap the button "Run" I get in RED: embedded script: 'VariableList' object has no attribute 'updateValue'

In the LogFile: Script Error embedded script: 'VariableList' object has no attribute 'updateValue'
Script Error Exception Traceback (most recent call shown last):

embedded script, line 3, at top level
AttributeError: 'VariableList' object has no attribute 'updateValue'


And nothing changes in the Variable:
GordijnenBADlicht2hgcurtain_open_truefalse with the variable ID: 1575789550

Posted on
Mon Jul 08, 2019 8:54 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Icon does not change whatever I do - CURTAINS

Typos in my first script. Changed in-line in that script so update accordingly (indigo.variables should be indigo.variable).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 09, 2019 1:20 am
Mirko offline
Posts: 79
Joined: Dec 04, 2014

Re: Icon does not change whatever I do - CURTAINS

Goodmorning Texas! :)

I changed the typos but I get right now:

Script Error embedded script: ElementNotFoundError -- could not find variable with element ID 4294967295
Script Error Exception Traceback (most recent call shown last):

embedded script, line 3, at top level
ValueError: ElementNotFoundError -- could not find variable with element ID 4294967295


and I have no idea where the element ID 4294967295 comes from .....

Posted on
Tue Jul 09, 2019 8:54 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Icon does not change whatever I do - CURTAINS

Your script apparently has the wrong ID in it. It's in the indigo.variable.updateValue call.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 09, 2019 10:46 am
Mirko offline
Posts: 79
Joined: Dec 04, 2014

Re: Icon does not change whatever I do - CURTAINS

Thanks a lot, Jay! It works :D :D

There is one more question: I used to have a slider appearing when I hit the icon to open or close the curtains. Now there is no slider since it is a variable and not a device on the control page anymore. That slider is quite handy. Is it possible to get the slider back? In order to stop the curtains half way or just a bit more open or closed.

Anyway I'm very pleased with the above scripts!

Posted on
Thu Aug 08, 2019 11:37 pm
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: Icon does not change whatever I do - CURTAINS

This is a very satisfying Indigo tutorial. Consider pinning it.

Re: Slider... on Control Pages, for elements on them (image, text), different stuff happens by default when you click on them as something like Client Actions (as opposed to Server Actions, which cover Action Groups and plugins and stuff) autofills.

My guess: before, your Control Page used to use the device state, now it’s using a variable value. The only client action for variables is to Update Variable.

Many ways to fix.
Quickest: Since you can’t popup a dimmer for a variable, you can put a transparent png over it. Then, when you click on the variable, you are actually clicking on a transparent png. THEN: make the png a device state for the actual Indigo Device. Then, make a client action like, “popup ui controls,” or something named in that gist. It should now give you a dimmer slider back, but still handle the new variable/trigger going on.

Hope i didn’t miss the mark there

Posted on
Sun Aug 18, 2019 5:02 am
Mirko offline
Posts: 79
Joined: Dec 04, 2014

Re: Icon does not change whatever I do - CURTAINS

Super! A transparant PNG on top! Works!!

Thanks :D

Posted on
Tue Nov 05, 2019 8:17 pm
mgolden50 offline
User avatar
Posts: 247
Joined: Jan 29, 2007
Location: Chandler, AZ

Re: Icon does not change whatever I do - CURTAINS

Hi, I have tried to use every thing I can grasp form the forums to no effect.

I want to overlay a flame icon with a snow flake icon when either heater A/C or Heater device is running. And I would like nothing showing on the screen when neither device is on. But instead when neither is running I get an outline drawing of each Icons. Both Icons show properly with color when the devices are running. I have tried using a blank png image for the base image and for the "off" image but that doesn't seem to work for me.

What am I not getting?

Posted on
Wed Nov 06, 2019 10:05 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Icon does not change whatever I do - CURTAINS

What device state are you using to determine which icon to use and what are it's potential values? What are the names of the custom images you're using?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Who is online

Users browsing this forum: No registered users and 3 guests