Skip to content
Snippets Groups Projects
Commit a185b579 authored by René Schöne's avatar René Schöne
Browse files

Resolve "Create pages documentation"

parent 33924f8d
No related branches found
No related tags found
2 merge requests!19dev to master,!7Resolve "Create pages documentation"
pages/docs/img/rules-sequence.png

23.7 KiB

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="14.3.0">
<zoom_level>10</zoom_level>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>240</x>
<y>280</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>_item1:Item_</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>280</x>
<y>340</y>
<w>20</w>
<h>90</h>
</coordinates>
<panel_attributes/>
<additional_attributes/>
</element>
<element>
<id>UMLActor</id>
<coordinates>
<x>120</x>
<y>330</y>
<w>60</w>
<h>110</h>
</coordinates>
<panel_attributes>User</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>170</x>
<y>340</y>
<w>130</w>
<h>40</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-
setState</panel_attributes>
<additional_attributes>110.0;20.0;10.0;20.0</additional_attributes>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>420</x>
<y>410</y>
<w>20</w>
<h>100</h>
</coordinates>
<panel_attributes/>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>420</x>
<y>300</y>
<w>30</w>
<h>130</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;110.0</additional_attributes>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>360</x>
<y>280</y>
<w>150</w>
<h>30</h>
</coordinates>
<panel_attributes>_io1:ItemObserver_
bg=yellow</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>290</x>
<y>400</y>
<w>150</w>
<h>40</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-
apply</panel_attributes>
<additional_attributes>130.0;20.0;10.0;20.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>290</x>
<y>350</y>
<w>130</w>
<h>60</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-
sendState0</panel_attributes>
<additional_attributes>10.0;40.0;30.0;40.0;30.0;10.0;10.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>430</x>
<y>420</y>
<w>130</w>
<h>60</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-
check if
stateEquals</panel_attributes>
<additional_attributes>10.0;40.0;30.0;40.0;30.0;10.0;10.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>430</x>
<y>470</y>
<w>190</w>
<h>40</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-
trigger</panel_attributes>
<additional_attributes>170.0;20.0;10.0;20.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>600</x>
<y>300</y>
<w>30</w>
<h>210</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;190.0</additional_attributes>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>600</x>
<y>490</y>
<w>20</w>
<h>280</h>
</coordinates>
<panel_attributes>
layer=-1</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>560</x>
<y>280</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>_rA:Rule_
bg=yellow</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>710</x>
<y>280</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>_cA1:Condition_</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>750</x>
<y>570</y>
<w>20</w>
<h>50</h>
</coordinates>
<panel_attributes/>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>750</x>
<y>300</y>
<w>30</w>
<h>290</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;270.0</additional_attributes>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>830</x>
<y>280</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>_aA1:Action_</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>870</x>
<y>690</y>
<w>20</w>
<h>20</h>
</coordinates>
<panel_attributes/>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>870</x>
<y>300</y>
<w>30</w>
<h>410</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;390.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>610</x>
<y>560</y>
<w>160</w>
<h>40</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-
holdsFor(item1)</panel_attributes>
<additional_attributes>140.0;20.0;10.0;20.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>280</x>
<y>420</y>
<w>30</w>
<h>360</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;340.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>420</x>
<y>500</y>
<w>30</w>
<h>210</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;190.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>610</x>
<y>600</y>
<w>160</w>
<h>30</h>
</coordinates>
<panel_attributes>lt=&lt;.</panel_attributes>
<additional_attributes>10.0;10.0;140.0;10.0</additional_attributes>
</element>
<element>
<id>UMLFrame</id>
<coordinates>
<x>590</x>
<y>630</y>
<w>310</w>
<h>130</h>
</coordinates>
<panel_attributes>alt
layer=1
bg=white
--
[if all conditions hold]
-.
[else]
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>280</x>
<y>300</y>
<w>30</w>
<h>60</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;40.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>610</x>
<y>680</y>
<w>280</w>
<h>40</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-
applyFor(item1)
layer=2</panel_attributes>
<additional_attributes>260.0;20.0;10.0;20.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>430</x>
<y>700</y>
<w>190</w>
<h>30</h>
</coordinates>
<panel_attributes>lt=&lt;.</panel_attributes>
<additional_attributes>10.0;10.0;170.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>430</x>
<y>760</y>
<w>190</w>
<h>30</h>
</coordinates>
<panel_attributes>lt=&lt;.</panel_attributes>
<additional_attributes>10.0;10.0;170.0;10.0</additional_attributes>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>990</x>
<y>760</y>
<w>20</w>
<h>50</h>
</coordinates>
<panel_attributes/>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>990</x>
<y>300</y>
<w>30</w>
<h>480</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;460.0</additional_attributes>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>950</x>
<y>280</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>_rB:Rule_
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>430</x>
<y>780</y>
<w>580</w>
<h>40</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-
trigger</panel_attributes>
<additional_attributes>560.0;20.0;10.0;20.0</additional_attributes>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>420</x>
<y>690</y>
<w>20</w>
<h>120</h>
</coordinates>
<panel_attributes/>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>290</x>
<y>800</y>
<w>150</w>
<h>30</h>
</coordinates>
<panel_attributes>lt=&lt;.</panel_attributes>
<additional_attributes>10.0;10.0;130.0;10.0</additional_attributes>
</element>
<element>
<id>UMLGeneric</id>
<coordinates>
<x>280</x>
<y>760</y>
<w>20</w>
<h>60</h>
</coordinates>
<panel_attributes/>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>280</x>
<y>810</y>
<w>30</w>
<h>50</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;30.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>420</x>
<y>800</y>
<w>30</w>
<h>60</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;40.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>600</x>
<y>760</y>
<w>30</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>10.0;10.0;10.0;80.0</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>1000</x>
<y>280</y>
<w>60</w>
<h>30</h>
</coordinates>
<panel_attributes>bg=orange
fg=white</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>950</x>
<y>280</y>
<w>60</w>
<h>30</h>
</coordinates>
<panel_attributes>bg=yellow
fg=white</panel_attributes>
<additional_attributes/>
</element>
</diagram>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="14.3.0">
<zoom_level>10</zoom_level>
<element>
<id>UMLClass</id>
<coordinates>
<x>230</x>
<y>30</y>
<w>160</w>
<h>50</h>
</coordinates>
<panel_attributes>item1:NumberItem
--
state: Double
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>620</x>
<y>30</y>
<w>160</w>
<h>50</h>
</coordinates>
<panel_attributes>item2:ColorItem
--
state: TupleHSB</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>620</x>
<y>120</y>
<w>160</w>
<h>30</h>
</coordinates>
<panel_attributes>io2:ItemObserver
bg=orange</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>230</x>
<y>120</y>
<w>160</w>
<h>30</h>
</coordinates>
<panel_attributes>io1:ItemObserver
bg=yellow</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>300</x>
<y>70</y>
<w>30</w>
<h>70</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;50.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>680</x>
<y>70</y>
<w>30</w>
<h>70</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;50.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>220</x>
<y>140</y>
<w>60</w>
<h>230</h>
</coordinates>
<panel_attributes>lt=&lt;-
</panel_attributes>
<additional_attributes>10.0;210.0;40.0;210.0;40.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>290</x>
<y>140</y>
<w>240</w>
<h>230</h>
</coordinates>
<panel_attributes>lt=&lt;-
</panel_attributes>
<additional_attributes>200.0;210.0;220.0;210.0;220.0;130.0;10.0;130.0;10.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>350</x>
<y>0</y>
<w>470</w>
<h>370</h>
</coordinates>
<panel_attributes>lt=&lt;-
</panel_attributes>
<additional_attributes>390.0;350.0;450.0;350.0;450.0;20.0;190.0;20.0;190.0;190.0;10.0;190.0;10.0;150.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>480</x>
<y>140</y>
<w>230</w>
<h>270</h>
</coordinates>
<panel_attributes>lt=&lt;-
</panel_attributes>
<additional_attributes>10.0;250.0;50.0;250.0;50.0;80.0;210.0;80.0;210.0;10.0</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>70</x>
<y>290</y>
<w>160</w>
<h>30</h>
</coordinates>
<panel_attributes>rA:Rule</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>120</x>
<y>420</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>aA:Action</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>120</x>
<y>380</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>cA:Condition</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>120</x>
<y>340</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>e1A:Event
bg=yellow</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>80</x>
<y>310</y>
<w>60</w>
<h>60</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;40.0;40.0;40.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>80</x>
<y>310</y>
<w>60</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;80.0;40.0;80.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>80</x>
<y>310</y>
<w>60</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;120.0;40.0;120.0</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>330</x>
<y>290</y>
<w>160</w>
<h>30</h>
</coordinates>
<panel_attributes>rB:Rule</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>380</x>
<y>460</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>aB:Action</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>380</x>
<y>420</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>cB:Condition</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>380</x>
<y>340</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>e1B:Event
bg=yellow</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>340</x>
<y>310</y>
<w>60</w>
<h>60</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;40.0;40.0;40.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>340</x>
<y>310</y>
<w>60</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;120.0;40.0;120.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>340</x>
<y>310</y>
<w>60</w>
<h>180</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;160.0;40.0;160.0</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>580</x>
<y>290</y>
<w>160</w>
<h>30</h>
</coordinates>
<panel_attributes>rC:Rule</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>630</x>
<y>420</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>aC:Action</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>630</x>
<y>380</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>cC:Condition</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>630</x>
<y>340</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>e1C:Event
bg=yellow</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>590</x>
<y>310</y>
<w>60</w>
<h>60</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;40.0;40.0;40.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>590</x>
<y>310</y>
<w>60</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;80.0;40.0;80.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>590</x>
<y>310</y>
<w>60</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;120.0;40.0;120.0</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>380</x>
<y>380</y>
<w>110</w>
<h>30</h>
</coordinates>
<panel_attributes>e2B:Event
bg=orange</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>340</x>
<y>310</y>
<w>60</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;80.0;40.0;80.0</additional_attributes>
</element>
</diagram>
pages/docs/img/swagger-ui.png

109 KiB

# Documentation of Eraser
First, setup eraser following the README in the main repository: [dev](https://git-st.inf.tu-dresden.de/OpenLicht/eraser/blob/dev/README.md) | [master](https://git-st.inf.tu-dresden.de/OpenLicht/eraser/blob/master/README.md)
To configure the system, read the [configuration page](config).
For an overview of the model, check out the [Model description](Model-description).
If you need more details, dive into the [inner workings](Inner-workings) (now with colorful images!), [insights for working with the model](working) the [description of machine learning](MachineLearning) (with code examples) or the [description of Learner implementation](Learner) (only in German).
To be able to read in models, a [dedicated DSL](DSL) must be used.
Further, the updated [configuration settings regarding MQTT 1.x and 2.x](mqtt) as well as the [Setup guide to connect to openHAB](openhab-binding) (only in German) are found in this wiki.
For contributing, please see [contribution guideline](contributing).
# OpenHAB Bindings
## openHAB 2.0-2.3 and MQTT 1.x
In the old openHAB versions, there used to be the MQTT event bus, which publishes every change of the state of an item to a channel dedicated to this item, and receives updates for the state analogously.
The configuration file needed is located in `/etc/openhab2/services/mqtt-eventbus.cfg` with the following content:
```bash
broker=mosquitto_local
statePublishTopic=oh2/out/${item}/state
commandSubscribeTopic=oh2/in/${item}/state
```
If you have an item named `iris1_item`, then every change (e.g., using the PaperUI) will be published to `oh2/out/iris1_item/state`.
And whenever a message is published to `oh2/in/iris1_item/state`, its payload will be used to update the state of the item `iris1_item`.
## openHAB 2.4+ and MQTT 2.x
In the more recent versions of openHAB, the old MQTT binding was ported to the new architecture.
However, the event bus feature [was dropped in favour of simple rules](https://community.openhab.org/t/roadmap-mqtt-binding/70657/12).
Now the following setup is required, involving one new channel, one new group and two new rules.
### A new MQTT channel to receive updates
To enable a trigger for all new MQTT messages, a new channel has to be created in the Thing of the respective broker.
Navigate to the Thing of the broker in the PaperUI, and click the "+" near "Channels" to create a new one using the following settings:
- Channel type: "Publish trigger" (will change the editable fields)
- Channel Id: Choose any appropriate name and stick to it. In the following, `receiveEverythingChannel` will be used.
- Label: Pick a description, like "Receive everything".
- MQTT Topic: This is the topic to subscribe to, and has to match the `outgoing` value in the MQTT settings of Eraser. The default in most examples is to use `oh2/in/#`.
- Payload condition: Is left empty.
- Separator character: The character to separate the last topic and the payload. In the following, "#" is used (not to be confused with the `#` used for the topic above, which matches any topic with the given prefix)
### A new group for relevant items
To enable a trigger to publish new states, a new group has to be created with all relevant items as children.
Navigate to Configuration > Items in the PaperUI. If this is not visible, disable the "Simple Mode" found at Configuration > System > Item Linking. This enables the manual editing of items and their links to channels.
Create a new group with the following settings:
- Name: Choose any appropriate name and stick to it. In the following, `PublishAllToMqttGroup` will be used.
- Label: Pick a description, like "Items whose state will be published to MQTT".
- Category: Is left empty.
- Type: `Group`
- Base type: `None` (Other types would enable an aggregation function, which is not needed here)
### A rule to process received updates
Add the following rule to your rule file in `./etc/openhab2/rules/`:
```java
rule "Receive all"
when
Channel "mqtt:systemBroker:embedded-mqtt-broker:receiveEverythingChannel" triggered
then
// The receivedEvent String contains unneeded elements like the mqtt topic, we only need everything after the "/" as this is were item name an
// logInfo("one.rules", "receivedEvent: {}", receivedEvent.toString())
val payload = receivedEvent.toString.split(" ", 3).get(2)
val parts = payload.split("/")
// logInfo("one.rules", "parts: {}", parts)
val lastTopicPartAndRealPayload = parts.get(parts.length - 1)
// logInfo("one.rules", "lastTopicPartAndRealPayload: {}", lastTopicPartAndRealPayload)
val topicAndPayloadTokens = lastTopicPartAndRealPayload.split("#", 2)
// logInfo("one.rules", "topicAndPayloadTokens: {}", topicAndPayloadTokens)
sendCommand(topicAndPayloadTokens.get(0), topicAndPayloadTokens.get(1));
end
```
Note the matching channel id for an system broker with the id `embedded-mqtt-broker`. If you use a normal broker with the id `myMQTTBroker`, it would be `mqtt:broker:myMQTTBroker:receiveEverythingChannel` instead.
The rule processes the received information, which is a String containing the topic and payload, separated by the formerly chosen Separator character `#`.
Lastly, it updates the item matching the last part of the topic with the payload.
### A rule to publish updates
```java
rule "Publish all"
when
Member of PublishAllToMqttGroup changed
then
val actions = getActions("mqtt","mqtt:systemBroker:embedded-mqtt-broker")
actions.publishMQTT("oh2/out/" + triggeringItem.name, triggeringItem.state.toString);
end
```
Note the matching group name `PublishAllToMqttGroup`, the matching name of the system broker `embedded-mqtt-broker` (see [above](#a-rule-to-process-received-updates) for normal broker), and the correct topic to publish to.
The topic has to match the `incoming` value in the MQTT settings of Eraser. The default in most examples is to use `oh2/out/`.
# Setup für Knowledge-Base
_This document is only available in German_
## Eraser-Seite
Grundlage zum Starten der Knowledge-Base ist die Datei `eraser.starter-1.0.0-SNAPSHOT.zip`, welche die eraser-Module, deren Abhängigkeiten sowie ein Start-Skript enthält.
Zusätzlich ist eine Konfigurationsdatei im YAML-Format notwendig. Die Standard-Konfiguration ist folgende (mit den Standard-Werten in Kommentaren):
```yaml
# Settings for Eraser.
# Start the feedback loop. Default: true.
useMAPE: true
rest:
# Start the REST server. Default: true.
use: true
# Port of the REST server. Default: 4567.
port: 4567
# Add some dummy data for activities and events. Only effective when using the REST server. Default: false.
createDummyMLData: false
# Initialize the knowledge base with a file.
# OpenHAB synchronization is done if MQTT url is set in the processed file
load:
# File to read in. Expected format = eraser
# # Option 1: Use built-in file
# file: starter.eraser
# external: false
# Option 2: Use external file
file: starter.eraser
external: true
# Model for activity recognition. If dummy is true, then the file parameter is ignored.
activity:
# File to read in. Expected format = eg
file: activity.eg
# Use dummy model in which the current activity is directly editable. Default: false.
dummy: true
# Model id. Default: 1.
id: 1
# Model for preference learning. If dummy is true, then the file parameter is ignored.
preference:
# File to read in. Expected format = eg
file: preference.eg
# Use dummy model in which the current activity is directly editable. Default: false.
dummy: true
# Model id. Default: 1.
id: 1
# Items to connect to inputs
items:
- datetime_month
- datetime_day
- datetime_hour
- datetime_minute
- bias
- activity
# Item to change with classification result
affectedItem: iris1_item
# Initialize the knowledge base by importing data from openHAB.
openhab:
# The URL from which to import and at which openHAB is running
url: "127.0.0.1:8080"
# The metadata namespace for items
metadataNamespace: fuenf
# Get updates from openHAB into the knowledge base. Default: true.
mqttUpdate: true
# Method to initialize model. Possible values: "load", "openhab". Default: "load".
initModelWith: load
```
Anzupassen ist folgendes:
- referenzierte Dateien (initiales Modell `load.file = starter.eraser`, ML-Modell für Aktivitätserkennung `activity.file = activity.eg` und ML-Modell für Präferenzen `preference.file = preference.eg`)
- referenzierte Items für die Präferenzen (`preference.items` und `preference.affectedItem`)
- URL von openHAB, inklusive Port. Optional der Namespace für Metadaten.
Die in der Konfigurations-Datei referenzierte Modell-Datei `starter.eraser` enthält das initiale Modell in der dafür vorgesehenen [DSL](https://git-st.inf.tu-dresden.de/OpenLicht/eraser/wikis/DSL). Ein Beispiel-Modell sieht wie folgt aus:
```
Color Item: id="iris1_item" label="Iris 1" state="121,88,68" topic="iris1_item";
Number Item: id="datetime_month" label="Month" state="1" topic="datetime_month";
Number Item: id="datetime_day" label="Day" state="31" topic="datetime_day";
Number Item: id="datetime_hour" label="Hour" state="13" topic="datetime_hour";
Number Item: id="datetime_minute" label="Minute" state="37" topic="datetime_minute";
Number Item: id="bias" label="bias item" state="1" ;
Activity Item: id="activity" ;
Group: id="Lights" items=["iris1_item"];
Group: id="Datetime" items=["datetime_month", "datetime_day", "datetime_hour", "datetime_minute"];
Mqtt: incoming="oh2/out/" outgoing="oh2/in/" host="localhost:2883" ;
Influx: host="172.22.1.152" ;
ML: activities={
0: "Open door in empty room",
1: "Door closed in empty room",
2: "Open door with person in room",
3: "Door closed with person in room",
4: "Working",
5: "Watch TV",
6: "Reading",
7: "Listening to music",
8: "Going to sleep",
9: "Wake up"
} ;
```
Im Statement zu `Mqtt` muss die Verbindung zum MQTT-Broker, der auch im openHAB verwendet wird, angegeben werden. Gegebenfalls muss eine Port-Weiterleitung eingerichtet werden.
Das Statement zu Influx ist optional.
Zum Starter der Knowledge-Base ist die Konfigurationsdatei anzugeben (hier im Beispiel `./starter-setting.yaml`):
```bash
./eraser.starter-1.0.0-SNAPSHOT/bin/eraser.starter -f starter-setting.yaml
```
Zum Beenden sollte (wie auch beim Starten im Log zu lesen) ein POST-Request auf `localhost:3467/system/exit` gesendet werden. Das ist auch über die [Swagger-UI](#swagger-ui-fur-die-rest-api-der-knowledge-base) möglich.
## openHAB-Seite
Grundlage auf der openHAB-Seite ist ein installiertes MQTT-Binding in Version 2, und das Eraser-Binding in Version `2.3.0.201904121612`.
In der PaperUI muss ein MQTT-Broker-Thing angelegt werden, entweder ein SystemBroker oder ein lokaler Broker, wie im Beispiel gezeigt:
![MQTT Binding Config](img/config-mqtt-binding.png)
Zusätzlich muss ein Eraser-Thing angelegt werden, welches den Namen des oben genannten Brokers in den Einstellung gesetzt hat (hier im Beispiel `local-mqtt-broker`).
Wahlweise können Updates von allen Items (`Publish All` aktiviert), oder nur von Items in einer Gruppe (`Publish All` deaktiviert und `Publish Group` ausgewählt) an Eraser gesendet werden.
Weiterhin ist zu beachten, dass die MQTT-Topics hier und bei der Eraser-Konfiguration übereinstimmen, d.h.
- `openhab.Base-Topic == eraser.outgoing` (im Beispiel `oh2/in`)
- `openhab.Outgoing-Topic == eraser.incoming` (im Beispiel `oh2/out`)
![Eraser Binding Config](img/config-eraser-binding.png)
## Swagger-UI für die REST-API der Knowledge-Base
Zur einfacheren Verwendung der REST-API wurde eine Swagger-UI in Python entwickelt, da das verwendete leichtgewichtige REST-Framework ([SparkJava](http://sparkjava.com/)) dies nicht unterstützt.
Zum Starten wird das Python-Skript gestartet, welches auf `localhost:5000` läuft und nach `localhost:4567` (Standard-Einstellung in der Knowledge-Base unter `rest.port`) weiterleitet.
```bash
python forward.py
```
Abhängigkeiten sind `flask`, `flask_restplus` und `requests`.
Nach Starten sieht die Oberfläche aktuell wie folgt aus:
![Swagger-UI Startseite](img/swagger-ui.png)
# Setup and Building eraser
This project uses Gradle as the build tool. Please use the provided Gradle wrappers instead of an installed one.
- Clone the repository, either using https (`https://git-st.inf.tu-dresden.de/OpenLicht/eraser.git`) or ssh (`git@git-st.inf.tu-dresden.de:OpenLicht/eraser.git`)
- (Optional) Build all subprojects: `./gradlew build`
## Troubleshooting
### Lombok
Some of the modules use [Lombok](https://projectlombok.org/). It has to be set up according to your platform, e.g., for IntelliJ the [plugin has to be installed](https://projectlombok.org/setup/intellij).
Afterwards, the annotation processor has to be enabled for the project (which sould be warned about by IntelliJ).
### Java Version
All submodules use Java `1.8`. Please ensure using an appropriate compiler.
# Working with the model
The root is mostly the entry point to all needed information, and can be obtained from any element in the model using `getRoot()`.
From there, one has mostly "descend" into the relevant part of the model, e.g., if information is needed about items, then `getOpenHAB2Model()` yields this part of the model.
There are various attributes to resolve model entities by their ID, e.g., `resolveThing(String thingName)`, `resolveItem(String itemName)`. Those return an `java.util.Optional` with the respective type, e.g., `Optional<Item>` to represent non-matched IDs.
## OpenHAB specifics
As described in the [description of the model](Model-description), item type is reified, so all items with a double state are of type `ItemWithDoubleState` and only this type has a `getState` returning its state (as a double value).
There is a convenience way to get the state as a double, or String value using `getStateAsDouble` and `getStateAsString` defined on `Item` and implement in a meaningful way by the different subclasses.
Analogously, state can be set from different type, e.g., from a String, or a boolean value.
Synchronisation between eraser and openHAB itself currently includes only states of items. Therefore, any structural changes (e.g., addition or removal of an item) or change of other attributes such as description of items or things, is **not tracked nor supported**.
## Documentation
When working and especially when extending eraser, it is highly recommended to use the [API documentation](ragdoc/index.html) as a reference manual.
site_name: Documentation of Eraser
nav:
- setup.md
- config.md
- Model-description.md
- Inner-workings.md
- working.md
- MachineLearning.md
- Learner.md
- DSL.md
- mqtt.md
- openhab-binding.md
- contributing.md
- API documentation: ragdoc/index.html
theme:
name: readthedocs
custom_dir: custom_theme/
plugins:
- search
- git-revision-date:
as_datetime: True
- macros
repo_url: https://git-st.inf.tu-dresden.de/OpenLicht/eraser
site_dir: ../public
ragdoc-view @ 4bb8afb1
Subproject commit 4bb8afb1bc3dc6b346e04e72c5896568b2e9b192
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment