I have a continuously running perl script which maintains TCP connections to a terminal server, in turn connecting to various RS232/RS485 devices around the house (A/V equipment, thermostats, spa, alarm panel, etc). This script also keeps a connection to Indigo via the XML port, which provides a very nice event feed in both directions.
Although some bits of automation logic are handled directly by my program, in other cases I find it useful to integrate with Indigo, particularly for the control pages. I am working on one for my spa, which uses Pentair equipment.
I have struggled with how to reliably transmit control page button presses to my external script. Indigo does not have an explicit means to do this as far as I can tell, so I tried to be creative. At first I did it using a variable for each button. This proved problematic for a variety of reasons: there are situations which can cause commands to the Pentair interface to be dropped (equipment is in service mode, two commands sent in immediate succession, TCP connection lost, etc). Since Indigo only sends the variable change notifications when the variable actually changes, there is no event triggered when the button is pressed a second time. Thus the control page could easily get in a state where it would not reflect the actual situation at the spa controller, and further button presses would not have the expected effect because they were already "stuck down".
I noticed that the Indigo log records an entry every time a button is pressed, so I tried using that to trigger my script. This worked MUCH better but was kind of kludgy to set up. Each button is configured to assert a dummy variable, because it needs to have some action associated with it in order for Indigo to log it. Then my script watches for the log updates, and sends the corresponding commands to the Pentair system. When the pentair responds with the status updates, these are mapped to the variables that I want to show in Indigo.
At first, while testing this on my Mac's browser, everything appeared to be working perfectly, but then I ran into a show stopper: when clicking control page buttons on the indigo touch app, no updates are recorded to the log. However, if I use Safari on the iPhone to open the control page, it works correctly! So that is question #1: what's going on differently in the app that makes it fail to log the button events?.
And Question #2: could Indigo provide a better way to do this by triggering an explicit event notice to an XML client? . Actually, the LogStream messages would suffice as-is, if I could be sure that they were sent on ANY button click event (even if the action associated with the button is a no-op). What would be even better is if it could use a symbolic name so that I don't have hard coded z-order numbers in the external script.
thanks!
-----
Here's the control page [updated]:
Here's how the buttons are configured:
My external script is connected via the Indigo control port. It receives control page events via the Indigo log:
Each control page button (hard coded by z-order) triggers a corresponding command which is sent to the Pentair iLink interface:
When I receive status updates from the Pentair system, they are mapped to variable updates which are sent to Indigo:
..and likewise for the chemical feeder: