Allow use of date/time attribute for trigger

Missing from HE is the ability to set a trigger based on a date/time attribute. I'm forced to write my attribute to a Hub Variable - which forces it to exist prior to my app. a deal breaker for creating a useful app that could be shared.


in the image 'variable time' only shows pre-existing Hub Global variables. this means my app has to be hard coded - or a rule that is foced to copy my variables to a pre-existing Hub variable since we're not allowed to create a global variable from within an app.

Please explain what you're trying to accomplish. Time based triggers/events are used/available in many apps including RM.

5 Likes

Sorry for the delay - haven't been at the desk for a few days.
@thebearmay - in response - I know help usefulness is directly related to quality of question - so let me elaborate better.
I wrote an app that pulls Sunrise / Sunset data from Sunrisesunset.org with the help of @csteele. the tool works perfectly and pulls additional values besides the SR and SS data. it pulls Twilights.
I store all the values that come back from this pull into attributes and also store them into states.
I run conversion on the strings coming in to put the type of Twilight (there are actually 3 kinds returned and I have a choice option for the user) and stuff the user choice into an attribute as Epoch formed date/time. I can store it in any form, but I read somewhere it was supposed to be epoch. Here are my attributes:
image

I want to use the variable twilight begins before SR to start outdoor lights. I want to use the variable Twilight ends after SS to enable outdoor lights.
Then the hurdle showed up. I tried to created a rule to pull date/time from my attributes and couldn't. I asked for help and got some not helpful answers.
I ended up having to make pre-existing Global Hub variables and hard coding my app to write my variables into them.

I was forced to do this since you can't dynamically create hub global variables per the documentation.
The Trigger events in rule options allows to select Variables - but only shows Hub variables.
image
For my app to be useful to anyone else, the limitation of being forced to use hub variables in this case is a deal breaker. If HE allowed date/time variables to be used from an app as it implies, I'd be golden. The title 'Select DateTime Variable*' is actually mistitled, imho - it should say 'Select 'DateTime Global Variable *'. HE plays loose and fast with their descriptions in this and other locations code wise - variables that are GHV are not the same as user/app vars in rules etc. but this is not on my wants/wish list. Just the ability to not be tied to pre-existing GHV.

Might be a crappy work around but I have an idea. Could you have the app create a child device (virtual switch) under the main device for each category, so create a "CivilTwilight" device. Then when that period starts have the app turn the switch on, and turn the switch off when it ends. You could use that to trigger rules and also to check the state within rules.

it's a workaround for sure... I wouldn't call it crappy but it's fits 'not elegant' I think :slight_smile:

Just for historic purpose - this all began because I wanted to push values to Grafana so I could create a daily graph of CT Temp and Brightness of circadian bulbs I am using. I wanted to add plots of the twilight times and learned that Grafana doesn't accept date/time values via influx feed.
As my graph evolved and began being useful, I pushed the date time values of twilight into numeric attributes, then sucked them into influx and parsed them on the other side. Worked very well! (thanks @csteele).

Once that started working I realized I had a useful 'pre' and 'post' value for SR and SS variables. So I could have outdoor lights function as I desired as well. Hence the evolution of this - and now the disenchantment when HE came up short.

What do you mean you can't use an attribute for a trigger??

please feel free to snap shot your successful method and I'll quickly implement.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.