Provide access to Thing status in textual (DSL) rules #1654
Comments
Hi @kaikreuzer . Can you point me how to start? I would like to implement it in spare time. I look at the document https://www.eclipse.org/smarthome/documentation. But still I am not sure how to do. |
Hi @kceiw Unfortunately, this isn't too trivial - you should have some understanding of Xtext/Xtend/Xbase. FTR, this is the place where item names are made available and resolvable within scripts/rules: And the classes in https://github.com/eclipse/smarthome/tree/master/bundles/model/org.eclipse.smarthome.model.script/src/org/eclipse/smarthome/model/script/scoping bring implicit java package imports, command and state types and the action methods. Somewhere along these places the Things would need to be added. We probably should first discuss the syntax of what we want to achieve. Probably, adding an action could be the simplest solution in the end, although I think we would also want a new rule trigger type. |
Thanks @kaikreuzer . I'm not quite understand about "the Things need to be added". My understanding is that the status is an attribute of the Thing. Why do we need to add Things?
It seems more like a condition than an action. Do you mean that setting state DEAD is an action in the rule system, and that'll trigger whatever in between then and end to be executed? Please correct me if I misunderstand. |
Hi @kaikreuzer,
That's what I think what needs to be done to have a rule run when Thing goes OFFLINE. Please let me know if I am missing anything. |
We're going to expose thing status to rule. This is the first step toward the goal. The rule engine needs to subscribe to the event. Bug: eclipse-archived#1654 Signed-off-by: Maoliang Huang <hellomao@outlook.com>
The syntax is "Thing <thingUid> changed [from <oldState>] [to <newState>]" Bug: eclipse-archived#1654 Signed-off-by: Maoliang Huang <hellomao@outlook.com>
Similar to how ItemRegistry is exposedin RulesJvmModelInferrer, ThingRegistry is exposed in RulesJvmModelInferrer.xtend Bug: eclipse-archived#1654 Signed-off-by: Maoliang Huang <hellomao@outlook.com>
RulesThingsRefresher acts like RulesItemRefresher. It listens to things changes (added/removed) and schedules to reload the rules. Bug: eclipse-archived#1654 Signed-off-by: Maoliang Huang <hellomao@outlook.com>
Bug: eclipse-archived#1654 Signed-off-by: Maoliang Huang <hellomao@outlook.com>
Convert the thing status from online to Online which is used in the rule. Other thing status are converted to Offline. The rule engine also supports the rule with trigger thing state change. Bug: eclipse-archived#1654 Signed-off-by: Maoliang Huang <hellomao@outlook.com>
Add the syntax 'Thing' <thingUid> 'received update' in the syntax file. This is similar to item status update. Handle the thing status event and execute thing update rule in rule engine. Bug: eclipse-archived#1654 Signed-off-by: Maoliang Huang <hellomao@outlook.com>
The rule is changed to take thingUid as a string instead of an ID. And we don't use the type Thing internally to pass the information in the rule. This is done so because when the thing is removed, it can occur before the rule is checked and executed. When it occurs, we cannot get the Thing from thingUid. Fix an issue in storing thing related rules and retrieve them. Bug: eclipse-archived#1654 Signed-off-by: Maoliang Huang <hellomao@outlook.com>
- Use a pre-defined list as the thing status. the list is the same as ThingStatus. Bug: eclipse-archived#1654 Signed-off-by: kceiw <hellomao@outlook.com>
- The thing uid contains ':' which cannot be used as an identifier. So we cannot use something like "ThingType:Thing" in the script and interpreset it as a thing. So we need to create an action to accept the thing uid and return its status. - This is to allow the user to create more restrains using ThingStatusInfo in the script. Bug: eclipse-archived#1654 Signed-off-by: kceiw <hellomao@outlook.com>
Bug: eclipse-archived#1654 Signed-off-by: kceiw <hellomao@outlook.com>
Bug: eclipse-archived#1654 Signed-off-by: kceiw <hellomao@outlook.com>
Bug: eclipse-archived#1654 Signed-off-by: kceiw <hellomao@outlook.com>
Bug: eclipse-archived#1654 Signed-off-by: kceiw <hellomao@outlook.com>
Bug: eclipse-archived#1654 Signed-off-by: kceiw <hellomao@outlook.com>
Bug: eclipse-archived#1654 Signed-off-by: kceiw <hellomao@outlook.com>
Bug: #1654 Signed-off-by: kceiw <hellomao@outlook.com>
As far as I can see, #3001 added trigger and and an action service to access the thing status at any location. So to me it looks like this issue was resolved, or did I miss anything? |
It is resolved indeed, thanks.
Simon Kaufmann <notifications@github.com> schrieb am Fr., 30. Juni 2017,
21:14:
… As far as I can see, #3001
<#3001> added trigger and and an
action service to access the thing status at any location. So to me it
looks like this issue was resolved, or did I miss anything?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1654 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB7K977iInSGRTIucKbOriSl0aEGMvc3ks5sJUkFgaJpZM4IzwP8>
.
|
The only part that is missing is to add it to the documentation. |
In rules it is often desirable to access the status of a Thing - currently, this information is not yet available.
We should add a function to access this information within the (old) Xtext DSL rules.
The text was updated successfully, but these errors were encountered: