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: 2566
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.

Sonoma on a Mac Mini M1 running Airfoil Pro, Bond Home, Camect, Roku Network Remote, Hue Lights, DomoPad, Adapters, Home Assistant Agent, HomeKitLinkSiri, EPS Smart Dimmer, Fantastic Weather, Nanoleaf, LED Simple Effects, Grafana. UnifiAP

Posted on
Thu Feb 01, 2018 2:43 pm
jay (support) offline
Site Admin
User avatar
Posts: 18238
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: 2566
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.

Sonoma on a Mac Mini M1 running Airfoil Pro, Bond Home, Camect, Roku Network Remote, Hue Lights, DomoPad, Adapters, Home Assistant Agent, HomeKitLinkSiri, EPS Smart Dimmer, Fantastic Weather, Nanoleaf, LED Simple Effects, Grafana. UnifiAP

Posted on
Thu Feb 01, 2018 6:01 pm
Different Computers offline
User avatar
Posts: 2566
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!

Sonoma on a Mac Mini M1 running Airfoil Pro, Bond Home, Camect, Roku Network Remote, Hue Lights, DomoPad, Adapters, Home Assistant Agent, HomeKitLinkSiri, EPS Smart Dimmer, Fantastic Weather, Nanoleaf, LED Simple Effects, Grafana. UnifiAP

Who is online

Users browsing this forum: No registered users and 2 guests