A new plugin is available for Mqtt protocol.
How it works MQTT?
MQTT Essentials
Entertaining way Pub/Sub for the masses (only german version)
What I wanted to achieve:
- I was looking for way to be more independent of the control systems and software in actuators and sensors.
- the ability to control and monitor almost anything right now (without waiting for the development of features for a device or pimatic).
- decrease the variety of software in Sensors and Actuators
- simplicity of solutions and protocols.
- the possibility of frequent changes in my home system.
- spend less time inventing how to transfer sonsors and control data.
- and save a little
One of the possible scenarios
+---------------+ +----------------------+
| | | Sensors & Actuators |
| Pimatic A +-------+ +-------+ (WiFi Ethernet) |
| | | | | (MQTT compilant dev) |
+---------------+ +--+----------+-+ +----------------------+
| MQTT-Broker |
| (message bus) |
| (Mosquitto, |
| RabbitMQ, |
| HiveMQ etc.) |
| |
+---------------+ +--+----------+-+ +------------------------+
| | | | | Interface C |
| Pimatic B +-------+ +-----+ (e.g. OpenHub, Blynk, |
| | | Mqtt clients, CLI etc.)|
+---------------+ +----------------------- +
I’m working on it to all devices, responded well to the outside world. Switch, Contact and Presence sensor that support already have. You may as well add the device to two Pimatics and everything works interconnection, including cooperation with real device.
For Dimmer, Buttons it will be done soon.
I also work on the broadcasting of all variables on the Broker. For scenarios Pimatic A send data to the broker, Pimatic B will take necessary data. A pimatics not be just two.
At the same time everything can be monitored and controlled externally. CLI, various MQTT (IoT) managers etc.
Following might step towards complete driving Pimatic over MQTT.
How install
Description based on the assumption that everything runs on one RPI.
Install MQTT Broker
For Debian wheezy you can install Mosquitto according to these instructions.
Only at the end I recommend using.
sudo apt-get install mosquitto mosquitto-clients
You will get the utilities for handling messages bus from CLI (mosquitto_passwd, mosquitto_pub, mosquitto_sub)
For Debian jessie just use this command.
Start Mosquitto
sudo /etc/init.d/mosquitto start
Install Pimatic module
Stop Pimatic
sudo /etc/init.d/pimatic stop
add plugin to plugin section in config,json
{
"plugin": "mqtt"
}
Add some device into device section in config,json
{
"class": "MqttSensor",
"id": "mosquitto",
"name": "Mosquitto MQTT broker",
"attributes": [
{
"name": "connected-clients",
"topic": "$SYS/broker/clients/connected",
"type": "number",
"acronym": "Clients"
}
]
},
{
"class": "MqttSensor",
"id": "sensor-with-lookup",
"name": "Sensor with lookup",
"attributes": [
{
"name": "state",
"topic": "pimatic/lookup",
"type": "string",
"unit": "",
"acronym": "",
"messageMap": {
"0": "Not ready",
"1": "Ready",
"2": "Completed"
}
}
]
}
Start Pimatic (Start will take a little longer, Pimatic will download the plugins and dependencies.)
sudo /etc/init.d/pimatic start
Test
mosquitto_pub -t "pimatic/lookup" -m "1"
That is all. Have fun with MQTT
Everything important can be found in the plugin README.