This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

How to get access to "time" in the "then" part of a flow

I am trying to get homey say the time at the end of a flow and do not seem to be able to see how to do that. 

Very simple I start a flow with saying "goodmorning" and I want homey to come back with "Goodmorning the time is 'time'" 

I know there is a buildin command to get the time, but is there a way to get access to the buildin time variable in a flow? It seems you get only access to the "time" variable if you use the 'watch' flow element as the initiator of the flow but that is not what I want.

Thanks for any help
«1

Comments

  • edited April 2016
    I've almost got that working, so I'll give you what I have and maybe you can finish the puzzle :)

    Flow 1:
    When: Date & Time card, every 1 minute
    Then: Set a variable "time"  <time token from D&T card in the When column>

    Flow 2:
    When: You said something, "Good morning"
    Then: Say something, "Good morning, the time is {{$time}}"

    Here I got a long string of numbers incrementing by one, maybe we shouldn't call the variable "time", so try a different name. But I'm sure it's something along the lines of the above two flows. Have fun!
  • I managed to do this for the temperature but that's an easy number:
    https://forum.athom.com/discussion/comment/18949/#Comment_18949
    But time isn't an integer so don't know if that works?

  • edited April 2016
    Ah, I know why it doesn't work, if the time is 12:20, the colon makes Homey interpret the value as an array of numbers, ranging from 12 to 20 (so 12,13,14,15,16,17,18,19,20) and will read those out.

    So we have to get rid of the colon somehow :)

    Edit: almost there, if you put this: "The time is {{$Time[0]}}" it reads out the time, followed by a 0.

    I would have expected it to read out the first member of the array (so the hour), but no.
  • Fixed! Sometimes it's so simple: "The time is {{$Time[]}}"

    So square bracket open, square bracket close after $Time. That reads out the correct time.
  • With me it say's:
    "de tijd is dollar time komma"
    What am i doin wrong?
  • Could you paste the contents of the Say something card here?
  • De tijd is {{$Time[]}}
  • edited April 2016
    Did you create a separate flow that fills the Time variable? See Flow 1 in the second post in this thread.
  • Yep, same as u stated there.
    Maybe something goes wrong with creating the variable. While creating the variable all my varaible's was gone!
    So made a new variable. First created a number variable but that did not get the time stamp right. It got 14 instead of 14:22. Then i made a string variable .
  • It's *not* a Better Logic variable! Those cannot be referenced as {{$variable}} :)

    Use the built in Logic card in Flow 1.
  • RocodamelsheRocodamelshe Member
    edited April 2016
    That easy aye?
    Cheers m8!
    It still says the komma btw
  • So now it says the correct time, but with "komma" at the end?

    Check Flow 1 where you fill the Time variable and make sure it doesn't have a comma at the end.
  • RocodamelsheRocodamelshe Member
    edited April 2016
    No comma in the txt.
    It now say's: "de tijd is nul negen komma"
    Now is say's: "de tijd is vijftien uur komma"
    And now: "de tijd is vijftien uur dertien komma"
  • Strange - in Flow 1, could you also copy the Time token to a Better Logic string variable? That way you can take a look at the content of that variable and see if there's a comma in there.

    It could also be a localization issue - my Homey is set to English.
  • Time in Better logic string variable is correct, not showing a comma.
    My Homey is set to dutch, maybe that's an issue. Gonna try it in english setup.
  • The weird thing is that I'm sure the comma symbol isn't something Homey would pronounce even if it was there. Odd.
  • RocodamelsheRocodamelshe Member
    edited April 2016
    In english setup no comma!
    Weird.

    <edit> When set back to dutch the komma is back.
  • Open up a Github issue! Still, partial high-five for half fixing it though :)
  • RocodamelsheRocodamelshe Member
    edited April 2016
    Yeah, +1!
    And not goin to open a ticket for it, they have better things to do atm me guess.
  • Martijn and others, thanks for the suggestions, great help!
  • I have been looking for this as well. Some global variables for time, day of the week, outside temperature etc. would be nice to have.

  • If I add a comma right after the variable (no square brackets) {{$detijd,}} Homey tells me the right time without a comma.
  • RocodamelsheRocodamelshe Member
    edited April 2016
    HansieNL said:
    If I add a comma right after the variable (no square brackets) {{$detijd,}} Homey tells me the right time without a comma.
    Ow, have to check on that!

    <<edit>> That works, cheers!
  • Thanks @HansieNL! No idea why it works, but it does :)

    Things like temperature, wind and hourly forecasts you can get from wunderground.com (go there and get a free API key) and then query with a HTTP flow chart (install https://apps.athom.com/app/com.internet).

    Here's an example on how to get the current temperature:

    Flow 1:
    When: Every Hour
    Then:
    Get Variable Step 1:
    Box 1: http://api.wunderground.com/api/<your key>/conditions/q/<your location>.json
    Box 2: {}
    Box 3: $.current_observation.temp_c
    Box 4: updateTemp

    Flow 2:
    When: Get Variable Step 2 , updateTemp
    Then: Logic <yourTempVariable> <value token from Get Variable Step 2 in the When column>

    You can then use {{$yourTempVariable}} to use the current temperature at your location.

    To see all the other weather based information you can get, have a look at https://www.wunderground.com/weather/api/d/docs?d=index.



  • HansieNL said:
    If I add a comma right after the variable (no square brackets) {{$detijd,}} Homey tells me the right time without a comma.
    Ow, have to check on that!

    <<edit>> That works, cheers!
    In Dutch too?

  • HansieNL said:
    If I add a comma right after the variable (no square brackets) {{$detijd,}} Homey tells me the right time without a comma.
    Ow, have to check on that!

    <<edit>> That works, cheers!
    In Dutch too?
    Yep, I'm running Dutch version. Haven't tried English version.
  • Excellent, thanks.
  • Thanks @HansieNL! No idea why it works, but it does :)

    Things like temperature, wind and hourly forecasts you can get from wunderground.com (go there and get a free API key) and then query with a HTTP flow chart (install https://apps.athom.com/app/com.internet).

    Here's an example on how to get the current temperature:

    Flow 1:
    When: Every Hour
    Then:
    Get Variable Step 1:
    Box 1: http://api.wunderground.com/api/<your key>/conditions/q/<your location>.json
    Box 2: {}
    Box 3: $.current_observation.temp_c
    Box 4: updateTemp

    Flow 2:
    When: Get Variable Step 2 , updateTemp
    Then: Logic <yourTempVariable> <value token from Get Variable Step 2 in the When column>

    You can then use {{$yourTempVariable}} to use the current temperature at your location.

    To see all the other weather based information you can get, have a look at https://www.wunderground.com/weather/api/d/docs?d=index.


    Would love to get that flow, but installing things on homey ATM... 
    Can you post a screenshot of the flow(s) ?

  • Sure:
    Flow 1


    Flow 2

    My Flow 1 gets three components (weather forecast, temperature and what the temperature feels like), so your flow may have a different number of items in the Then column :)

    From any other flow, you can use {{$varYouUsedInFlow2ThenColumn}} to access the value of the variable you populated in Flow 2 (homeyTemperature in my example).
  • Very nice!
    Gonna install that when my Homey is back online.
Sign In or Register to comment.