Funny that I spent a lot of time working with date and times and can't figure it out!
First, a HUGE thank you to @csteele for providing me a massive jump start with his code model on my project! I am overwhelmingly grateful!
I want to add a 'feature' to a driver. I want to have the ability to use todays date as a default but give the ability to enter whatever date might be needed.
Here is a pic of my driver so far. As you can see I have a 'Date' input and I want it to default and prefill to todays date but have the ability to accept any date if entered. :
The code I have that isn't working is:
preferences {
input name: 'usedLatitude', type: 'text', title: 'Latitude', description: 'Override Latitude (default is hub value)', required:false, defaultValue: location.latitude
input name: 'usedLongitude', type: 'text', title: 'Longitude', description: 'Override Longitude (default is hub value)', required:false, defaultValue: location.longitude
input name: 'usedDate', type: 'date', title: 'Date', description: 'Override Date to be calculated (default is today)', required:false, defaultValue: location.getDate
input name: 'usedTimeZone', type: 'text', title: 'Timezone', description: 'Override Timezone (default is hub value)', required:false, defaultValue: location.timeZone.ID
The result is 'Null'. I've tried iterations with today(), now() and getDate but I'm stymied and reading all the Hubitat docs hasn't shown me the way.
For a bonus point if interested - @csteele built a json routine to move inbound data to attributes. One attribute comes as an integer. I want to store it as 'hh:mm' but having trouble parsing. I've had to make a second api call to get the one value and its poor code. Is there an easy way to format that escapes me?
here's that called localDayLength formatted as I want (but requires a second API call)-
and my hack code is:
but I want it like @csteele s work: