Time and Date on Control Page

Posted on
Sun Dec 24, 2017 11:07 am
farberm offline
Posts: 393
Joined: Feb 24, 2008

Time and Date on Control Page

Can someone tell me what everyone is using to Display the Date and Time on the Control page.

Python script or something else.
If using a python script can someone provide an example

Thanks in advance

Posted on
Sun Dec 24, 2017 12:19 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Time and Date on Control Page

You can create variables for what you want to see and place them on your control pages - fill them by running the python code below. I run this just after midnight for things that change once a day. For time I use the built in Indigo function to update a clock variable (that is run once a min. -- second photo)

This is an example from one of my schedules

Code: Select all
from datetime import date
indigo.variable.updateValue(972215514, date.today().strftime("%A"))  # substitute the ID of the variable that will hold the weekday
indigo.variable.updateValue(1274472235, date.today().strftime("%b"))  # substitute the ID of the variable that will hold the MonthShort
indigo.variable.updateValue(102740303, date.today().strftime("%B"))  # substitute the ID of the variable that will hold the Month
indigo.variable.updateValue(825743399, date.today().strftime("%d"))  # substitute the ID of the variable that will hold the Day
indigo.variable.updateValue(130393313, date.today().strftime("%Y"))  # substitute the ID of the variable that will hold the year
indigo.variable.updateValue(1578531574, date.today().strftime("%y"))  # substitute the ID of the variable that will hold the Year2Digit


You can sub in what ever format specifier you want from the list here

http://strftime.org/

PS. The format specifier are the bits in the red circle below.... Have fun and happy holidays
Attachments
2017-12-24_10-00-54.jpeg
2017-12-24_10-00-54.jpeg (88.67 KiB) Viewed 1596 times
2017-12-24_10-15-47.jpeg
2017-12-24_10-15-47.jpeg (106.07 KiB) Viewed 1596 times

_______
Norm

Posted on
Sun Dec 24, 2017 1:19 pm
farberm offline
Posts: 393
Joined: Feb 24, 2008

Re: Time and Date on Control Page

I am a little new at this but I am going to make the following assumptions:

you created the following variable and they have the following variable numbers (listed in the variable window)
weekday - 972215514
MonthShort - 1274472235
Month - 102740303
Day - 825743399
year - 13093313
Year2Digit - 1578531574

Create s script that runs the python script you included but change the variable numbers to the ones I have and run it once a day at midnight

Posted on
Sun Dec 24, 2017 1:45 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Time and Date on Control Page

Yes - but your numbers will be different. Grab your numbers by right clicking on the variable name and copy ID

I sent you some files in native format - working through all of this does take some time but it is do-able :D

_______
Norm

Posted on
Sun Dec 24, 2017 4:22 pm
mclass offline
Posts: 312
Joined: May 13, 2015
Location: Melbourne, Australia

Re: Time and Date on Control Page

Hi,

Having (very) limited Python abilities, I have adopted an alternative approach:

    - Create two action groups DateUpdate and TimeUpdate
    - Each Action Group executes a Variable Action "Insert Timestamp into Variable" and inserts a formatted timestamp into variables : "TimeNow" and "DateNow"
    Screen Shot 1.png
    Screen Shot 1.png (57.41 KiB) Viewed 1542 times

    - "DateNow" is formatted (by the Action Group) by the string "%A %d %B %Y"
    - "TimeNow" is formatted by the the string "%I:%M %p"
    Screen Shot2.png
    Screen Shot2.png (38.08 KiB) Viewed 1542 times

    - Each of the Action Groups are executed by schedules (time every minute, date at 12:01am every day)
    - Time and date variables are inserted to control page

<<EDIT>>
Forgot to add that I also added a trigger so that the time and date actions are executed on Indigo server startup to ensure the time and date variables are updated.

You could use a single action group and schedule that updated both at once (every minute) if you prefer. Hope that helps.

mclass

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest