I'd be very grateful for some python code assist for the issues below:
1) - I used the code below for AS date calculations. Is this necessary for date calculations with Python?
set dt to do shell script "/bin/date \"+%A, %b %d at %H:%M\""
set theHour to (do shell script "date +%H") --as integer
set theMinute to (do shell script "date +%M") --as integer
2) Boolean logic:
if VarA or VarB then
and
if VarA and VarB then
3) Below are lines to calculate time for populating a ad hoc time/date action (e.g., >60 min adds an hour, >24 hrs adds a day),. Maybe this isn't necessary for Python?
--calculate time to dim lights:
set dimMin to theMinute + onTym
set dimHour to theHour
if dimMin ≥ 60 then
set dimMin to dimMin - 60
set dimHour to dimHour + 1
if dimHour > 23 then
set dimHour to dimHour - 24
end if
end if
set dimTime to dimHour & ":" & dimMin & ":" & offSec as string
log dimTime using type "fYrdLts dimTime"
--calculate time to turn lights off:
set offMin to theMinute + onTym + dimTym
set offHour to theHour
if offMin ≥ 60 then
set offMin to offMin - 60
set offHour to offHour + 1
if offHour > 23 then
set offHour to offHour - 24
end if
end if
set offTime to offHour & ":" & offMin & ":" & offSec as string
log "offTime" & offTime using type "fYrdLts offTime"
--enable and populate schedule items
***But I would like to know how to create an ad hoc time/date action, replacing the AS code below:
set the time trigger type of time date action "fYrdLtsDIM" to absolute
set the date trigger type of time date action "fYrdLtsDIM" to everyDay
set the absolute trigger time of time date action "fYrdLtsDIM" to date dimTime
4) More Boolean logic:
if ("16:00:00" > offTime or offTime ≥ "22:00:00") then
Thank you in advance for any assistance.
Bob