Help with old Applescripts

Posted on
Tue Oct 15, 2019 5:26 pm
cmfulmer offline
Posts: 23
Joined: Jan 05, 2011

Help with old Applescripts

I'm trying to get a few pair of light switches to sync device state. Here's the applescripts I have:
trigger "Garage Master", action #1: execute embedded AppleScript "set on state of device "Garage Slave" to on state of device "Garage"..."
trigger "Garage Slave", action #1: execute embedded AppleScript "set on state of device "Garage" to on state of device "Garage Slave"..."
trigger "Side Flood Lights Master", action #1: execute embedded AppleScript "set on state of device "Side Flood Lights Slave" to on state of device "Side Flood Lights"..."
trigger "Side Flood Lights Slave", action #1: execute embedded AppleScript "set on state of device "Side Flood Lights" to on state of device "Side Flood Lights Slave"..."
trigger "Garage Eve Master", action #1: execute embedded AppleScript "set on state of device "Garage Eve Slave" to on state of device "Garage Eve"..."
trigger "Garage Eve Slave", action #1: execute embedded AppleScript "set on state of device "Garage Eve" to on state of device "Garage Eve Slave"..."
trigger "Curtain Outlet", action #1: execute embedded AppleScript "turn off "Curtains" in 10..."
trigger "Basement Master", action #1: execute embedded AppleScript "set on state of device "Basement Slave" to on state of device "Basement"..."
trigger "Basement Slave", action #1: execute embedded AppleScript "set on state of device "Basement" to on state of device "Basement Slave"..."
trigger "Stairs", action #1: execute embedded AppleScript "set on state of device "Stairs Master" to on state of device "Stairs"..."
trigger "Stairs Master", action #1: execute embedded AppleScript "set on state of device "Stairs" to on state of device "Stairs Master"..."

Can I do this directly through the 'triggers' pane now, or do I need to convert to Python?

Thanks,
Chad

Posted on
Tue Oct 15, 2019 7:31 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help with old Applescripts

There's a "Match On State of Device" action available now which does what you want.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Oct 16, 2019 9:43 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Help with old Applescripts

FlyingDiver wrote:
There's a "Match On State of Device" action available now which does what you want.


+1. This should greatly simplify your triggers... ;)

[MODERATOR NOTE] moved to appropriate forum.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Oct 16, 2019 4:25 pm
cmfulmer offline
Posts: 23
Joined: Jan 05, 2011

Re: Help with old Applescripts

I saw that when I was looking it over, and wasn't sure if that was the way to go or not. Thanks!

Posted on
Wed Jan 12, 2022 8:26 pm
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: Help with old Applescripts

hheyyyy, that's a nice feature, didn't know that existed either.

question: is there a sync-keypadlinc led-to-device/variable-state function?

i see, somewhat oddly, a sync-device-to-led-state function... this, presumably will... turn on a device based on the state of an led on a keypad? i can see this helping with 3-way switches i guess, not sure i get this one. :D i'm sure it's just me not getting it.

but, what about the above, sync led to device state or variable val? does this already exist and i just can't find it...? i originally just did as logic for all the leds, works fine.. but now have to dump all the as...

thanks!

Posted on
Thu Jan 13, 2022 12:31 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Help with old Applescripts

No UI actions for that yet, but here are some python snippets that should help with the conversions:

Code: Select all
# Push src_dev on/off state into dst_dev KeypadLinc LED state
src_dev = indigo.devices[123]   # "Source Lamp"
dst_dev = indigo.devices[456]   # "Dest KeypadLinc"
dst_led = 4      # 1 based, so 4 is 4th LED
indigo.relay.setLedState(dst_dev, dst_led, src_dev.onState)

Code: Select all
# Push boolean variable value into dst_dev KeypadLinc LED state
src_var = indigo.variables[123]   # "someBoolVariable"
dst_dev = indigo.devices[456]   # "Dest KeypadLinc"
dst_led = 4      # 1 based, so 4 is 4th LED
indigo.relay.setLedState(dst_dev, dst_led, src_var.getValue(bool))

Image

Posted on
Thu Jan 13, 2022 12:47 am
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: Help with old Applescripts

Excellent Matt, thanks a lot for that.

Posted on
Fri Jan 14, 2022 8:20 pm
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: Help with old Applescripts

hey, just a note that it seems that the mapping is actually 0-based, when i tried led 8 i got:

Code: Select all
   Error                           keypad button index 9 not in range (1 to 8)


using led 7 got me button 8. fyi.

these snippets are a lifesaver by the way --- thanks again!

Posted on
Sat Jan 15, 2022 10:42 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Help with old Applescripts

Thanks. I misread the Indigo code when creating the example. I'm glad it is 0 based as I was a bit annoyed when I thought it was 1 based. :wink:

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest