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.

[APP] Better logic / Variable management

1356725

Comments

  • On git I published the version without the bug. Also the BitFlip device is implemented.... If anyone wants to test, please let me know what you think
  • Do you think a future release may have time based variable managment,  i.e to set a trigger 15 minutes into the future?
  • AndyWilde said:
    Do you think a future release may have time based variable managment,  i.e to set a trigger 15 minutes into the future?
    Action cards already do have a delay trigger.


    This can only be achieved by action cards, not by API calls. If you need this functionality via api what you could do (after the next release)

    Create a variable MyExternalTrigger
    create a variable MyDelayedTrigger

    Create flow
    If MyExternalTrigger is changed => change value of MyDelayedTrigger with a delay

    Then create a second flow
    If MyDelayedTrigger is changed => Perform desired action


  • oops,  forgot about the little timer there,  I was trying to over complicate it
  • UrandayUranday Member
    edited March 2016
    Here are the release notes of the next version. Currently it is in test, ill hope to submit it to the appstore this weekend:

    V0.1.0
    BREAKING CHANGE: Due to renaming bool values to boolean all variables and cards need to be re-added.
    Bugfix: Dropdown was not working for boolean values in the .
    Feature: Added BitFlip device to switch a boolean value from the device and phone app.
    Feature: Added API support to GET or SET (post) a value.
        PUT: HTTP://HOMEYADDRES/api/app/net.i-dev.betterlogic/VARIABLENAME/VALUE  //Please ensure that the value matches the type, otherwise it will not be set.
    Feature: Add date time last changed to settings screen with format (YYYY-MM-DD HH-MM-SS)
    Feature: Implement insights. (note that bool and string values are not displayed yet in the module)

    Please come with suggestions for the next release. I want to implement AND and OR cards for the condition, but ill have to wait until dropdown multiselects are available.

    For those who are eager, it is available on github.
  • new trigger for number variable when difference abs(old - newval) >, <, == X see https://athomcommunity.slack.com/archives/general/p1456950484000842

    Also ability to be able to listen to "any variable" change trigger from other app. In that case upper idea could be new app, acting as an extension for your great better logic app. Not sure if that's even possible currently? Push from app to app? @Emile ;?
  • MatjaLipu said:
    new trigger for number variable when difference abs(old - newval) >, <, == X see https://athomcommunity.slack.com/archives/general/p1456950484000842

    Also ability to be able to listen to "any variable" change trigger from other app. In that case upper idea could be new app, acting as an extension for your great better logic app. Not sure if that's even possible currently? Push from app to app? @Emile ;?
    The trigger I can look into, should not be to hard.

    What I could make is an api that creates a variable. So your app has to call the URL of the api of my app and create the variable. This means though that everyone should install my app if they want to use yours. I think then it would be wise if we prefix this variables with SYSTEM_APPID_MyFirstVar.
    With this idea you could:
    - Create a trigger on a system variable change
    - Create logic on the variable

    An other feature I could make is an URL callback event on variable change. So whenever a variable changes, it calls an external URL..?
  • Broader idea is we could be able to create extension apps and communicate in realtime(push) between them.

    Example:
    new app with trigger when some number variable from your app, difference is [greater/lower/equal] than X.

    You can implement api.js to get variables list(for autocomplete), get variable value etc.
    Prefix is not necessary. Let user define variables in your app and make autocomplete in new app (using your api).
    We could do webhooks (URL callback), but this is coupling. With events parent app does not need to know about anyone who is listening.

    The main issue I see how to notify new app variable was changed. We want push here, not poll. So .realtime() from app to new app.

    Ideally your app would announce variable change

    Homey.trigger('variableChange', {
      name: 'counter',
      prev: 2,
      value: 3
    })

    new app would simply subscribe to this event
    Homey.app('net.i-dev.betterlogic').on('variableChange', function(args) {...})
  • Submitted version 0.1.0 with the following features:

    * BREAKING CHANGE: Due to renaming bool values to boolean all variables and cards need to be re-added.
    * Bugfix: Dropdown was not working for boolean values in the .
    * Feature: Added BitFlip device to switch a boolean value from the device and phone app.
    * Feature: Added API support to GET, GET all variables and SET (post) a value.
        * PUT: HTTP://HOMEYADDRES/api/app/net.i-dev.betterlogic/VARIABLENAME/VALUE  //Please ensure that the value matches the type, otherwise it will not be set.
    * Feature: Add date time last changed to settings screen with format (YYYY-MM-DD HH-MM-SS)
    * Feature: Implement insights. (note that bool and string values are not displayed yet in the module)
    * Feature: Implement card that can set all variables. It converts the type. If the type matches the value is setted
    * Feature: Implement trigger card that triggers on a number change. (minimal difference, minimal increase or minimal decrease)

    If you cant wait, fetch it from git. Please let me know what you think.


  • Uranday said:
    Submitted version 0.1.0 with the following features:

    * Feature: Implement card that can set all variables. It converts the type. If the type matches the value is setted

    Awesome stuff again. Could you explain the feature above or give a sample use case for it. I was unable to find this card and not sure I understand although it sounds quite powerfull ... :grey_question: 
  • I will make a movie soon with a load of features.... 
  • Published! 
  • aloftaloft Member
    edited March 2016
    "Still" not updated on my Homey ... ;-)

    In all seriousness; what is the frequency of app updates on my Homey?  Does the 'update' setting have any impact on updating the apps or is that only for core HomeyOS ?  And is there a way to force update an app? 

    (Edit: a reboot did help updating the app, so that might be one way to force-update an app)
  • aloft said:
    "Still" not updated on my Homey ... ;-)

    In all seriousness; what is the frequency of app updates on my Homey?  Does the 'update' setting have any impact on updating the apps or is that only for core HomeyOS ?  And is there a way to force update an app? 

    (Edit: a reboot did help updating the app, so that might be one way to force-update an app)

    I have no clue... Maybe ask in an other topic?
  • Quick word of huge thanks - I've just replaced all built-in logic cards with the BetterLogic ones and it works very very well. My personal favorites:

    - the settings page shows you the full list of variables, their current value and the time and date of their last change
    - when using cards in a flow, you can simply pick the variables from a picklist, no need to remember them, no chance of typos
    - boolean flip saves a lot of work!

    Even when you only use a few variables in your flow, this app is well worth it!

    Tip: create triggers and actions in separate flows, that greatly reduces the amount of flows you'll end up with, as explained in https://forum.athom.com/discussion/comment/13123
  • Quick question on the Text Contains card - what is the meaning of the little red cross in the top left hand corner?

    I have a variable called "Local_Time_Setting" that contains a time and date stamp (2016-03-07T17:30:27+00:00) and I want something to happen when the local time becomes 17:30. So a flow runs a check every minute to see if the current time (hh:mm) matches the time stamp in the variable.

    Like this ("time" is the token from the date and time card):



    I'm assuming the little red cross, which only shows up when I hit the test button, does not mean "all is well" :)
  • The chance that it is exactly that time is slim to none..therefor it can not check. 
  • Oh, I thought "contains" would check to see if the variable (with string value "2016-03-07T17:30:27+00:00") would contain the string "17:30". That would be true once a day :)

    To be sure, I wrote the output of the Time token to another variable, and it is just "hh:mm". 
  • It checks if the string assigned to the variable contains the value in the input. 
  • Strange - just ran the test again, the little red x doesn't appear anymore! Seems to work now  :)
  • @Uranday You already have "text contains" condition flow card, but could you add a "text starts with" condition flow card as well?

    In combination with for instance the iCalendar to Voice App that would enable some powerful scheduling. It would help us to create schedules with events that would trigger flows based on their respective summary prefixes.

  • brinkie said:

    @Uranday You already have "text contains" condition flow card, but could you add a "text starts with" condition flow card as well?

    In combination with for instance the iCalendar to Voice App that would enable some powerful scheduling. It would help us to create schedules with events that would trigger flows based on their respective summary prefixes.


    Can do. Will put it in the next release. 

    Patrick 

  • Uranday said:
    brinkie said:

    @Uranday You already have "text contains" condition flow card, but could you add a "text starts with" condition flow card as well?

    In combination with for instance the iCalendar to Voice App that would enable some powerful scheduling. It would help us to create schedules with events that would trigger flows based on their respective summary prefixes.


    Can do. Will put it in the next release. 

    Patrick 

    Cool!
  • Or consider a regexp/wildcards condition card.
  • aloftaloft Member
    Is there a way to convert a string received from a device into a number in BetterLogic? 

    Example: a Fibaro Motion sensor also senses the luminance. It's value card (when luminance change) is a string, although containing only numbers.  A BetterLogic number will not accept the value.

    I'd like to do "greater than" and "less than" comparisons to switch on/off lights based on that.

    The Homey built-in logic seems to be able to do the comparisons, but if it can be done in BetterLogic as well, then I can have all my logic into one place. That's more logic ;-)
  • UrandayUranday Member
    edited March 2016
    At this moment you can't. Have to look into it. What you could do is set a variable first. There is one that accepts all and converts when type matches. 

    But for my understanding, are you looking for ad hoc checks... Output of card against an inputted value in the condition? Droptoken => 3.
     Or do you want to check the output of a card against a variable? So VarA=3 and a condition that says droptoken => VarA
  • aloftaloft Member
    But for my understanding, are you looking for ad hoc checks... Output of card against an inputted value in the condition? Droptoken => 3.
     Or do you want to check the output of a card against a variable? So VarA=3 and a condition that says droptoken => VarA
    Second one; So store the output of a card in a variable ( that's is flowA) . And then in other flows, use that to compare in a condition (e.g. if Lux > 200 lumen and Lux < 500 lumen, turn light on with brightness 50 % ). 
  • aloft said:
    But for my understanding, are you looking for ad hoc checks... Output of card against an inputted value in the condition? Droptoken => 3.
     Or do you want to check the output of a card against a variable? So VarA=3 and a condition that says droptoken => VarA
    Second one; So store the output of a card in a variable ( that's is flowA) . And then in other flows, use that to compare in a condition (e.g. if Lux > 200 lumen and Lux < 500 lumen, turn light on with brightness 50 % ). 

    That's already possible with the set a variable that converts it if possible. 

  • aloftaloft Member
    Uranday said:

    That's already possible with the set a variable that converts it if possible. 

    I am not sure I am understanding you correctly, but I am sure the fault is on my Denglish-side ;-)

    When I add a new variable in BetterLogic, I need to choose  between:

    "String"
    "number"
    "Boolean"

    String is the only variable that accepts the output of the card. But then I cannot compare it with 'greater than' or 'less than' logic from the BetterLogic app, that only works for numbers.

  • Try this one - if you drop a token in it that contains a number-as-a-string, it converts it to a number:



    You can then use that variable in a > or < card.
Sign In or Register to comment.