Current Time, Sunrise and Sunset Information on Control Page
-
- Posts: 29
- Joined: Fri Apr 26, 2019 1:12 pm
- Location: Massachusetts
Current Time, Sunrise and Sunset Information on Control Page
Hello,
Is there a way to get the Current Time, Sunrise and Sunset information shown in the Indigo Client (lower right corner) to display in a Control Page?
If there is a way I have not been able to find it or figure it out.
Thanks.
Is there a way to get the Current Time, Sunrise and Sunset information shown in the Indigo Client (lower right corner) to display in a Control Page?
If there is a way I have not been able to find it or figure it out.
Thanks.
- FlyingDiver
- Posts: 7305
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: Current Time, Sunrise and Sunset Information on Control
You would need to run a script on a schedule (every second?) to put those values in variables that you can display in the control page. The formatting is up to you. See https://pythonexamples.org/python-datetime-format/
Indigo makes available the calculated sunrise/sunset values for your specified location. See https://wiki.indigodomo.com/doku.php?id ... r_commands. Use the formatting tools from the first link.
Indigo makes available the calculated sunrise/sunset values for your specified location. See https://wiki.indigodomo.com/doku.php?id ... r_commands. Use the formatting tools from the first link.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: Current Time, Sunrise and Sunset Information on Control
This is exactly what I do. I have a Python script called Routine Variable Operations that I run once per minute. Not everything in the script is updated every minute, but my time variables are. (Some of the variables below are not for Control Pages).
I came here to drink milk and kick ass....and I've just finished my milk.
[My Plugins] - [My Forums]
[My Plugins] - [My Forums]
-
- Posts: 29
- Joined: Fri Apr 26, 2019 1:12 pm
- Location: Massachusetts
Re: Current Time, Sunrise and Sunset Information on Control
Thanks.
I have a learning curve ahead of me. I am going to have to learn Python. I guess getting 3 date-time values from the Indigo server and putting them in variables is as good a place to start as any.
First things first, I will look for an on-line Python tutorial. Does anyone have a good or preferred tutorial site where I can learn this, new to me, scripting language?
As Agatha Christie's Poirot would say ..... it will be good for the little grey cells.
I currently running Indigo , 2023.1.1, on a late 2014 Mac mini, running macOS Monterey, version 127.1. Any issues running in this environment? I am planning to get a new mac Mini in the new year.
Thank you.
I have a learning curve ahead of me. I am going to have to learn Python. I guess getting 3 date-time values from the Indigo server and putting them in variables is as good a place to start as any.
First things first, I will look for an on-line Python tutorial. Does anyone have a good or preferred tutorial site where I can learn this, new to me, scripting language?
As Agatha Christie's Poirot would say ..... it will be good for the little grey cells.
I currently running Indigo , 2023.1.1, on a late 2014 Mac mini, running macOS Monterey, version 127.1. Any issues running in this environment? I am planning to get a new mac Mini in the new year.
Thank you.
Re: Current Time, Sunrise and Sunset Information on Control
Look on YouTube for a cat named Net Ninja. He's the best in the business IMO. To whet your appetite,
The long numbers are (fake) variable IDs.
Code: Select all
from datetime import datetime
now = datetime.now()
day = f"{now:%A}"
fancy_date = f"{now:%B %d, %Y}"
fancy_time = f"{now:%I:%M}"
am_pm = f"{now:%p}"
indigo.variable.updateValue(12345676, day)
indigo.variable.updateValue(12345677, fancy_date)
indigo.variable.updateValue(12345678, fancy_time)
indigo.variable.updateValue(12345679, am_pm)
I came here to drink milk and kick ass....and I've just finished my milk.
[My Plugins] - [My Forums]
[My Plugins] - [My Forums]
Re: Current Time, Sunrise and Sunset Information on Control
I came here to drink milk and kick ass....and I've just finished my milk.
[My Plugins] - [My Forums]
[My Plugins] - [My Forums]
Re: Current Time, Sunrise and Sunset Information on Control
And there is a slightly different way to manage the time. There is a Clock Display plugin for Indigo. You create a Device, and it basically does the rest. You can put the data form your clock Device on a page easily enough, but it doesn't do the seconds perfectly, just due to the what the plugin is written I guess.
But if having the exact second isn't such a big deal, check out the Clock Display plugin.
AND it also has sunrise /sunset as well, so you should be all set to gather this date from your clock device and put it in a web page.
I can't say its as accurate to the nano-second as the python method would be, but mostly like it'll be good enough...
Don't hesitate to ask if you need help getting this info onto a webpage.
In the plugin settings, you can stipulate how you'd like the Sunrise/Sunset time displayed. This is what I use:
%-I:%M %p, which gives me 6:32 AM and 5:02 PM (at least for today)
You'll also find the attached file very helpful in understanding the codes Python uses for day, date, and time.
But if having the exact second isn't such a big deal, check out the Clock Display plugin.
AND it also has sunrise /sunset as well, so you should be all set to gather this date from your clock device and put it in a web page.
I can't say its as accurate to the nano-second as the python method would be, but mostly like it'll be good enough...
Don't hesitate to ask if you need help getting this info onto a webpage.
In the plugin settings, you can stipulate how you'd like the Sunrise/Sunset time displayed. This is what I use:
%-I:%M %p, which gives me 6:32 AM and 5:02 PM (at least for today)
You'll also find the attached file very helpful in understanding the codes Python uses for day, date, and time.
-
- Posts: 29
- Joined: Fri Apr 26, 2019 1:12 pm
- Location: Massachusetts
Re: Current Time, Sunrise and Sunset Information on Control
Thank you DaveL17, jltnol and FlyingDiver.
The Clock Display plug in has done the trick for the short term. To get up to speed and build something useful in Python will take a while for this 78 yo.
My previous home automation server (used for 20+ years) had if - then - else logic built in. That is the thing I miss the most in Indigo.
If I learn Python I suspect I can add conditional actions in schedules and triggers.
I want to thank each of you for responding to my question.
I'm off and running .... slowly.
The Clock Display plug in has done the trick for the short term. To get up to speed and build something useful in Python will take a while for this 78 yo.
My previous home automation server (used for 20+ years) had if - then - else logic built in. That is the thing I miss the most in Indigo.
If I learn Python I suspect I can add conditional actions in schedules and triggers.
I want to thank each of you for responding to my question.
I'm off and running .... slowly.
Re: Current Time, Sunrise and Sunset Information on Control
I didn't even know about the Clock Display plugin. Glad to hear that works for you.
As far as if - then - else logic, once you get the hang of some simple Python commands, this is very easy to do given how Python integration is baked into Indigo. Say you have a schedule that you only want to run if a certain condition is true ( everything to the right of a "#" is a comment, and ignored by Python).
This code goes into the Condition tab of the schedule, in the lower box that says, "If Python script returns True".
It may seem like a lot at first, but once you get the hang of it, it's really pretty straightforward.
As far as if - then - else logic, once you get the hang of some simple Python commands, this is very easy to do given how Python integration is baked into Indigo. Say you have a schedule that you only want to run if a certain condition is true ( everything to the right of a "#" is a comment, and ignored by Python).
Code: Select all
my_var = indigo.variables[12345678] # this is how you reference an Indigo Variable -- by its ID (or its name, although that's discouraged).
my_test = my_var.value # Get the value of my_var (Indigo variables always contain a text string). Let's say here it's "20".
my_test = int(my_test) # Convert the text string to an integer.
if my_test > 10: # Since 20 > 10, this "if" will be executed
return True # Return the value True
else:
return False # You don't have to do this, but it's nice to be thorough.
It may seem like a lot at first, but once you get the hang of it, it's really pretty straightforward.
I came here to drink milk and kick ass....and I've just finished my milk.
[My Plugins] - [My Forums]
[My Plugins] - [My Forums]
Re: Current Time, Sunrise and Sunset Information on Control
And just to echo Dave's comments on Python, I knew nothing when I started, and still feel like I'm in Python Kindergarten, BUT the folks here, Dave being one of them, have ALWAYS been helpful in helping me solve scripting problems when I get stuck.
My advice is Don't Be Afraid to try some basic ideas in Python.
My advice is Don't Be Afraid to try some basic ideas in Python.
Re: Current Time, Sunrise and Sunset Information on Control
When I came over to Indigo, I didn't even know Python existed. But I knew Lua existed and I wanted no part of that.
I came here to drink milk and kick ass....and I've just finished my milk.
[My Plugins] - [My Forums]
[My Plugins] - [My Forums]
Re: Current Time, Sunrise and Sunset Information on Control
Incidentally, I just stumbled across another free option for Python learning.
Harvard University has placed their Introduction to Programming with Python course on Open Courseware (tuition free).
Harvard University has placed their Introduction to Programming with Python course on Open Courseware (tuition free).
I came here to drink milk and kick ass....and I've just finished my milk.
[My Plugins] - [My Forums]
[My Plugins] - [My Forums]
-
- Posts: 29
- Joined: Fri Apr 26, 2019 1:12 pm
- Location: Massachusetts
Re: Current Time, Sunrise and Sunset Information on Control
Thank you DaveL17.
Harvard is about a half hour away from my home. This is definitely on to do list in the New Year.
Thanks again.
Harvard is about a half hour away from my home. This is definitely on to do list in the New Year.
Thanks again.
Re: Current Time, Sunrise and Sunset Information on Control
You're welcome. I hope you find it useful.
I came here to drink milk and kick ass....and I've just finished my milk.
[My Plugins] - [My Forums]
[My Plugins] - [My Forums]