raneil wrote:
Apple stopped including the "enscript" command-line utility with Mac OS X sometime after Snow Leopard. I'm not sure which Mac OS X version was the last to include it. For more current versions, you'll need to download the "enscript" source code and build it yourself, or locate a pre-built binary. I have used MacPorts successfully on several Macs running Mavericks with no issues.
set theCommand to "cat " & textFileQuotedPath & " | enscript -fMonaco" & fw & "/" & fh & " -" & po & "lqs" & ls & " --non-printable-format=space --margins=" & lm & ":" & rm & ":" & tm & ":" & bm & " -o - | pstopdf -i -o " & pdfFileQuotedPath
set shellResult to do shell script theCommand
do shell script "cat '/Users/davidmorhun/Documents/Wunderground Alert Files/alert.txt' | enscript -fMonaco8/8.5 -Rlqs3.0 --non-printable-format=space --margins=140:5:5:5 -o - | pstopdf -i -o '/Users/davidmorhun/Documents/Wunderground Alert Files/tmp/temp.pdf'"
--> error "sh: enscript: command not found
pstopdf failed on PS read from stdin with error code -30998" number 234
"cat '/Users/davidmorhun/Documents/Wunderground Alert Files/alert.txt' | enscript -fMonaco8/8.5 -Rlqs3.0 --non-printable-format=space --margins=140:5:5:5 -o - | pstopdf -i -o '/Users/davidmorhun/Documents/Wunderground Alert Files/tmp/temp.pdf'"
six50joe wrote:
Also, the device that my control is attached to has a 0/1 state, but the image doesn't dynamically change; it always remains in the 'closed' state. Can anyone advise?
six50joe wrote:
Hoping to get this to work; the controls look dynamite.
ctPlugin = indigo.server.getPlugin("com.swmetrics.indigoplugin.colortouch")
ctPlugin.executeAction("setSpecificMode", tstat, props={'newMode': indigo.kHvacMode.HeatCool, 'newFanMode': indigo.kFanMode.Auto, 'newHeatTo': adjustedHeatSetpoint, 'newCoolTo': adjustedCoolSetpoint})
indigo.thermostat.setHeatSetpoint(tstat, value=adjustedHeatSetpoint)
indigo.thermostat.setCoolSetpoint(tstat, value=adjustedCoolSetpoint)
indigo.thermostat.setHvacMode(tstat, value=indigo.kHvacMode.HeatCool)
indigo.thermostat.setFanMode(tstat, value=indigo.kFanMode.Auto)
2016-04-22 10:00:07 ColorTouch Thermostat Error Error in plugin execution ExecuteAction:
Traceback (most recent call last):
File "plugin.py", line 1204, in actionControlThermostat
File "plugin.py", line 419, in _handleChangeSetpointAction
<type 'exceptions.KeyError'>: ('cooltemp',)
2016-04-22 10:00:07 ColorTouch Thermostat sending "Thermostat Kitchen" change cool setpoint to 25.0
2016-04-22 10:00:07 ColorTouch Thermostat Error Error in plugin execution ExecuteAction:
Traceback (most recent call last):
File "plugin.py", line 1204, in actionControlThermostat
File "plugin.py", line 419, in _handleChangeSetpointAction
<type 'exceptions.KeyError'>: ('cooltemp',)
2016-04-22 10:00:07 ColorTouch Thermostat sending "Thermostat Kitchen" change cool setpoint to 25.0
>>> t = indigo.devices[1431507005] # "Thermostat Kitchen"
>>> print t.states
States : (dict)
ctAlertAirFilter : off (on/off bool)
ctAlertService : off (on/off bool)
ctAlertUVLamp : off (on/off bool)
ctAlertsUpdated : 2016-04-22 09:58:16 (string)
ctLastUpdate : 2016-04-22 10:08:01 (string)
ctLastUpdate.ui : 04/22/16, 10:08 AM (string)
ctRuntimes : [{"cool1": 0, "cool2": 0, "ts": "2016-04-15 00:00:00", "fc": 0, "heat2": 0, "heat1": 0, "aux2": 0, "aux1": 0}, {"cool1": 0, "cool2": 0, "ts": "2016-04-16 00:00:00", "fc": 0, "heat2": 0, "heat1": 0, "aux2": 0, "aux1": 0}, {"cool1": 0, "cool2": 0, "ts": "2016-04-17 00:00:00", "fc": 0, "heat2": 0, "heat1": 0, "aux2": 0, "aux1": 0}, {"cool1": 0, "cool2": 0, "ts": "2016-04-18 00:00:00", "fc": 0, "heat2": 0, "heat1": 0, "aux2": 0, "aux1": 0}, {"cool1": 47, "cool2": 0, "ts": "2016-04-19 00:00:00", "fc": 0, "heat2": 0, "heat1": 0, "aux2": 0, "aux1": 0}, {"cool1": 5, "cool2": 0, "ts": "2016-04-20 00:00:00", "fc": 0, "heat2": 0, "heat1": 0, "aux2": 0, "aux1": 0}, {"cool1": 50, "cool2": 0, "ts": "2016-04-20 18:58:34", "fc": 0, "heat2": 0, "heat1": 0, "aux2": 0, "aux1": 0}] (string)
ctRuntimesUpdated : 2016-04-20 18:58:35 (string)
ctScheduleFolders : (string)
ctScheduleMode : 0 (integer)
ctScheduleModeDescription : None (Off) (string)
ctSensors : [{"name": "Thermostat", "temp": 24.0}, {"name": "Outdoor", "temp": -39.0}] (string)
ctSensorsUpdated : 2016-04-20 18:58:35 (string)
ct_availablemodes : 0 (integer)
ct_away : off (on/off bool)
ct_cooltempmax : 37 (real)
ct_cooltempmin : 1.5 (real)
ct_dehum_setpoint : 0 (integer)
ct_heattempmax : 37 (real)
ct_heattempmin : 1.5 (real)
ct_hum_setpoint : 0 (integer)
ct_name : Kitchen (string)
ct_schedule : off (on/off bool)
ct_schedulepart : 255 (integer)
ct_schedulepart.ui : Inactive (string)
ct_setpointdelta : 2 (real)
ct_spacetemp : 23.5 (real)
ct_state : 0 (integer)
ct_tempunits : 1 (integer)
hvacCoolerIsOn : off (on/off bool)
hvacDehumidifierIsOn : off (on/off bool)
hvacFanIsOn : off (on/off bool)
hvacFanMode : 0 (integer)
hvacFanModeIsAlwaysOn : false (bool)
hvacFanModeIsAuto : true (bool)
hvacHeaterIsOn : off (on/off bool)
hvacHumidifierIsOn : off (on/off bool)
hvacOperationMode : 3 (integer)
hvacOperationModeIsAuto : true (bool)
hvacOperationModeIsCool : false (bool)
hvacOperationModeIsHeat : false (bool)
hvacOperationModeIsOff : false (bool)
hvacOperationModeIsProgramAuto : false (bool)
hvacOperationModeIsProgramCool : false (bool)
hvacOperationModeIsProgramHeat : false (bool)
setpointCool : 36 (real)
setpointHeat : 14 (real)
temperatureInput1 : 23.5 (real)
temperatureInputsAll : 23.5 (string)
>>>
jshields wrote:
In any case If I enable your plugin I get all those Python errors and nothing works on the Indigo side for the thermostat. I suppose it might be a difference in the firmware in the thermostat itself since mine has the wifi built in rather than external so it may respond differently, even though I think it shouldn't be that case.
jshields wrote:
Is it possible that the python in 10.10.5 is different from what you are running? Also, this is a Mac OS Server, so I suppose that could be part of the difference.
I'm not a python person so I'm not the best to debug that level of thing.
jshields wrote:
Is there any other information I can gather for you?
jshields wrote:
Could you make a debug version of your plugin with some logging so we can see exactly where things are working vs failing?
http://192.168.1.95/
{"api_ver":5,"type":"residential"}
http://192.168.1.95/query/info
{"name":"Original","mode":1,"state":0,"fan":0,"fanstate":0,"tempunits":0,"schedule":0,"schedulepart":255,"away":0,"spacetemp":72.0,"heattemp":70.0,"cooltemp":79.0,"cooltempmin":35.0,"cooltempmax":99.0,"heattempmin":35.00,"heattempmax":99.0,"hum":0,"hum_setpoint":27,"dehum_setpoint":25,"hum_active":77,"setpointdelta":3.0,"availablemodes":0}
http://192.168.1.95/query/sensors
{"sensors":[{"name":"Thermostat","temp":72.0,"hum":27},{"name":"Remote","temp":0.0}]}
http://192.168.1.95/query/alerts
{"alerts":[{"name":"Air Filter","active":false},{"name":"UV Lamp","active":false},{"name":"Service","active":false}]}
http://192.168.1.95/query/runtimes
Received INSTEON "Utility Room Door Lock Sensor" on (button 1)
Phidget Event Utility Room / Garage Door opened.
Received INSTEON "Utility Room Door Lock Sensor" off (button 1)
Phidget Event Utility Room / Garage Door closed.
akimball wrote:
By the way, I do love your mod... my 2-cents. -al
-- the "watched" folder into which the Alert text files are created by a script on the Indigo Server, triggering the Launch Agent to run this script
set sourceFolder to ((path to documents folder) as text) & "Wunderground Alert Files:"
-- the destination folder where the converted PNG fill will be saved
set destFolder to ((path to library folder) as text) & "Application Support:Perceptive Automation:Indigo 6:IndigoWebServer:images:"
-- temporary folder in which to save the intermediate PDF
set tempFolder to (path to temporary items folder) as text
-- get a list of Alert Text files to be converted
set theseItems to {}
try
set theseItems to paragraphs of (do shell script "ls " & (tEsc(sourceFolder) & "*.txt"))
end try
-- iterate through he list
repeat with textFile in theseItems
try
-- get the name of this text file; we'll use it as the name of the output PNG file as well
set textFileQuotedPath to the quoted form of textFile
set fileName to do shell script ("basename " & textFileQuotedPath & " '.txt'")
-- save the intermediate PDF file to a temporary folder
set thePDFFile to tempFolder & "temp.pdf"
set pdfFileQuotedPath to the quoted form of the POSIX path of thePDFFile
--set the font size and line spacing
set fScale to 1
set fh to 8.5
set fh to fh * fScale
set fw to 8
set fw to fw * fScale
set ls to 3.0
--set the page margins; set the left margin so that when the Image Events crops the image from the center, the text fills the image
set lm to 140
set rm to 5
set tm to 5
set bm to 5
--set the page orientation
--set po to "r" -- landscape
set po to "R" -- portrait
-- convert the text file to a PDF
set theCommand to "cat " & textFileQuotedPath & " | enscript -fMonaco" & fw & "/" & fh & " -" & po & "lqs" & ls & " --non-printable-format=space --margins=" & lm & ":" & rm & ":" & tm & ":" & bm & " -o - | pstopdf -i -o " & pdfFileQuotedPath
set shellResult to do shell script theCommand
-- delete the text file from the "watched" folder
do shell script "rm " & textFileQuotedPath
-- convert the PDF to a png and crop it so that it will fill the designated space on the Control Page
set hCrop to 0.4
-- update the Indigo variable used to display the "Refresh" button and the "Refreshing…" message on the Alerts Control Page(s)
tell application "IndigoServer" to set the value of variable "w_alertsActive" to "2"
set the thePNGFile to destFolder & fileName & ".png"
set the theJPGFile to tempFolder & fileName & ".jpg"
tell application "Image Events"
-- start the Image Events application
launch
-- open the PDF file
set this_image to open thePDFFile
-- get dimensions of the image
copy dimensions of this_image to {W, H}
-- crop it
crop this_image to dimensions {W - (W * hCrop), H}
-- save it as a JPG to ensure the image has an opaque white background
save this_image as JPEG in theJPGFile with icon
-- close it
close this_image
-- open the JPEG file
set this_image to open theJPGFile
-- save it as a PNG (the Refreshing Image URL item on the control page will point to this file)
save this_image as PNG in thePNGFile with icon
-- close it
close this_image
end tell
on error errMsg number errNum
set fullErrMsg to errMsg & " [" & (errNum as text) & "]."
end try
end repeat
-- delete any invisible files (prevents this script from being invoked unnecessarily -- launchd will invoke this script repeatedly as long as there are ANY files in the folder, including hidden files)
try
set theCommand to "rm -f " & tEsc(sourceFolder) & ".*"
set ignoreThis to do shell script theCommand
end try
on tEsc(inputString)
-- Terminal Escape; return a path string that is "escaped" for use Terminal.app
-- Useful for creating path strings to which glob characters can be appended for use with 'do shell script'
set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ""}
try
set inputString to the POSIX path of inputString
--the list of characters to be escaped; the backslash character must be first
--this list was compiled via LIMITED trial and error; may need to be updated.
set charsToEscape to "\\ ~`!#$%&*()=<>,;'{}[]|" & quote
set theString to inputString as string
repeat with theChar in charsToEscape
if theString contains theChar then
--replace every occurence of the character with the escaped version
set AppleScript's text item delimiters to theChar
set theList to every text item of theString
set AppleScript's text item delimiters to "\\" & theChar
set theString to theList as text
end if
end repeat
end try
set AppleScript's text item delimiters to TID
return theString
end tEsc