Shortened Sunrise/Sunset Time?

Posted on
Sat Aug 08, 2020 9:41 am
sumocomputers offline
Posts: 267
Joined: Jun 23, 2008

Shortened Sunrise/Sunset Time?

Using the Astronomy device, I wanted to display Sunrise/Sunset Time on a Control Page, and currently it shows something like:

2020-08-08 07:42 PM

I really only need 7:42 PM, or even just 7:42, as in our area, Sunrise is assumed AM, Sunset PM.

I looked at FW Plugin configuration options, and couldn't find a way to do it easily, though I did see the 12 hour option without AM/PM.

I guess I could write these to a variable, and somehow strip off the leading date & leading zero, but was wondering if there is another way I am missing, or perhaps this might be a feature request?

Thanks,

Chris

Posted on
Sat Aug 08, 2020 10:29 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Shortened Sunrise/Sunset Time?

Hi Chris - I've uploaded v1.0.02 of the plugin which includes two new states sunRiseShort and sunSetShort. Hopefully, those will work for you.

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Aug 08, 2020 10:50 am
sumocomputers offline
Posts: 267
Joined: Jun 23, 2008

Re: Shortened Sunrise/Sunset Time?

It works awesome, thank you.

I still need to figure out a way to strip off the leading zero from time (on FW as well as the generic Indigo time that I use as a clock).

I think there was a thread on how to do this with a simple Python script, but for the life of me, I cannot find it.

Posted on
Sat Aug 08, 2020 11:48 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Shortened Sunrise/Sunset Time?

It depends on what you're working with. In this instance, the plugin value is a string (and if you're working with an Indigo variable, that's a string as well).

A very simple example of stripping the leading zero from a string is:

Code: Select all
t = [string source of value]
new_t = t.lstrip('0')

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Aug 08, 2020 1:07 pm
sumocomputers offline
Posts: 267
Joined: Jun 23, 2008

Re: Shortened Sunrise/Sunset Time?

So I think this script should work to strip the 0 from the Sunrise/Sunset values and write it to a variable (I borrowed some of it from an existing working script, so I'm sure there is a cleaner way).

But how do I find the correct states name for Sunrise Short or Sunrise Long?

Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-

t = (indigo.devices[663603508].states['sunrise_time_short'])  #FW Astronomy Device
new_t = t.lstrip('0')
indigo.variable.updateValue(555900233, format(new_t)) #New Stripped Sunrise Variable

Posted on
Sat Aug 08, 2020 2:06 pm
sumocomputers offline
Posts: 267
Joined: Jun 23, 2008

Re: Shortened Sunrise/Sunset Time?

I dug into the code on Git and found them. This ended up working in case anyone else (or my future self when I forget) finds it:

Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-

t = (indigo.devices[663603508].states['sunriseTimeShort'])  #FW Astronomy Device
new_t = t.lstrip('0')
indigo.variable.updateValue(555900233, format(new_t)) #New Stripped Sunrise Variable


Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-

t = (indigo.devices[663603508].states['sunsetTimeShort'])  #FW Astronomy Device
new_t = t.lstrip('0')
indigo.variable.updateValue(489151405, format(new_t)) #New Stripped Sunset Variable

Posted on
Thu Aug 13, 2020 6:02 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Shortened Sunrise/Sunset Time?

Depending if astronomy sunrise/set is different to normal, the Clock Display plugin supports sunrise/set and may help you tidy this up?


Sent from my iPhone using Tapatalk Pro

Posted on
Mon Aug 17, 2020 10:10 am
sumocomputers offline
Posts: 267
Joined: Jun 23, 2008

Re: Shortened Sunrise/Sunset Time?

howartp wrote:
Depending if astronomy sunrise/set is different to normal, the Clock Display plugin supports sunrise/set and may help you tidy this up?

Sent from my iPhone using Tapatalk Pro


Even though I have everything working, I will check out the Clock plugin!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest