{"action":"created","issue":{"url":"https://api.github.com/repos/athombv/homey/issues/1647","repository_url":"https://api.github.com/repos/athombv/homey","labels_url":"https://api.github.com/repos/athombv/homey/issues/1647/labels{/name}","comments_url":"https://api.github.com/repos/athombv/homey/issues/1647/comments","events_url":"https://api.github.com/repos/athombv/homey/issues/1647/events","html_url":"https://github.com/athombv/homey/issues/1647","id":237278129,"number":1647,"title":"Trigger flow based on condition change","user":{"login":"RobertMe","id":1102763,"avatar_url":"https://avatars0.githubusercontent.com/u/1102763?v=3","gravatar_id":"","url":"https://api.github.com/users/RobertMe","html_url":"https://github.com/RobertMe","followers_url":"https://api.github.com/users/RobertMe/followers","following_url":"https://api.github.com/users/RobertMe/following{/other_user}","gists_url":"https://api.github.com/users/RobertMe/gists{/gist_id}","starred_url":"https://api.github.com/users/RobertMe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RobertMe/subscriptions","organizations_url":"https://api.github.com/users/RobertMe/orgs","repos_url":"https://api.github.com/users/RobertMe/repos","events_url":"https://api.github.com/users/RobertMe/events{/privacy}","received_events_url":"https://api.github.com/users/RobertMe/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-06-20T16:54:07Z","updated_at":"2017-07-04T16:15:34Z","closed_at":"2017-07-03T19:31:20Z","body":"**What is your Homey version (Settings → System)?**\r\n\r\n1.3.1\r\n\r\n**What did you try to achieve?**\r\n\r\n*Please include detailed steps how we can reproduce the issue*\r\n\r\nCreating complex flows based on multiple conditions. Like \"When the sun is down, and the lux is below X, then turn on the lights\" (optionally with \"else turn them off\")\r\n\r\n**What was the result?**\r\n\r\nI had two create two flows. One being triggered when the sun goes down, with the condition for lux below X, and another based on the lux change, and the lux being below X, and the sun being down. Which means having to duplicate the logic which is cumbersome when you have to change for example the lux threshold.\r\n\r\n**What did you expect as result?**\r\n\r\nOnly having one flow.\r\n\r\n**Any other remarks**\r\n\r\nI've been brainstorming about an idea where you have a trigger \"The condition has changed\" which will then monitor all the condition/\"and\" cards, and when the end result changes (so true becoming false or the other way around) the then/else actions could be executed. Automatically evaluating conditions could then for example be based on the changes of the tags which are used as droptoken (on for example logic cards) or by changes in capabilities (as (almost) every condition card also has a trigger to detect the change in condition, and almost all of these conditions/triggers are backed by capabilities).\r\n\r\nI understand this could lead to performance issues when having a lot of flows using this trigger, and possibly having multiple cards in them every time. But this could mostly be prevented by only monitoring the condition cards which where actually tested the first run. So when having three condition cards, these would be tested in order. So when the first card already is \"false\" this means only a \"monitor\" for the first card is needed (and when the first card is true, and the second is false, both need to be monitort etc). This because the other cards don't matter, as long as a previous card was false the end result will still be false (unless \"or\" is introduced, but then the same rule applies, only the tested cards need to be monitored).\r\nPerformance could be further improved by only retesting all conditions when the \"changed\" card actually changed. So for example when having a logic card which states \"lux < 20\" and first the lux is 30 (which evaluates to false) and then there is a lux change to for example 25 the card needs to be retested, but as the result is still false the other cards on the flow don't need to be retested because the outcome of this card, and thus flow, wouldn't have changed."},"comment":{"url":"https://api.github.com/repos/athombv/homey/issues/comments/312913428","html_url":"https://github.com/athombv/homey/issues/1647#issuecomment-312913428","issue_url":"https://api.github.com/repos/athombv/homey/issues/1647","id":312913428,"user":{"login":"RobertMe","id":1102763,"avatar_url":"https://avatars0.githubusercontent.com/u/1102763?v=3","gravatar_id":"","url":"https://api.github.com/users/RobertMe","html_url":"https://github.com/RobertMe","followers_url":"https://api.github.com/users/RobertMe/followers","following_url":"https://api.github.com/users/RobertMe/following{/other_user}","gists_url":"https://api.github.com/users/RobertMe/gists{/gist_id}","starred_url":"https://api.github.com/users/RobertMe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RobertMe/subscriptions","organizations_url":"https://api.github.com/users/RobertMe/orgs","repos_url":"https://api.github.com/users/RobertMe/repos","events_url":"https://api.github.com/users/RobertMe/events{/privacy}","received_events_url":"https://api.github.com/users/RobertMe/received_events","type":"User","site_admin":false},"created_at":"2017-07-04T16:15:34Z","updated_at":"2017-07-04T16:15:34Z","body":"\"This flow is activated\" also isn't time dependent. That's also why I stated that I would make this a \"special\" flow for which there is a trigger, \"condition has changed\", just like the flow activation cards. I didn't say that the triggers as a whole should be removed.\r\n\r\nAnd time dependent conditions could of course also re-evaluate the condition as a whole when the time changes. As in the end there is no difference when you either have 1 flow:\r\n**If** the condition changed **And** It's between 20:00 and 23:00 and lux is below 30 **Then**...\r\nOr when you have 4 flows:\r\n**If** this flow is activated **And** It's between 20:00 and 23:00 and lux is below 30 **Then** ...\r\n**If** the time is 20:00 **Then** activate flow ...\r\n**If** the time is 23:00 **Then** activate flow ...\r\n**If** the lux changed **Then** activate flow ..."}}
{"actor":{"display_login":"RobertMe"}}