How to Use AppleScript to Display Logs in Indigo Touch

Posted on
Thu Feb 01, 2018 11:59 am
Different Computers offline
User avatar
Posts: 1833
Joined: Jan 02, 2016
Location: East Coast

Re: How to Use AppleScript to Display Logs in Indigo Touch

Can you just restate the problem?

Sorry. Is there a way to trim the time stamps out of the variable result? The timestamp takes up most of the page width.

SmartThings refugee, so happy to be on Indigo. 10.13.6 on an i5 MBP w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKit Bridge, MatplotLib, Plex, uniFAP, Wunderground, Nanoleaf, LED Simple Effects, Airfoil Pro, Grafana.

Posted on
Thu Feb 01, 2018 2:43 pm
jay (support) offline
Site Admin
User avatar
Posts: 14534
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How to Use AppleScript to Display Logs in Indigo Touch

I think this'll do it (untested):

Code: Select all
import sys
import collections
import re

def tail(iterable, N):
    deq = collections.deque()
    for thing in iterable:
        if len(deq) >= N:
            deq.popleft()
        deq.append(thing)
    return list(deq)

# A list of the variable IDs - this script doesn't create them so they have to exist already
variable_ids = [1, 2, 3, 4, 5]

lines = tail(open("/Library/Application Support/Perceptive Automation/Indigo 7/Logs/indigo_log.txt"), len(variable_ids))
for index, line in enumerate(lines):
    # if the line starts with the date/time string formatted like this: 2018-02-01 00:00:24.350
    if re.match(r'^[0-9]{4}\-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}', line):
        # remove everything from the start of the line through the first tab, which removes the date
        line = "\t".join(line.split("\t")[1:])
    indigo.variable.updateValue(variable_ids[index], value=line)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Feb 01, 2018 2:50 pm
Different Computers offline
User avatar
Posts: 1833
Joined: Jan 02, 2016
Location: East Coast

Re: How to Use AppleScript to Display Logs in Indigo Touch

Thank you!

I'll try it tonight.

SmartThings refugee, so happy to be on Indigo. 10.13.6 on an i5 MBP w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKit Bridge, MatplotLib, Plex, uniFAP, Wunderground, Nanoleaf, LED Simple Effects, Airfoil Pro, Grafana.

Posted on
Thu Feb 01, 2018 6:01 pm
Different Computers offline
User avatar
Posts: 1833
Joined: Jan 02, 2016
Location: East Coast

Re: How to Use AppleScript to Display Logs in Indigo Touch

Jay, thanks again.

Your script was once again perfect!

SmartThings refugee, so happy to be on Indigo. 10.13.6 on an i5 MBP w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKit Bridge, MatplotLib, Plex, uniFAP, Wunderground, Nanoleaf, LED Simple Effects, Airfoil Pro, Grafana.

Who is online

Users browsing this forum: No registered users and 1 guest