New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation for the rule and action to get thing status. #463
Conversation
Hey @kceiw, thanks for both additions. Could you please break down your text to one sentence per line. Also please be aware, that Kramdown demands empty lines around block elements. You need to add empty lines on front of your example code fences. @kaikreuzer could you also take a look? |
addons/actions.md
Outdated
@@ -95,6 +95,26 @@ The Timer object supports the following methods: | |||
* `hasTerminated`: returns true if the code has run and completed | |||
* `reschedule(AbstractInstant instant)`: reschedules the timer to execute at the new time. If the Timer has terminated this method does nothing. | |||
|
|||
### Thing Status Action | |||
|
|||
`getThingStatusInfo(String thingUid)`: Gets ThingStatusInfo of the given thing identified by thingUid and returns the result as ThingStatusInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explaining getThingStatusInfo
with "Gets ThingStatusInfo" doesn't do much good 😃 I caught myself looking at the example below to understand what this section is all about. Maybe you could condense this sentence and the following paragraph.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that we usually write thingUID
.
addons/actions.md
Outdated
} else { | ||
logError("ThingStatus", "The thing isn't online.") | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice comprehendible example. Did you want to say "isn't online" instead of "is offline"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I intend to say "isn't online". It can be "offline" or "not in the system".
configuration/rules-dsl.md
Outdated
``` | ||
|
||
The ThingUid is the identifier assigned by OpenHAB to the thing you add. You can find it from | ||
PaperUI. For example, one of my z-wave device is assigned "zwave:device:c5155aa4:node14". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*openHAB
You can find it from PaperUI.
This sentence is a bit vague. You can also get it by looking at the Karaf remote console.
one of my z-wave device is assigned
There is no "I" in documentation. 😜
configuration/rules-dsl.md
Outdated
PaperUI. For example, one of my z-wave device is assigned "zwave:device:c5155aa4:node14". | ||
|
||
> Note: You need to use quote around ThingUid. The parser will not recognize the whole text | ||
> correctly without quotes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply show it in the syntax listing then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify it. It's not necessary if thingUID doesn't contain ':'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But a thingUID always contains ':'...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true that a thingUID always contains ':' right now. I would rather view that as an implementation detail which is subject to change. So I changed the note in a way that it doesn't need to be changed even if thingUID schema is changed. I believe that hardly happens. It doesn't hurt to put such a note, I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can assure you that Thing UIDs will contain colons for at least the next 30 years ;-)
configuration/rules-dsl.md
Outdated
> correctly without quotes. | ||
|
||
The status used in the trigger and the script is a string (no quotes). You can find all the | ||
possible values from [Thing Status]({{base}}/concepts/things.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reference should additionally be found in the first sentence of this section.
addons/actions.md
Outdated
@@ -95,6 +95,26 @@ The Timer object supports the following methods: | |||
* `hasTerminated`: returns true if the code has run and completed | |||
* `reschedule(AbstractInstant instant)`: reschedules the timer to execute at the new time. If the Timer has terminated this method does nothing. | |||
|
|||
### Thing Status Action | |||
|
|||
`getThingStatusInfo(String thingUid)`: Gets ThingStatusInfo of the given thing identified by thingUid and returns the result as ThingStatusInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that we usually write thingUID
.
configuration/rules-dsl.md
Outdated
You can listen on status updates or on status changes (an update might leave the status unchanged). | ||
You can decide whether you want to catch only a specific status or any. | ||
Here is the syntax for all these cases (parts in square brackets are optional): | ||
```java |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add an empty line above the code section
configuration/rules-dsl.md
Outdated
You can decide whether you want to catch only a specific status or any. | ||
Here is the syntax for all these cases (parts in square brackets are optional): | ||
```java | ||
Thing <ThingUid> received update [<status>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to thingUID
, similar to above.
configuration/rules-dsl.md
Outdated
PaperUI. For example, one of my z-wave device is assigned "zwave:device:c5155aa4:node14". | ||
|
||
> Note: You need to use quote around ThingUid. The parser will not recognize the whole text | ||
> correctly without quotes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks for the feedback. I'll improve my pull request. |
I update the pull request. Please review this again. Let me know if I still miss anything. |
addons/actions.md
Outdated
@@ -95,6 +95,29 @@ The Timer object supports the following methods: | |||
* `hasTerminated`: returns true if the code has run and completed | |||
* `reschedule(AbstractInstant instant)`: reschedules the timer to execute at the new time. If the Timer has terminated this method does nothing. | |||
|
|||
### Thing Status Action | |||
|
|||
`getThingStatusInfo(String thingUID)`: Gets status information of the given thing identified by thingUID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"thingUID
."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @kceiw, thanks for the improvements. Sorry for the slight delay ( 🌤 🏖 🏄 ), I got another set of comments for you :)
addons/actions.md
Outdated
|
||
`getThingStatusInfo(String thingUID)`: Gets status information of the given thing identified by thingUID | ||
|
||
The result is of type ThingStatusInfo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer the word in code fences or as a link as well.
addons/actions.md
Outdated
For example: | ||
|
||
```java | ||
var statusInfo = getThingStatusInfo("zwave:device:c5155aa4:node2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the example above you referred to this variable as as "thingStatusInfo".
configuration/rules-dsl.md
Outdated
@@ -178,6 +179,27 @@ then | |||
end | |||
``` | |||
|
|||
### Thing Triggers | |||
|
|||
You can listen on status updates or on status changes (an update might leave the status unchanged). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"listen for" or "trigger on"
configuration/rules-dsl.md
Outdated
For example, one z-wave device can be "zwave:device:c5155aa4:node14". | ||
|
||
> Note: You need to use quote around thingUID if it contains special characters such as ':'. | ||
> The parser will not recognize the whole text correctly without quotes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaikreuzer makes sense for things defined via config files, my things do not have : in their name and would naturally work without quotes.
configuration/rules-dsl.md
Outdated
And refer to [Thing Status Action]({{base}}/addons/actions.html) to find how to get thing status in the script. | ||
In the trigger, thingUID is the identifier assigned by openHAB to the thing you add. | ||
You can find it from PaperUI or from Karaf remote console. | ||
For example, one z-wave device can be "zwave:device:c5155aa4:node14". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last three sentences are only interesting of the user had these things autodiscovered. Could you make them their own paragraph and begin with "The thingUID
is the identifier assigned to the Thing, manually in your configuration or automatically during auto discovery...."?
Thanks @ThomDietrich. I updated the pull request according to your new comments. |
Wonderful. Thanks for the addition! One last thing I've missed so far: You need to sign off your PR please: https://github.com/openhab/openhab-docs/blob/gh-pages/CONTRIBUTING.md#sign-your-work |
Hey @kceiw, to clarify: Normally you need to sing-off every commit but as an exception it's acceptable to sign-off in the PR description. Please do so and we are ready to merge. |
The change of the code is at eclipse-archived/smarthome#3001 After this commit, the end user can find the documentation about how to react to thing status change in the rule. Bug: openhab#517 Signed-off-by: Maoliang Huang <hellomao@outlook.com> Incorporate more pull request feedback.
Hi @ThomDietrich |
Hey @kceiw I've resolved the conflict and we are ready to go. Thanks for your contribution! |
I enabled to listen to thing status in the rule and also add a new action to get thing status in the script, in this pull request: eclipse-archived/smarthome#3001
This pull request is to add the documentation.