Skip to content
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

Merged
merged 2 commits into from Sep 26, 2017

Conversation

kceiw
Copy link
Contributor

@kceiw kceiw commented Jul 30, 2017

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.

@ThomDietrich
Copy link
Member

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?

@@ -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
Copy link
Member

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.

Copy link
Member

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.

} else {
logError("ThingStatus", "The thing isn't online.")
}
```
Copy link
Member

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"?

Copy link
Contributor Author

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".

```

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".
Copy link
Member

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. 😜

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.
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

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 ':'.

Copy link
Member

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 ':'...

Copy link
Contributor Author

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.

Copy link
Member

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 ;-)

> 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).
Copy link
Member

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.

@@ -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
Copy link
Member

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.

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
Copy link
Member

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

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>]
Copy link
Member

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.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kceiw
Copy link
Contributor Author

kceiw commented Aug 10, 2017

Thanks for the feedback. I'll improve my pull request.

@kceiw
Copy link
Contributor Author

kceiw commented Aug 10, 2017

I update the pull request. Please review this again. Let me know if I still miss anything.
Thanks.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"thingUID."

Copy link
Member

@ThomDietrich ThomDietrich left a 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 :)


`getThingStatusInfo(String thingUID)`: Gets status information of the given thing identified by thingUID

The result is of type ThingStatusInfo.
Copy link
Member

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.

For example:

```java
var statusInfo = getThingStatusInfo("zwave:device:c5155aa4:node2")
Copy link
Member

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".

@@ -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).
Copy link
Member

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"

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.
Copy link
Member

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.

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".
Copy link
Member

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...."?

@kceiw
Copy link
Contributor Author

kceiw commented Aug 26, 2017

Thanks @ThomDietrich. I updated the pull request according to your new comments.

@ThomDietrich
Copy link
Member

ThomDietrich commented Aug 27, 2017

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

@ThomDietrich
Copy link
Member

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.
@kceiw
Copy link
Contributor Author

kceiw commented Sep 26, 2017

Hi @ThomDietrich
I've squashed my commits and addedthe sign-off to it.
At the same time, I created the issue #517 for this pull request and write it to the commit too.

@ThomDietrich
Copy link
Member

Hey @kceiw I've resolved the conflict and we are ready to go. Thanks for your contribution!

@ThomDietrich ThomDietrich merged commit a080441 into openhab:gh-pages Sep 26, 2017
@ThomDietrich
Copy link
Member

GitHub tip: Next time write "Resolves #517" or "Closes #517" in our commit and Github will automatically do that upon merge ;)

@Confectrician Confectrician added this to the 2.x.x milestone Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants