Need Help Creating A Variable Containing Just The Time Portion Of Sunset and Sunrise Variables

Hello everyone,

I am close but just can't seem to figure out how to store the a hub variable or a local app variable to contain just the time portion of the sunset & sunrise variables. See the rule below.

The set statement for the rule local variable does set just the time as desired [1st highlight]; however, the value stored in the local variable [AppVariableSunRise & AppVariableSunSet] contain both the date and time. I suspect this is because of the Value format that is define is my problem. If anyone can help me fix my issue I would appreciate it. I have looked through the threads for several hours and this one is eluding me [as always though while looking through the threads though I learn a lot more :-)].

My goal is to only have to have the sunrise and sunset times announced. It is obvious it is for the same day.

I am also writing the values to a file. This is the first time I have written to a file. Is there a way to append to the file and to write the file to a NAS vs. locally to the Hub? Being honest here. I have not researched this one yet. I am just adding this in here since I am already writing this question. Therefor it is fair to make me do my research and not answer.
Honestly being lazy here on this one question. :frowning:

As always, appreciate any help and guidance. Hope everyone has a great weekend!

I just use the hub information driver which can be found in HPM.

It has an attribute for sunrise and sunset time.

My rule to update sunrise and sunset times is shown below. It has only the time, no date.

There is an 'erase date' action in 'set variable when setting a date/time variable. I tested and it seems to work.

I set v1 to current date/time, then ran that action:

The log shows the notification was sent as:

Message:[sunset is 09:00], was sent to Alan

3 Likes

I went with Alan_F's suggestion since it only required that I add the addition erase statements just below the existing local variable set statements as he is doing. Worked perfectly.

Thank you both so much for your help!

  • Don
1 Like

I did not know about the erase date thing, never noticed it. Good to know,

Same here!