Background ...
What I am trying to accomplish involves using the Indigo app on my iPhone or iPad to set a START DATE and END DATE for a Heating and Air Conditioning schedule on the upper floor of my home, when I know I have someone staying upstairs. Adding the START TIME AND END TIME are options as well.
So I have created a control page where I can select TODAY and using a python script insert today's date into a variable named START_DATE. I then have a "+DAY" and "-DAY" to be able to increase the date by one day (or decrease if I hit the +DAY one too many times).
I am having issues trying to figure out how to "read" the variable START_DATE, convert it back to a date that python can then increment by 1 day.
To set variable to TODAY is use ...
- Code: Select all
from datetime import date
indigo.variable.updateValue(1193981403, date.today().strftime("%Y-%m-%d"))
To increment the date by 1 day ... this is what I would want to do - using the timedelta function.
I am assuming the reason it fails is because the variable is a string and not a date value.
- Code: Select all
from datetime import timedelta
target_date = (indigo.variables[1193981403].value)
target_date = target_date + timedelta(days=1)
indigo.variable.updateValue(1193981403, value=str(target_date))
I have searched various websites trying to find a way to convert a string to a date.
Any ideas?
Thanks!