-
-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for Thing Model module and GenericThingProvider
- Loading branch information
1 parent
0d031a3
commit 631ac81
Showing
2 changed files
with
158 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# OpenHAB Core Thing Model | ||
|
||
## Overview | ||
|
||
The Thing Model module is a crucial component of OpenHAB's core architecture that handles the definition, parsing, and processing of Thing configurations. Things in OpenHAB represent physical devices or web services that can be integrated into the system. | ||
|
||
## Key Components | ||
|
||
### Formatting (`formatting/`) | ||
|
||
- `ThingFormatter.xtend`: Handles the formatting of Thing definitions in the OpenHAB configuration syntax. | ||
|
||
### Generator (`generator/`) | ||
|
||
- `ThingGenerator.xtend`: Generates the necessary code for Thing implementations based on model definitions. | ||
|
||
### Internal (`internal/`) | ||
|
||
- `AbstractProviderLazyNullness.java`: Provides base implementation for lazy loading of Thing properties | ||
- `GenericItemChannelLinkProvider.java`: Manages links between Items and Thing channels | ||
- `GenericThingProvider.xtend`: Core provider implementation for Thing management | ||
|
||
### Scoping (`scoping/`) | ||
|
||
- `ThingScopeProvider.xtend`: Handles the scoping rules for Thing definitions | ||
|
||
### Serializer (`serializer/`) | ||
|
||
- `ThingSemanticSequencer.xtend`: Manages semantic sequencing of Thing definitions | ||
- `ThingSyntacticSequencer.xtend`: Handles syntactic sequencing of Thing configurations | ||
- `ThingSyntacticSequencerExtension.java`: Extension for Thing syntax processing | ||
|
||
### Validation (`validation/`) | ||
|
||
- `ThingValidator.xtend`: Validates Thing configurations to ensure correctness | ||
|
||
### Value Converter (`valueconverter/`) | ||
|
||
- `ThingValueConverters.java`: Handles conversion of Thing configuration values | ||
- `UIDtoStringConverter.java`: Converts between UIDs and string representations | ||
|
||
## Usage | ||
|
||
### Thing Definition Example | ||
|
||
Here's a simple example of how to define a Thing in your OpenHAB configuration: | ||
|
||
```Thing mqtt:topic:livingroom "Living Room Sensor" @ "First Floor" [ | ||
broker="home-mqtt", | ||
topic="home/livingroom/sensor", | ||
refresh=60 | ||
] | ||
``` | ||
|
||
This defines an MQTT sensor in the living room that reads data every 60 seconds. | ||
|
||
## Key Features | ||
|
||
The Thing Model helps you: | ||
|
||
1. Define your smart devices in a readable way | ||
2. Make sure your configurations are valid before they run | ||
3. Handle different types of devices consistently | ||
4. Keep your Things organized and manageable | ||
|
||
Think of it as the blueprint system for your smart home devices - it helps OpenHAB understand what devices you have and how to talk to them. | ||
|
||
## Working with Other Parts | ||
|
||
The Thing Model doesn't work alone - it's part of a bigger system: | ||
|
||
1. Talks directly to your physical devices through bindings | ||
2. Works with Items to show device info in your UI | ||
3. Helps with finding new devices on your network | ||
4. Lets you change device settings while everything's running | ||
|
||
## Development Tips | ||
|
||
When working with Things, keep these points in mind: | ||
|
||
### Keep It Clean | ||
|
||
1. Use clear names for your Things | ||
2. Group related Things together | ||
3. Comment your configurations | ||
|
||
### Play It Safe | ||
|
||
1. Always validate your Thing configs before using them | ||
2. Test your changes in a safe environment first | ||
3. Back up working configurations | ||
|
||
### Common Gotchas | ||
|
||
1. Double-check your Thing IDs - they must be unique | ||
2. Watch out for special characters in Thing names | ||
3. Remember to handle offline devices gracefully | ||
|
||
## Need more examples or have questions? | ||
|
||
Check out: | ||
|
||
1. The OpenHAB community forums | ||
2. Example configurations in the addons repository | ||
3. The binding developer guide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters