jay wrote:...- We removed the assumption that lights are ON if the first command we see is an OFF - so if you turn on a light at 10pm and leave it on all night, it won't show as being on. We're kicking around a couple of ideas on how to address that so watch this thread for more information.
Kick, kick... Here is a quick, but useful, little AppleScript that should address the problem Jay noted. The script checks Indigo's internal status for every device and then updates the sqlite db with pseudo
On records for each device that is on. The net effect is that the Usage Report will only be off by at most a minute for devices that were on at mid-night.
The script should be saved as an external AppleScript (I called it "what-is-on.scpt") and then
run daily at 12:01AM* as the
Action of an Indigo
Time/Date Action.
- Code: Select all
set devIsOnTable to {} as list
tell application "IndigoServer"
repeat with currentDevice in devices
tell currentDevice
set dev_name to name of currentDevice
set dev_dim to supports dimming of currentDevice
set dev_state to on state of currentDevice
if dev_state then
if not dev_dim then
set dev_value to "NULL"
else
set dev_value to brightness of currentDevice
end if
set dev_state to "True"
set the end of devIsOnTable to {dev_name, dev_state, dev_value}
end if
end tell
end repeat
end tell
repeat with dev_name in devIsOnTable
set db to quoted form of "/Library/Application Support/Perceptive Automation/Indigo 4/IndigoSqlClient/sqlite_db"
set s to "/usr/bin/sqlite3 " & db
set s to s & " \"INSERT INTO device_history_basic (dev_name, dev_state, dev_value) VALUES('"
set s to s & item 1 of dev_name & "','" & item 2 of dev_name & "'," & item 3 of dev_name & ");\""
do shell script s
tell application "IndigoServer"
log "Saved ON state of " & item 1 of dev_name using type "sql update"
end tell
end repeat
*Minor Peeve: Why doesn't Indigo support, as an option, a 24 hour clock? IMHO, 00:01 is much clearer than 12:01AM