Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » New Modular Rule Concept  () 1 Vote
Re: New Modular Rule Concept [message #1697753 is a reply to message #1697359] Mon, 08 June 2015 07:50 Go to previous messageGo to next message
Dennis Nobel is currently offline Dennis NobelFriend
Messages: 166
Registered: September 2014
Senior Member
Hi Chris,

AFAIK the concepts of persistent variables is not part of the Core Rule Engine. You could do it with a special module handler, that reads and writes variables from a central database.

ButI think there are a lot of uses cases, where variables are an essential part of rules. So maybe we need to think about how to create such rules the best and if should provide some core module handlers for variables.

Regards

Dennis
Re: New Modular Rule Concept [message #1697818 is a reply to message #1697753] Mon, 08 June 2015 15:32 Go to previous messageGo to next message
Chris Jackson is currently offline Chris JacksonFriend
Messages: 256
Registered: December 2013
Senior Member
I think this it's really a necessity to have variables that can maintain state - otherwise the rule system is really only usable for quite simple functions...

One other request - to add a comment member to the different blocks so that we can add some sort of description to the Json files...

Chris
Re: New Modular Rule Concept [message #1697833 is a reply to message #1697818] Mon, 08 June 2015 18:22 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
I think the question here is mainly about what OSGi services are accessible from within modules. We will have to provide a way to access items and things and so you definitely have the possibility to access "stateful information". We could also think here about a dedicated GlobalRuleVariableService. This is not yet defined, but I think there is no need to change anything in the overall concept for this.

Regarding comments: I actually never noticed that JSON is so poor that it does not even allow embedded comments... So I guess what you are asking for is somthing like "_comment" in http://stackoverflow.com/questions/244777/can-i-comment-a-json-file?answertab=votes#tab-top. This might indeed be a valid request. What do others think?

Regards,
Kai
Re: New Modular Rule Concept [message #1697834 is a reply to message #1697833] Mon, 08 June 2015 18:36 Go to previous messageGo to next message
Chris Jackson is currently offline Chris JacksonFriend
Messages: 256
Registered: December 2013
Senior Member
Hi Kai,
Yes - this sounds ok if we can add such a service for variables - I'd personally prefer to avoid using items for this... No-one has commented on the suggestion of an "initialisation" and "termination" block (or is it module - I need to properly acquaint myself with the terminology Smile).

Regarding comments - yes - basically just adding a
"comment": "This is a comment"
element to the object(s). Even if you could add comments to json files, they would not be transferred through the REST interface - I think this is useful so that they can be displayed in any graphical designer (as in the HABmin Blockly implementation - see the second image in the link)...

Chris
Re: New Modular Rule Concept [message #1697888 is a reply to message #1697834] Tue, 09 June 2015 11:10 Go to previous messageGo to next message
Marin Mitev is currently offline Marin MitevFriend
Messages: 22
Registered: December 2014
Junior Member
Hi Chris,
A comment element could be useful feature, but if you want to display it as a description text, then I think it is already covered by the description element which is already present in each building block: the modules, rules, rule templates and module types. So the tooltip shown in Rule designer can display those description elements, and they can be localizable
Re: New Modular Rule Concept [message #1697890 is a reply to message #1697834] Tue, 09 June 2015 11:18 Go to previous messageGo to next message
Marin Mitev is currently offline Marin MitevFriend
Messages: 22
Registered: December 2014
Junior Member
Chris Jackson wrote on Mon, 08 June 2015 18:36
Hi Kai,
No-one has commented on the suggestion of an "initialisation" and "termination" block ...
...
I'm wondering if there should be an initialisation and termination block definition that ensures that a rule is initialised correctly, and also if it's disabled, it can appropriately close things down. For example, if we had a rule that controlled a heater, we might want to set up some variables when the rule is first run, and then when it's deactivated for some reason, we might want to ensure that the heater is turned off?
Chris


This is interesting use-case, but it is not supported in that way currently. Maybe it could be covered by events generated by the engine when rule is executed or disabled, however this will require a separate rule, which may not be very convenient...
Re: New Modular Rule Concept [message #1697896 is a reply to message #1697890] Tue, 09 June 2015 12:35 Go to previous messageGo to next message
Chris Jackson is currently offline Chris JacksonFriend
Messages: 256
Registered: December 2013
Senior Member
Quote:

... but if you want to display it as a description text, then I think it is already covered by the description element which is already present in each building block: the modules, rules, rule templates and module types. So the tooltip shown in Rule designer can display those description elements, and they can be localizable

Ok - I didn't realize that there was a "description" element in all parts of the definition. I'm not completely sure how/why this is localisable though as the input would be free-form input that is entered by the user when they are 'writing' a rule - not something that is defined by a module provider (sorry if I use the wrong terminology). I just say this as I'm worried we might be talking at cross terms? In the HABmin rule designer that I referenced, the comment boxes have information that is entered by the user to describe the rule they are writing so that they can remember how it works when they look at it 12 months later.


Quote:

This is interesting use-case, but it is not supported in that way currently. Maybe it could be covered by events generated by the engine when rule is executed or disabled, however this will require a separate rule, which may not be very convenient...

Yes, I think this would be inconvenient, and prone to error. My example use case is to control a heater - I have a rule that turns the heater, and a fan, on and off depending on different inputs (temperature, humidity and time). When this rule is disabled, I want to ensure the heater is disabled - I think having to add a separate rule and manage the link could go wrong and I would suggest that this should be added to the todo list (maybe not for the first release, but in the pipeline).
Likewise for the initialization - I think there needs to be some way to initialize a rule - the initialization block seems a clean approach, but maybe there's a better/alternative way...

Thanks.

Cheers
Chris
Re: New Modular Rule Concept [message #1697902 is a reply to message #1697896] Tue, 09 June 2015 13:05 Go to previous messageGo to next message
Marin Mitev is currently offline Marin MitevFriend
Messages: 22
Registered: December 2014
Junior Member
Your observation is correct - localized description will be available only for module types and rule templates, but the description for rule instances and rule modules (triggers, conditions, actions) will be set by the user and won't be localized.

We will consider the blocks for rule initialization/deinitialization
Re: New Modular Rule Concept [message #1697903 is a reply to message #1697902] Tue, 09 June 2015 13:24 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Ok, so the description field of modules / rules is enough then and we won't need a comment in the JSON, right? I before didn't know that your question was about showing stuff in the UI, but rather doing a kind of "developer comment" within JSON files that are packed in bundles.

Quote:
I think there needs to be some way to initialize a rule

Maybe we would also need something like prerequisites, before a rule can become enabled? Checking that some items are available, things are ONLINE etc.? This could be achieved if the initialization could also use a callback to declare when it is ready (as the init might not be a synchronous operation).
Re: New Modular Rule Concept [message #1697915 is a reply to message #1697903] Tue, 09 June 2015 15:10 Go to previous messageGo to next message
Chris Jackson is currently offline Chris JacksonFriend
Messages: 256
Registered: December 2013
Senior Member
Quote:

Ok, so the description field of modules / rules is enough then and we won't need a comment in the JSON, right?


If I understood Marin correctly, the "description" is a description of what the block is and it's defined by the provider (and therefore localized). This provides a 'tooltip' type of thing that helps guide the user by telling them what a particular block does (this is effectively your java doc)

What I would also like to see is to have a user defined entry so that they can write some information to remind them what they have used the block for (this is akin to a source code comment).

If I've got this right, then I think we still need it?

Chris
Re: New Modular Rule Concept [message #1697919 is a reply to message #1697915] Tue, 09 June 2015 15:20 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
No, what Marin says is that rule TEMPLATES and module TYPES have a localized description defined by the provider and that rules and modules themselves have a description that can be defined by the user. So I think this should be alright.
Re: New Modular Rule Concept [message #1697920 is a reply to message #1697919] Tue, 09 June 2015 15:21 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
And anyhow, people writing complex rules for themselves are likely to use some scripting modules - and within scripts, you can of course comment as much as you like Smile
Re: New Modular Rule Concept [message #1697927 is a reply to message #1697920] Tue, 09 June 2015 15:49 Go to previous messageGo to next message
Chris Jackson is currently offline Chris JacksonFriend
Messages: 256
Registered: December 2013
Senior Member
Quote:

No, what Marin says is that rule TEMPLATES and module TYPES have a localized description defined by the provider and that rules and modules themselves have a description that can be defined by the user. So I think this should be alright.

Ok - that's fine...

Quote:

And anyhow, people writing complex rules for themselves are likely to use some scripting modules - and within scripts, you can of course comment as much as you like

Maybe, but I don't think we should require this Smile Comments are always good, and these rules are meant to be 'shareable' so describing the rule so others can understand it is (IMHO) desirable... I've been using a block rule designer for some reasonably complex rules for quite a while, and I'd hate to loose comments...

Chris
Re: New Modular Rule Concept [message #1697988 is a reply to message #1697903] Wed, 10 June 2015 07:16 Go to previous messageGo to next message
Marin Mitev is currently offline Marin MitevFriend
Messages: 22
Registered: December 2014
Junior Member
Kai Kreuzer wrote on Tue, 09 June 2015 13:24

Maybe we would also need something like prerequisites, before a rule can become enabled? Checking that some items are available, things are ONLINE etc.? This could be achieved if the initialization could also use a callback to declare when it is ready (as the init might not be a synchronous operation).

Isn't this a duplication of the Condition block - A Rule won't execute the actions unless the condition is satisfied and inside the condition someone could check the system state or the event data or both
Re: New Modular Rule Concept [message #1698559 is a reply to message #1697988] Tue, 16 June 2015 12:09 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Not really - it would be more a life-cycle feature than an execution feature. It could influence the status of a rule (similar to whether a handler is available or not) and define whether a rule is potentially executable at all. My point is that if we introduce some kind of "initialization", we have to ensure that all pre-requisites are fullfilled for doing the initialization at all. If it wants to set set a certain value for an item as a start, we would e.g. have to make sure that this item exists at all.
Re: New Modular Rule Concept [message #1710940 is a reply to message #1698559] Sun, 11 October 2015 14:00 Go to previous messageGo to next message
Smart Home is currently offline Smart HomeFriend
Messages: 109
Registered: February 2015
Senior Member
Some of the module types requires an item name. E.g.:

"ItemStateChangeTrigger":{
			"label": "Item State Trigger",
			"description": "This triggers a rule if an items state changed",
			"config":{
				"itemName":{
					"type":"TEXT",
					"label":"item name",
					"description":"the name of the item which's state change should be observed",
					"required":true
				}
			},


If I want to create a generic UI for modules which will display all item names for the user to select from, how do I know that the field itemName is for item names?
Re: New Modular Rule Concept [message #1710950 is a reply to message #1710940] Sun, 11 October 2015 18:12 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
I think we should use the "context" field of config descriptions for this purpose - i.e. add a <context>item</context> here.
Re: New Modular Rule Concept [message #1711105 is a reply to message #1710950] Tue, 13 October 2015 06:23 Go to previous messageGo to next message
Smart Home is currently offline Smart HomeFriend
Messages: 109
Registered: February 2015
Senior Member
Quote:
i.e. add a <context>item</context> here


Probably we will need other contexts, e.g., date / time, state etc. Are they going to be predefined?

Other issue that I think should be addressed is how to match between triggers and conditions. How do I know which conditions are valid for a specific trigger? E.g., if there is a condition which checks above and below values probably it cannot be used with item event state trigger (e.g., GenericEventTrigger). Use case can be when user selects trigger and now he needs to select condition, in that case, I would like to show only conditions that are valid for the selected trigger.

Also, do you plan to add above / below triggers / conditions to the automation module core?
Re: New Modular Rule Concept [message #1711375 is a reply to message #1711105] Thu, 15 October 2015 12:08 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Quote:
Probably we will need other contexts, e.g., date / time, state etc. Are they going to be predefined?


Yes, that's the plan.

Quote:
Other issue that I think should be addressed is how to match between triggers and conditions.


Correct. Besides the type (as a very simple check if inputs and outputs can be matched), we plan to use the tags for this purpose, where the tags define the semantics of the input/output. As with contexts, a default set of tags will need to be defined.

Quote:
Also, do you plan to add above / below triggers / conditions to the automation module core?


Possibly yes, but I would want trying to keep the set of "core" modules small. Probably it makes sense to start with a "comparison" condition, which has the comparator (=, <, >, !=, <=, >=) as a configuration option.
Re: New Modular Rule Concept [message #1711424 is a reply to message #1711375] Thu, 15 October 2015 21:02 Go to previous messageGo to next message
Smart Home is currently offline Smart HomeFriend
Messages: 109
Registered: February 2015
Senior Member
Quote:
Probably it makes sense to start with a "comparison" condition, which has the comparator (=, <, >, !=, <=, >=) as a configuration option.


I also suggest to add composite conditions, above, below etc. same as state on / off composite conditions. They are very basic and probably widely used.
Re: New Modular Rule Concept [message #1711441 is a reply to message #1711424] Fri, 16 October 2015 07:08 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Yes, you are probably right. So as a basis implementation the comparison condition would be fine and based on this we can add specialized composite conditions.
Re: New Modular Rule Concept [message #1711622 is a reply to message #1711441] Sun, 18 October 2015 14:10 Go to previous messageGo to next message
Smart Home is currently offline Smart HomeFriend
Messages: 109
Registered: February 2015
Senior Member
Is there a way to run a rule not as a result of a trigger? Something like Check Now in IFTTT.
Re: New Modular Rule Concept [message #1711635 is a reply to message #1711622] Sun, 18 October 2015 20:21 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Not yet, but it is a good point. I guess you mean directly running the list of actions without considering triggers and conditions. The only problem would then be that the trigger outputs are missing; if a rule requires them, what should happen?
Re: New Modular Rule Concept [message #1711666 is a reply to message #1711635] Mon, 19 October 2015 07:38 Go to previous messageGo to next message
Smart Home is currently offline Smart HomeFriend
Messages: 109
Registered: February 2015
Senior Member
I think that somehow you need to check the conditions (if applicable). Take for example the condition: ItemStateCondition.

Check now is actually a trigger without parameters. If the condition requires parameters, check now should probably do nothing and actions should not run.
Re: New Modular Rule Concept [message #1711697 is a reply to message #1711666] Mon, 19 October 2015 11:14 Go to previous messageGo to next message
Dennis Nobel is currently offline Dennis NobelFriend
Messages: 166
Registered: September 2014
Senior Member
It depends if "Check now" includes conditions or really just triggers the action. However in both cases you could just give in the required outputs from other modules manually.
Re: New Modular Rule Concept [message #1711716 is a reply to message #1711697] Mon, 19 October 2015 12:35 Go to previous messageGo to next message
Smart Home is currently offline Smart HomeFriend
Messages: 109
Registered: February 2015
Senior Member
Quote:
It depends if "Check now" includes conditions or really just triggers the action


From my POV, check now is a way to execute the rule. It is not meant to run the action explicitly. E.g., it allows the user to check the rule that he has just created or to run the rule without waiting for the trigger (bypass the trigger).

Quote:
However in both cases you could just give in the required outputs from other modules manually.


If I bypass the trigger I don't have the inputs.
Re: New Modular Rule Concept [message #1712304 is a reply to message #1711716] Thu, 22 October 2015 18:11 Go to previous messageGo to next message
Karel Goderis is currently offline Karel GoderisFriend
Messages: 198
Registered: March 2014
Senior Member
I just want to kick the can a bit further down the road, but is anyone already working on the integration with the userland/space? cfr the initial backward compatibility solution proposed by Kai at the beginning of the thread?
Re: New Modular Rule Concept [message #1712309 is a reply to message #1712304] Thu, 22 October 2015 19:33 Go to previous message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Note that apart from this forum thread, there is a lot of activity on the PR itself here: https://github.com/marinmitev/smarthome/issues
The clear focus is to get the whole framework in a usable state. I have also already spent some thoughts on a migration path of the existing rules, but this is something that I do not plan to finalize for an openHAB 2.0 release. There isn't really any urgency as the current rules work well for anybody who wants to do pure scripting.
Previous Topic:GroupItem Function
Next Topic:Introducing Notifications
Goto Forum:
  


Current Time: Fri Apr 26 06:46:40 GMT 2024

Powered by FUDForum. Page generated in 0.05628 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top