It really is quite simple to do that sort of logic in a Python script with just a basic understanding. Let us know if you have any issues with your scripts over in the scripting forum section - lots of helpful and friendly people will chime in with examples and recommendations.
Plugin requests
- jay (support)
- Site Admin
- Posts: 18479
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Plugin requests
Re: Plugin requests
Hi @Jay I thought that it was pretty straightforward, but the method to get the actualstateID eludes me...does this output to a list somewhere?EagleDTW wrote: ↑Fri Nov 01, 2024 7:59 pmThanks, Jay...this is pretty straightforward and I appreciate the example read through!jay (support) wrote: ↑Fri Nov 01, 2024 9:29 am The easiest way is with a simple script:
Don't be freaked out - I've broken things out and added comments to describe what's going on as a learning exercise. However, if you want to simplify:Code: Select all
# Set up some local variables # this is the ID of nest device - it gets the full device instance device_to_test = indigo.devices[IDOFTESTDEVICE] # this is the ID of the state as shown in the custom states list # it gets the value of the specified state for comparison later device_state_value = device_to_test.states["ACTUALSTATEID"] # these are the IDs of the action groups to execute later true_action_group = IDOFTRUEACTIONGROUP false_action_group = ISOFFALSEACTIONGROUP # This does the actual work # the comparison that your image shows is to check to see if the state value contains the # specified string, but if the value is an exact match you can use '!=' instead of 'in' if "heat_cool" not in device_state_value: # it's not in the state value so execute the true group indigo.actionGroup.execute(true_action_group) else: # it's in the state value, so execute the false group indigo.actionGroup.execute(false_action_group)
Just substitute the appropriate UPPERCASEVALUES with the actual values and I think it'll work.Code: Select all
if "heat_cool" not in indigo.devices[IDOFTESTDEVICE].states["ACTUALSTATEID"]: indigo.actionGroup.execute(IDOFTRUEACTIONGROUP) else: indigo.actionGroup.execute(ISOFFALSEACTIONGROUP)
Re: Plugin requests
In the Indigo UI, right-click on the device and select "Print Device Details to Event Log". Within the log output, look for the key `states` -- all the state names will be listed for the device.
I came here to drink milk and kick ass....and I've just finished my milk.
My Plugins and Scripts
My Plugins and Scripts
- jay (support)
- Site Admin
- Posts: 18479
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Plugin requests
Assuming it's a custom state, it also shows in the Custom States tile when you select the device in the Home Window.
Re: Plugin requests
I appreciate the quick responses from both of you!!
Re: Plugin requests
Hi @Jay,
Are Variable states just this script or something a bit different:
if "status_var" not in indigo.variables[IDOFVARIABLE].value["ACTUALVALUE"]:
indigo.actionGroup.execute(IDOFTRUEACTIONGROUP)
else:
indigo.actionGroup.execute(ISOFFALSEACTIONGROUP)
Thank you,
Daniel
Are Variable states just this script or something a bit different:
if "status_var" not in indigo.variables[IDOFVARIABLE].value["ACTUALVALUE"]:
indigo.actionGroup.execute(IDOFTRUEACTIONGROUP)
else:
indigo.actionGroup.execute(ISOFFALSEACTIONGROUP)
Thank you,
Daniel
Re: Plugin requests
Variables don't have `states`, they have `values` and the values are always strings. You can access the variable's string value directly.
Try this:
Try this:
Code: Select all
if "status_var" not in indigo.variables[IDOFVARIABLE].value:
indigo.actionGroup.execute(IDOFTRUEACTIONGROUP)
else:
indigo.actionGroup.execute(ISOFFALSEACTIONGROUP)
I came here to drink milk and kick ass....and I've just finished my milk.
My Plugins and Scripts
My Plugins and Scripts
Re: Plugin requests
Nice - thanks, Dave! I'll give that a try!!
-Daniel
-Daniel
Re: Plugin requests
And Dave would it be this for changing a variable value:
if "status_var" not in indigo.variables[IDOFVARIABLE].value:
indigo.variables(IDOFVARIABLE).value[true]
else:
indigo.actionGroup.execute(ISOFFALSEACTIONGROUP)
if "status_var" not in indigo.variables[IDOFVARIABLE].value:
indigo.variables(IDOFVARIABLE).value[true]
else:
indigo.actionGroup.execute(ISOFFALSEACTIONGROUP)
Re: Plugin requests
Got it solved!!
if "true" not in indigo.variables[18821087].value:
myVar = indigo.variables[8360458]
indigo.variable.updateValue(myVar, "true")
else:
indigo.actionGroup.execute(861401)
-Daniel
if "true" not in indigo.variables[18821087].value:
myVar = indigo.variables[8360458]
indigo.variable.updateValue(myVar, "true")
else:
indigo.actionGroup.execute(861401)
-Daniel
Re: Plugin requests
Good on ya. In circumstances like this, it's best to check the documentation. It'll save you a lot of time.
For instance,
https://wiki.indigodomo.com/doku.php?id ... able_class
For instance,
https://wiki.indigodomo.com/doku.php?id ... able_class
I came here to drink milk and kick ass....and I've just finished my milk.
My Plugins and Scripts
My Plugins and Scripts