PatrickSannes / BetterLogic

A advanced logic library for homey
9 stars 8 forks source link

Feature Request - convert date time to epoch value #4

Closed daneedk closed 7 years ago

daneedk commented 7 years ago

Would it be possible to creat an action card that takes the date and time tags from another card and calculates the epoch value from it and saves it as an numeric value? and would it be possible to also make a condition card that evaluates the current date time to a variable holding an epoch value?

I mean like this: Set a epoch value: betterlogic

Compare the current date time against an earlier stored (and possibly adjusted) epoch value: betterlogicand1 or betterlogicand2

Why do I ask this? Well, when I add 84600 to the value set at sunset I (almost) have the epoch value for half an our before sunset the next day.

PatrickSannes commented 7 years ago

This is already possible with the mathjs cards. In there there is a special variable for the time now (epoch in seconds)

Would that be sufficient?

Groet

On 2 Dec 2016 15:45, "daneedk" notifications@github.com wrote:

Would it be possible to creat an action card that takes the date and time tags from another card and calculates the epoch value from it and saves it as an numeric value? and would it be possible to also make a condition card that evaluates the current date time to a variable holding an epoch value?

I mean like this: Set a epoch value: [image: betterlogic] https://cloud.githubusercontent.com/assets/16610696/20836970/269e14d4-b8a2-11e6-9436-6a15d911aa9c.png

Compare the current date time against an earlier stored (and possibly adjusted) epoch value: [image: betterlogicand1] https://cloud.githubusercontent.com/assets/16610696/20837303/cdc9e99e-b8a3-11e6-9f2a-64be6eb0ab29.png or [image: betterlogicand2] https://cloud.githubusercontent.com/assets/16610696/20837308/d11bfb32-b8a3-11e6-8441-4c266f5b6796.png

Why do I ask this? Well, when I add 84600 to the value set at sunset I (almost) have the epoch value for half an our before sunset the next day.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PatrickSannes/BetterLogic/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/ABxbDU03mrsCnj_aR1RU6V8-43glZQgTks5rEC7qgaJpZM4LCnzP .

daneedk commented 7 years ago

Thanks, I read the readme again and found it, I'll try it and let you know if this works for my purpose. Thanks!

PatrickSannes commented 7 years ago

Create set card in mathjs (timenow takes amount of seconds sinse epoch)

[image: Inline image 1]

Then you can create any action card to trigger. Can't put mathjs in here, but with a countdowntimer you can do something or with any other trigger. Then in the when you can say:

[image: Inline image 2]

Hope it helps!

On Sun, Dec 4, 2016 at 9:21 AM, daneedk notifications@github.com wrote:

Thanks, I've had a quick look but can't find what you mean. Can you explain, maybe with a screenshot, how to use it?

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PatrickSannes/BetterLogic/issues/4#issuecomment-264690793, or mute the thread https://github.com/notifications/unsubscribe-auth/ABxbDZKbN-6gvJQIicGfbx6Cacmgs29kks5rEnftgaJpZM4LCnzP .

daneedk commented 7 years ago

Thanks, I have it working now, this is how I did it:

At sunset a flow saves the current date and time + 1 day into the epoSunsetTemp variable:

...then betterlogic set eposunsettemp

In a flow that runs five minutes after midnight the epoSunsetTemp is saved into the epoSunset variable

...then betterlogic set eposunsettemp

In another flow, which triggers when someone comes home, I check the current date and time against the epoSunset -1800 and when it's true I turn on some hue scenes.

...and... betterlogic evaluate timenow

These flows enables me to use an offset from sunset in a reliable way

Thanks again for this great app!!!

(Btw, the images in your post don't show up)