Not sure what you tested exactly? MQTT is fast and the publishes are instant.
Remember If you change something (turn switch on/off) and you don't see that the interface, doesn't mean the publish is slow. The interface refreshes every X seconds.
Below a simple test, to show you how fast it is.
Code: Select all
<?php
$client = new Mosquitto\Client();
$client->onConnect('connect');
$client->onDisconnect('disconnect');
$client->onMessage('message');
$client->connect("localhost", 1883, 5);
$client->subscribe('#', 1);
$client->loopForever();
$client->unsubscribe('#');
function connect($r, $message) {
echo "I got code {$r} and message {$message}\n";
}
function message($message) {
printf("%s %s -- message: %s" . PHP_EOL, date('Y-m-d H:i:s'), $message->topic, $message->payload);
}
function disconnect() {
echo "Disconnected cleanly\n";
}
So now I start 2 terminals, one to run the test.php and one to publish.
Terminal #1
Code: Select all
$ php test.php
I got code 0 and message Connection Accepted.
Terminal #2
Code: Select all
mosquitto_pub -h localhost -m '{ "idx" : 6, "nvalue" : 1, "svalue" : "25.0" }' -t 'domoticz/in'
Back to terminal #1 (pay attention to the timestamps)
Code: Select all
2018-02-02 10:58:17 domoticz/in -- message: { "idx" : 6, "nvalue" : 1, "svalue" : "25.0" }
2018-02-02 10:58:17 domoticz/out -- message: {
"Battery" : 255,
"RSSI" : 12,
"description" : "",
"dtype" : "Light/Switch",
"id" : "00014056",
"idx" : 6,
"name" : "iPhone Ali",
"nvalue" : 1,
"stype" : "Switch",
"svalue1" : "25.0",
"switchType" : "X10 Siren",
"unit" : 1
}
As you can see, I'm changing the nvalue to 1 (and svalue 25, but you can ignore that for now).
The
domoticz/out confirms that Domoticz did receive the message and is republishing it instantly.
When I go back to my interface and I refresh my 'Switch' page, I see that my changes are done correctly.
So what's the slow part exactly?
Same applies, if I click on a switch in the Domoticz interface to turn it on/off, I see a instant domoticz/out message