Page 4 of 4

Re: MQTT support in OpenNetHome

Posted: Tue Aug 30, 2016 5:35 am
by krambriw
When I wrote the Adafruit MQTT Client plugin for EventGhost I used the Python library provided by Adafruit https://learn.adafruit.com/adafruit-io/overview. I do send a 'keepalive' every 4th min and this keeps the plugin connected but I think the library also has a built-in keep alive mechanism. Maybe you could use the Node.js library?

While testing by toggling the state of a lamp, I can see that most of the times it works, I do receive an MQTT message (change of state) in my MQTT clients (MQTT.fx as well as EventGhost) but suddenly it stops working. Then again, when the connection has been interrupted for a while and no messages arrived, it suddenly starts working again.

I have a feeling that sometimes the first command is not recognized (at least not received by io.adafruit) but if you hit it again, then io.adafruit receives it and a message also appears in my MQTT clients.

Could it also be that you will have to add a short delay between publishing messages to avoid exceeding the rate limit (2 requests per second or 120 requests within 60 seconds)?

With a "normal" MQTT broker (Mosquitto running in a RPi) it works rock solid I think.

Re: MQTT support in OpenNetHome

Posted: Thu Sep 01, 2016 6:47 am
by krambriw
Just an idea;

A nice feature would be if you could create an item (a Gauge) for the TCP port and select an attribute for 'events' (with format as they are). In this way, it would be really easy to subscribe to all ONH events via MQTT

BR Walter

Re: MQTT support in OpenNetHome

Posted: Sat Sep 03, 2016 5:29 am
by krambriw
Still losing the connection to adafruit every minute

Code: Select all

	16.09.03 05:26:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:25:22	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:24:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:23:24	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:22:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:21:24	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:20:22	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:19:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:18:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:17:24	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:16:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:15:22	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:14:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:13:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:12:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost
	16.09.03 05:11:23	MqttClient$SubscribeCallback	Lost connection to MQTT server tcp://io.adafruit.com: Connection lost

Re: MQTT support in OpenNetHome

Posted: Sat Sep 03, 2016 8:01 pm
by stefangsbb
So, I think I have solved the issue now with lost connections. It seems like the Adafruit MQTT-server does not like multiple clients with the same client name. This might be a bug in their server, but still I think at least me and you (Walter) have been throwing each other out constantly by reconnecting with the same client name.

I have now made the client name configurable and it is somewhat randomized on Item creation, so there is less risk of collision. It is in the nightly build.

Re: MQTT support in OpenNetHome

Posted: Sun Sep 04, 2016 7:05 am
by krambriw
It is working fine now with io.adafruit!

One thought; when you are configuring a MqttvalueLogger/Gauge and you select objects, I think most of the available attributes are really questionable. Whats the meaning having the attribute 'ListenPort' selectable for the TCP port?? It is just static information. The interesting would be to have the events available. For many other objects, a lot of attributes with similar static information is available, I wonder if this has some real value in a MQTT perspective?