I have fussed around with the following, but have been unable to log any values obtained.
- Code: Select all
indigo.server.getTime()
indigo.server.getTime().time()
indigo.server.log("time{}".format(time))
Note - I haven't defined a variable for time.
indigo.server.getTime()
indigo.server.getTime().time()
indigo.server.log("time{}".format(time))
t = indigo.server.getTime()
indigo.server.log(u"{0}".format(t))
>>> 2019-10-11 06:42:52.688000
t = indigo.server.getTime()
indigo.server.log(u"{0}".format(type(t)))
>>> <type 'datetime.datetime'>
SMUSEBY wrote:Is it possible to get the current time - hours or hours&min for use in a conditional test? - e.g. if current time is >1630 and < 2200, then...
I have fussed around with the following, but have been unable to log any values obtained.
devLuxBath = indigo.devices[1450400961] # "Bathroom Fibaro Luminance Sensor"
devDiningLight = indigo.devices[1519699078] # "Dining Room Light"
now = indigo.server.getTime()
time_07 = now.replace(hour= 7, minute=00, second=0, microsecond=0)
time_23 = now.replace(hour=23, minute=00, second=0, microsecond=0)
if not devDiningLight.onState:
if (time_07 <= now <= time_23):
x = 100
else:
x = 10
if devLuxBath.sensorValue < 45:
indigo.dimmer.setBrightness(devDiningLight,value=x)
now = indigo.server.getTime()
time_1630 = now.replace(hour=16, minute=30, second=0, microsecond=0)
time_2200 = now.replace(hour=22, minute=00, second=0, microsecond=0)
if (time_1630 <= now <= time_2200):
#your code for time between 16:30 and 22:00
else:
#code not between times above
now = indigo.server.getTime()
theBody = "On %now, the house was vacant, and the front door was opened" % (now.value)
#
now = indigo.server.getTime()
theBody = "On {}, the house was vacant, and the front door was opened".format(now)
#
now = indigo.server.getTime()
theAddress = indigo.variables[236514828].getValue #email address
var1 = indigo.variable.create("theSubject", "Front Door Opened")
indigo.server.sendEmailTo(theAddress, subject=theSubject, body="some text")
newVar = indigo.variable.create("fooMonster", "default value")
indigo.variable.updateValue(newVar, "asleep")
indigo.server.log(u"{0}".format(newVar))
indigo.server.log(u"{0}".format(type(newVar)))
indigo.server.log(u"{0}".format(dir(newVar)))
now = indigo.server.getTime()
varA = indigo.variables[236514828] #email address
theAddress = "%s" % (varA.name)
indigo.server.sendEmailTo(address=theAddress, subject = "BRK House-front door opened", body = "some text")
now = indigo.server.getTime()
varA = indigo.variables[236514828] #email address
indigo.server.sendEmailTo(varA.value, subject="BRK House-front door opened", body="some text")
And what is the nature of the '%s' thing? - it's a line specific variable?
var = 2
indigo.server.log(u"The value of the number is: %s" % var)
var = 2
indigo.server.log(u"The {0} of the number is: {1}".format("value", var))
now = indigo.server.getTime()
varA = indigo.variables[236514828] #email address
hseVcnt = indigo.variables[1176596514].getValue(bool)
theBody = "The house is vacant, and the front door was opened at %s" % (now.value)
theBody2 = "The house is vacant, and the front door was opened at {}" .format(now.value)
indigo.server.sendEmailTo(varA.value, subject = "BRK House-front door opened", body = "some text")
import datetime
now = indigo.server.getTime()
now_formatted = datetime.datetime.strftime(now, "%H:%M")
import datetime
now = indigo.server.getTime()
now_formatted = datetime.datetime.strftime(now, "%H:%M")
varA = indigo.variables[180461382] #email address
hseVcnt = indigo.variables[1176596514].getValue(bool)
# theBody = "The house is vacant, and the front door was opened at %s" % (now.value)
# theBody = "The house is vacant, and the front door was opened at {}" .format("value", now_formatted))
# theBody = "The house is vacant, and the front door was opened at {}" .format("value", now))
theBody = "some text"
# if hseVcnt
indigo.server.sendEmailTo(varA.value, subject = "BRK House-front door opened", body = theBody)
Users browsing this forum: No registered users and 7 guests