Converting Security script to Python

Posted on
Wed Oct 28, 2020 4:51 am
macpro offline
User avatar
Posts: 721
Joined: Dec 29, 2005
Location: Third byte on the right

Converting Security script to Python

I've been using an ancient version of the Security script for many years. And it looks like it is the last speedbump on my way to Indigo 7.4.

Basically I need to convert this to Python:

Code: Select all
using terms from application "IndigoServer"
   on receive security event of eventType with code devID
      bla bla bla
   end receive security event
end using terms from      


How can I do this?

"I tawt I taw a puddy tat!" Tweety

Posted on
Wed Oct 28, 2020 7:09 am
FlyingDiver online
User avatar
Posts: 5321
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Converting Security script to Python

What's a security event?

Or, a better question is, what does this actually do? If you disable this script, what happens (or doesn't happen)?

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

Posted on
Wed Oct 28, 2020 7:24 am
macpro offline
User avatar
Posts: 721
Joined: Dec 29, 2005
Location: Third byte on the right

Re: Converting Security script to Python

See https://wiki.indigodomo.com/doku.php?id=x10_security_events for some details.
Basically it allows a running AppleScript to respond to events from X10 Security devices, like door/window sensors.

"I tawt I taw a puddy tat!" Tweety

Posted on
Wed Oct 28, 2020 7:27 am
FlyingDiver online
User avatar
Posts: 5321
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Converting Security script to Python

Ok, so what's the answer to the second part of the question? What devices do you have that generate these events?

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

Posted on
Wed Oct 28, 2020 7:56 am
macpro offline
User avatar
Posts: 721
Joined: Dec 29, 2005
Location: Third byte on the right

Re: Converting Security script to Python

X10 Security devices. Look door/window sensors, motion detectors etc..
They are not visible in Indigo as devices.

And when I disable that script, Indigo will no longer know if doors/windows are open or closed.

"I tawt I taw a puddy tat!" Tweety

Posted on
Wed Oct 28, 2020 8:54 am
WagnerOne offline
Posts: 124
Joined: Jun 12, 2009
Location: Chicago, IL

Re: Converting Security script to Python

I'm going to be in this same boat when I try to upgrade. I am still using that old Security Script too. I looked into switching to Switchboard a few times, but never got around to it.

I have upwards of 20 EagleEye/ActiveEye MS13A/MS16A X10 motion sensors in my system. I've been replacing them slowly with z-wave sensors, but the types I have and want more of (I'm looking at you Dome) all seem to be in short/no supply the past many months.

All my X10 motion/door/etc. sensors talk to Indigo via a dedicated W800RF32 interface.

I used to have some DS10A dry contact sensors talking to the W800 too, but I've retired all those at this point. I basically cut the leads off the dry contacts I was using and wired in a Z-Wave Ecolink door/window sensors.

Other cheap X10 sensors like the MS10A worked with that script too.

This setup has been bulletproof and working flawlessly for decades at this point. The X10 sensors are super small/discrete, battery operated via 2xAAA batteries and are indoor/outdoor. Most importantly they are very inexpensive. Why would I want to pay for a "multi" sensor that I never use anything more than the motion capabilities of for $40 each when I can get 3 of these old X10 motion sensors for $20.

Posted on
Wed Oct 28, 2020 9:25 am
FlyingDiver online
User avatar
Posts: 5321
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Converting Security script to Python

Turns out there's an example plugin in the SDK that shows how to do this, sort of. Here's the relevant code:

Code: Select all

################################################################################
class Plugin(indigo.PluginBase):
   ########################################
   def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs):
      super(Plugin, self).__init__(pluginId, pluginDisplayName, pluginVersion, pluginPrefs)
      self.debug = True

   ########################################
   def startup(self):
      self.debugLog(u"startup called -- subscribing to all X10 and INSTEON commands")
      indigo.insteon.subscribeToIncoming()
      indigo.insteon.subscribeToOutgoing()
      indigo.x10.subscribeToIncoming()
      indigo.x10.subscribeToOutgoing()

   def shutdown(self):
      self.debugLog(u"shutdown called")

   ########################################
   def insteonCommandReceived(self, cmd):
      self.debugLog(u"insteonCommandReceived: \n" + str(cmd))

   def insteonCommandSent(self, cmd):
      self.debugLog(u"insteonCommandSent: \n" + str(cmd))

   ########################################
   def x10CommandReceived(self, cmd):
      self.debugLog(u"x10CommandReceived: \n" + str(cmd))

      if cmd.cmdType == "sec":   # or "x10" for power line commands
         if cmd.secCodeId == 6:
            if cmd.secFunc == "sensor alert (max delay)":
               indigo.server.log(u"SENSOR OPEN")
            elif cmd.secFunc == "sensor normal (max delay)":
               indigo.server.log(u"SENSOR CLOSED")

   def x10CommandSent(self, cmd):
      self.debugLog(u"x10CommandSent: \n" + str(cmd))



I don't know if the
Code: Select all
indigo.x10.subscribeToIncoming()
call can be made in an external (always running) script, or if it has to be a plugin.

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

Posted on
Wed Oct 28, 2020 9:34 am
macpro offline
User avatar
Posts: 721
Joined: Dec 29, 2005
Location: Third byte on the right

Re: Converting Security script to Python

Thanks. Will give that a go.

"I tawt I taw a puddy tat!" Tweety

Posted on
Wed Oct 28, 2020 9:50 am
jay (support) offline
Site Admin
User avatar
Posts: 16778
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Converting Security script to Python

FlyingDiver wrote:
I don't know if the
Code: Select all
indigo.x10.subscribeToIncoming()
call can be made in an external (always running) script, or if it has to be a plugin.


It has to be a plugin.

The Switchboard is available on Benjamin's github repo. I think it still works but I've never personally used it.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Oct 28, 2020 1:07 pm
macpro offline
User avatar
Posts: 721
Joined: Dec 29, 2005
Location: Third byte on the right

Re: Converting Security script to Python

I've found the Switchboard plugin (thanks to Jay) and it seems to do the trick.
Still figuring out how to configure everything, but it looks like a can use it to replace the old Security script.

"I tawt I taw a puddy tat!" Tweety

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest