|
|
(5 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | == Description ==
| |
| | | |
− | This bridge allows sensiNact to subscribe to a MQTT topic, and materializes a sensiNact device based on the messages. The devices are displayed just after its configuration (once the <code>.cfg</code> file is deployed, check below) but the value will be update upon the message arrivals.
| |
− |
| |
− | == Requirements ==
| |
− |
| |
− | * MQTT bridge activated (using <code>sensinact -c</code>) ;
| |
− | * MQTT server running.
| |
− |
| |
− | == How to use it ==
| |
− |
| |
− | Create a file <code>mosquitto-X.cfg</code> where <codeX</code> is a number that will stand as OSGi service PID (for more details, checks Felix '''Configuration Manager''').
| |
− |
| |
− | The fields in this file are defined as in a regular property file. The mandatory fields are '''id''' and '''topic'''. In case any of the other fields '''host''' and '''port''' are not specified their defaults values are assumed, which are `127.0.0.1` and `1883` respectively.
| |
− |
| |
− | The '''id''' becomes the '''provider''' into sensiNact (the name of the sensor), the '''topic''' corresponds to the topic in which the provider is attached to. It means that when a new message on the assigned topic is received, the value associated with the device defined in '''id''' is updated.
| |
− |
| |
− | One example of file (named <code>mosquitto-1.cfg</code>) content is shown below:
| |
− |
| |
− | <source lang="html4strict">
| |
− | host=127.0.0.1
| |
− | port=1883
| |
− | id=counter
| |
− | topic=/camera
| |
− | </source>
| |
− |
| |
− | In order to be taken into account, this file '''MUST''' be deployed in the directory <code>$SENSINACT_HOME/load</code>.
| |
− |
| |
− | If the message sent to the MQTT does not correspond to clear text, but some other format (e.g., JSON), you can specify two properties, '''payload.format''' and '''payload.sensorValue''':
| |
− | * The '''payload.format''' supports the value 'json' at this moment ;
| |
− | * You MUST specify '''payload.sensorValue''' to indicate which element from the JSON you want to use.
| |
− |
| |
− | <source lang="html4strict">
| |
− | host=127.0.0.1
| |
− | port=1883
| |
− | id=counter
| |
− | topic=/camera
| |
− | payload.format=json
| |
− | payload.sensorValue=value
| |
− | </source>
| |
− |
| |
− | == Limitations ==
| |
− |
| |
− | * One topic is associated with one, and only one, sensiNact provider ;
| |
− | * The topic message is considered as <code>String</code> value, although the SNA generic performs automatic conversion to numeric types. It means that even <code>String</code> values can use numeric operators, e.g., "more than", "less than", etc. The conversion will be performed automatically in SNA.
| |