-
-
Notifications
You must be signed in to change notification settings - Fork 708
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
Additional improvements to persistence article #535
Additional improvements to persistence article #535
Conversation
Addressing comments left over from openhab#527 - Changed that -> than - Resolved clashing headlines - Strategies section: added `default` and explained its operation - Changed persistence extensions from code block to itemized list
So... @ThomDietrich, here is a new PR. First commit addresses all but two of your comments on #527. Two items are left:
If so, we could change this to something like: node14_humidity: strategy = everyChange, restoreOnStartup or, do you have a better example? Am I understanding your comment correctly?
Strategies { Items { And add text in front of this example pointing readers to the cron documentation for syntax and explaining the example? Got a better suggestion? BTW, I have some other changes I will submit on |
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.
Hi Brad,
Some small comments from my side. :)
Cheers
Jerome
configuration/persistence.md
Outdated
... | ||
} | ||
``` | ||
|
||
If no strategy is specified in an `itemlist` as described in the Items section below, the `default` strategy will be applied. The `default` parameter is optional and may be omitted. |
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 break down to one line per sentence.
- This may be a bit confusing for beginners.
On one side the default parameter is used when no other is given but in the next sentence this is explained as optional.
Maybe it would be good to make clear thatdefault
has to be set when one doesn't want to use explicit strategies only.
Its maybe a really small thing, but i stocked while reading through it and wanted to mention it.
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 agree completely. How about this...
The default
parameter assigns a strategy to be used if one is not specified in the Items
section below.
The default
parameter may be omitted from the Strategies
section, but if and only if a strategy is provided in each line of the Items
section.
Replace the text in the Items section with the following:
Note: if the strategy
portion of the itemlist is omitted, the default
strategy specified in the Strategies
section will be applied.
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.
Sounds good. 👍
configuration/persistence.md
Outdated
<itemlist2> [-> "<alias2>"] : [strategy = <strategyX>, <strategyY>, ...] | ||
... | ||
|
||
} | ||
``` | ||
|
||
Note that you may omit the `strategy` portion of the `itemlist` so long as you have provided a `default` strategy in the `Strategies` section. |
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.
so long as
=> as long as
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.
Yeah - 'so long as' and 'as long as' are superfine distinctions in English. 'as long as' is much more common, so this is what I should use in a document being read by people from all over the world. In any case, I am proposing to replace all of this anyway, but thank you for pointing this out.
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.
Ahh - from dictionary.cambridge.org (what do they know about English??!!)
As long as: refer to the intended duration of a plan or idea
As long as and so long as: means 'provided that", 'providing that" or 'on condition that'. So long as is a little informal.
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.
To be honest i didn't think of any rules. It sounded strange to me while reading. 😄
That was my intention to comment it here.
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 agree. Well, I will rewrite the section and drop this strange wording anyway.
- Reworded some of tne introductory material - Reorganized and changed some sub-section titles in Strategies and Items area to improve comprehension. - Item Persistence Configuration -> Persistence Configuration - Added Persistence Trigers section - Strategies section -> Strategies - Items section -> Items - Addressed comments by @Confectrician
@ThomDietrich please see comment above about changing the example from "persist absolutely everything all the time" to a specific example of an Item being persisted. Is this okay, or would you like to suggest a different one? FWIW, I stopped at the "A valid persistence configuration file might look like this:" |
configuration/persistence.md
Outdated
|
||
A complete list of supported persistence add-ons may be found in the [persistence]({{base}}/addons/persistence.html) section of the on-line openHAB documentation. | ||
|
||
## Persistence Add-on Configuration | ||
## Add-on Configuration |
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.
Once about the "Configuration" headline issue. I think it would best be solved if you simply removed this one.
wdyt?
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 - that makes sense.
configuration/persistence.md
Outdated
|
||
Each persistence add-on you install will need to be configured. | ||
Please refer to the specific [on-line documentation]({{base}}/addons/persistence.html) for your selected persistence add-on for configuration instructions. |
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 most other articles we are linking the subject directly. I.e.
Please refer to the documentation of available persistence service add-ons for configuration instructions.
(besides I for one would write online instead of on-line...?)
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.
Changed to, "Please refer to the available persistence service add-on documentation for your selected persistence add-on for configuration instructions."
configuration/persistence.md
Outdated
|
||
Persistence Strategies are configured in a file named `<persistenceservice>.persist`, stored in `$OPENHAB_CONF/persistence` ("persistenceservice" is replaced by the name of your add-on (e.g. `rrd4j.persist`)). | ||
Persistence Strategies are configured in a file named `<persistenceservice>.persist`, stored in `$OPENHAB_CONF/persistence` (Replace "persistenceservice" with the name of your persistence add-on (e.g. `rrd4j.persist`)). |
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.
double brackets? 😕
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.
How about one sentence to introduce the concept. Short example: "Configuration defines which Item, when, where."
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.
Agreed.
configuration/persistence.md
Outdated
|
||
This section allows you to define strategies and to declare a set of default strategies to use for this persistence service. The syntax is as follows: | ||
This section allows you to define one or more `Strategies` that will be applied to `Items` (you specifiy the `Items` in the `Items` section). |
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.
-you
?
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 Strategies
section allows to define one or more persistence strategies. A strategy defines the event that leads to the storage of an Item's state in the persistence service.
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.
Two points.
-
I tend to write technical information in a more personal style than some people. If this is not your preference, then I can go to an impersonal style, but I find it reads in a very strangely sometimes. Also, a little humanity can go a long way if it does not interfere or get too chatty. But this is your project and your call. Let me know what you prefer.
-
"allows to define" is a broken English sentence. You need an object. So the alternatives are, "The Strategies section allows YOU to define..." or the more impersonal, "The Strategies section allows ONE to define...". We could restructure it as follows and dodge the point... "The Strategies section defines one or more persistence strategies."
Thoughts?
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.
Thought 1: This is not my project! 😄 I'm merely the guy who joined the game a few months earlier than you 😉 You have an argument for the "you" and with that I'm fine to leave it in.
Regarding 2: Interesting. I am pretty sure that I'm using all three versions depending on my mood ^^ I'll try to remember that.
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.
Cool - we will leave "you" in. And okay on not being your project - got it. But don't want to step on your work either.
Regarding 2, the first is definitely broken, so it would be best to avoid this construction.
While we are on this topic, we should really avoid the English passive voice. The example in Wikipedia is great...
Good - Brutus stabbed Caesar
Bad - Caesar was stabbed by Brutus
The subject of the sentence should be the "doer" - the person/thing doing the doing.
Good - "The Binding updates the Item"
Bad - "The Item is updated by the binding"
configuration/persistence.md
Outdated
|
||
This section allows you to define strategies and to declare a set of default strategies to use for this persistence service. The syntax is as follows: | ||
This section allows you to define one or more `Strategies` that will be applied to `Items` (you specifiy the `Items` in the `Items` section). | ||
This section also defines a default strategy. |
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.
Combine with the explanation below (either here or there).
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.
Done
configuration/persistence.md
Outdated
|
||
- everyChange: persist the Item state whenever its state has changed | ||
- everyUpdate: persist the Item state whenever its state has been updated, even if it did not change | ||
- restoreOnStartup: load and initialize the last persisted Item state on openHAB startup (if the Item state is undefined (`UNDEF`)). See below. | ||
- restoreOnStartup: load and initialize the last persisted state of the Item on openHAB startup (if the Item state is undefined (`UNDEF`)). See below. |
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.
"restoreOnStartup
will load and ..." ?
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.
Well, the way it is currently written (this is the original language from the Wiki) it matches the other points. RE:
everyChange: persist the...
everyUpdate: persist the...
restoreOnStartup: load and initialize the...
I could change as follows:
restoreOnStatup: will load and initialize the...
but then I think the others should follow the same form:
everyChange: will persist the...
everyUpdate: will persist the...
My two cents are that the "will" is extra, but I am happy to put it in if you like. But I do feel they should all be the same.
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.
Sorry, this is not the first time I'm misleading you with super short comments.
- Yes all three
- Please add code fences
- I'm fine with either of
restoreOnStartup
: load...restoreOnStartup
- load...restoreOnStartup
will load...
Up to you!
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.
OK. Not misleading. But...
Two of them cause a persistence action. The last one causes a restore action. So 1 & 2 should be "persist" or "store". Number 3 should be "load". Agree?
configuration/persistence.md
Outdated
### Items section | ||
#### Cron Persistence Triggers | ||
openHAB uses [Quartz](http://www.quartz-scheduler.org/documentation/quartz-2.1.x/quick-start.html) for time-related cron events. | ||
In the `Strategies` syntax example above, "cronexpression" is a Quartz cron-like expression. |
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.
cronexpression
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.
Agree
configuration/persistence.md
Outdated
|
||
```java | ||
Strategies { | ||
<strategyName1> : "cronexpression1>" | ||
<strategyName2> : "cronexpression2" |
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.
With our without <>
?
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.
Right - ERROR. Will change to : "cronexpression1"
configuration/persistence.md
Outdated
@@ -76,6 +90,8 @@ where `<itemlist>` is a comma-separated list consisting of one or more of the fo | |||
- `<itemName>` a single Item identified by its name. This Item can be a group Item. But note that only the group value will be persisted. The value of the individual group members will not be persisted using this option. | |||
- `<groupName>*` - all members of this group will be persisted, but not the group itself. If no strategies are provided, the default strategies that are declared in the first section are applied. Optionally, an alias may be provided if the persistence service requires special names (e.g. a table to be used in a database, a feed id for an IoT service, etc.) | |||
|
|||
Note: if the `strategy` portion of the `itemlist` is omitted, the `default` strategy specified in the `Strategies` section will be applied. |
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 example below.
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.
How about the following:
For example, given an Item named GF_Hall_Light
, if default
in the Strategies
section is set to everyChange
, then the following Items
section,
Items {
GF_Hall_Light
}
will cause the state of GF_Hall_Light
to be persisted on every change.
@@ -139,20 +155,40 @@ You can easily imagine that you can implement very powerful rules using this fea | |||
|
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 unchanged part above, please capitalize headlines
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.
Okay - will ensure all headlines are capitalized in the entire article.
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 comment has been addressed
Yes your example would be okay with me. However to show good use of the restoreOnStartup feature, let's go with an item that doesn't come from a binding? First idea by myself:
No I think the cron topic is addressed quite well. I was aiming at the issue discussed in various places: Which persistence is best used for which kinds/types of Items (slow/fast changing, discrete/continuous, ...) However I realize that this is not easy to answer. Maybe topic for a later PR. |
configuration/persistence.md
Outdated
#### Cron Persistence Triggers | ||
openHAB uses [Quartz](http://www.quartz-scheduler.org/documentation/quartz-2.1.x/quick-start.html) for time-related cron events. | ||
In the `Strategies` syntax example above, "cronexpression" is a Quartz cron-like expression. | ||
See the [Quartz cron tutorial](http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/crontrigger) for examples of valid time-related trigger expressions. |
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 cron topic is also addressed under rules. There the description might also not be perfect but at least some useful links are given. Imho we should link to there instead of repeating incomplete info here!? http://docs.openhab.org/configuration/rules-dsl.html#time-based-triggers
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 looked at the Rules page when I wrote this. I agree that, to the greatest extent possible, there should be "one source of the truth" rather than scattering information around in different places. So...
Does this mean that there should be a separate article on Quartz and that both the Rules and Persistence articles should link to it?
Do you know for sure if you can use "midnight" and "noon" in persistence rules? This is why I did not point to the Items article. (Also, I did some brief digging but did not find any definite information about whether terms other than those two are supported. Or...
I can take the quick way out and just point to the Rules article (but there is no sub-link that I can point to that would take them straight to the Time section of the Rules document. (I could add that as a quick PR.)
Thoughts?
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.
Okay - I will change the examples to your heating example. I agree something that is not updated by a binding is better.
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 think it would be okay to link to the rules article. I'm not sure what you mean by sub-link. This one should be it?
http://docs.openhab.org/configuration/rules-dsl.html#time-based-triggers
Regarding midnight and all other doubts: Honestly you can imho ignore that for now. There is a totally new scheduler at the verge of being merged to eclipse smarthome. We'll have to touch documentation because of that soon enough.
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.
- Okay - I will simply link to that article.
- Yep - that is what I meant by the sub-link. (But I did not see the little chain link symbol on the documentation page in HTML, so I assumed the links had not been added. I need to go look at the source for the Rules page.)
- Okay - I was just concerned that someone might dive into the Rules link, see the "midnight" terminology and immediately put it into a persistence definition only to have it blow up (or work - I have no idea whether it is supported in persistence configs or not). Not a big deal.
- Deleted one configuration headline - Added intro sentence to configuration section - Combined all text about default in one section of the document - corrected cronexpression angle bracket error - added code fence around everyChange, etc. - Removed detail of Quartz stuff and just added a pointer to Rules article - Replaced "persist everything" example to persisting Heating_Mode, etc..." - Added example of how default works.
Question - this PR is getting pretty complicated. Do we want to merge what we have (after any additional comments) and then I will work on the remaining sections? Or do you prefer to have all of the updates for this pass in one PR? |
Hmm it's not that big yet, let's stay with one PR. Will you continue with the second half of the article? I guess there are some more things we can improve. |
Okay - please don't merge until tomorrow. I saw a few things I want to tweak before we close this. I think there are other issues, but they are larger than just this. For example, putting the cron stuff all in one place and pointing both this and Rules to it. I also think we need an article (tutorial?) on databases, as you mentioned. It would be a Good Thing to be able to point people to that. So I will work more on this in the next 24 hours or so. |
Ahh - your comment about doing a merge soon had to do with the sitemaps article - I was reading the email notification and did not click through to the GitHub link until just now. Anyway, more input coming on this article. |
- Numerous small changes to improve readability
@ThomDietrich I have now completed my nit pass through the entire Persistence article. There is one TODO open under Workaround 1 for the issue of the rules engine and persistence restoration happening at the same time. The note says we need an example of the workaround. I don't feel comfortable writing this even though it is simple, so I just left the TODO open. Please look this over and see if it is ready to merge. |
- Existing text was not clear about the syntax one would use with a Persistence Extension in order to specify a persistence store in cases where multiple stores are available. - Clarified language and added an example.
One thing- I would like to fix the code-fenced text around the persistence extensions, but I do not know how to "escape" an angle bracket so that it remains visible. In the text now, [item] (but with angle brackets instead of square brackets) does not appear to render normally. What is the secret? |
Hey Brad, Angle brackets can even in Markdown be used to include HTML code tags. Your <Item> is interpreted as an (invalid) HTML tag. If you need the actual characters, you need to HTML-escape them with |
- Removed extra lines - Added code fences Signed-off-by: Brad Gilmer <[email protected]> (github: bgilmer77)
@ThomDietrich I think all of your comments have been addressed (hopefully). I have no idea why there were all the extra spaces - they have been removed. I have also added code fences, and everything looks just as it should, in my opinion, but let me know what you think. |
- Changed Persistence Extensions section from a non-enumerated list to a table - Fixed a spelling error in the section on restoring items after a restart Signed-off-by: Brad Gilmer <[email protected]> (github: bgilmer77)
Reformatted the Persistence Extensions as a table. I like this much better. Okay with you? BTW, I installed jekyll and can now render pages locally - what a Fantastic Thing!!!! |
Signed-off-by: Thomas Dietrich <[email protected]> (github: ThomDietrich)
The table is also a good option! I've added a proper header to it with my commit. I believe the article can still be improved but it's a great start and I'd say let's continue and merge. New PRs can be created for further aspects. A local Jekyll installation is great! Did you also check out the Vagrant machine? |
To be honest: We should maybe add some info about this in the docs too, for interested users and give them a starting point. |
Yeah the refreshing is an issue I've also struggled with for quite some time... Yes please :) https://github.com/openhab/openhab-docs/blob/gh-pages/README.md |
Addressing comments left over from #527
default
and explained its operation