This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Uuable to connect to MQTT Broker
#1
Hi!

In our project we have homeassistant MQTT Broker and I am trying to use it from LM.

While I can connect to the same broker from my PC as follows, with LM I am getting an log saying "connect failed: Lookup error".

mosquitto command from my PC terminal is working fine as follows:
Code:
mosquitto_pub -h homeassistant.local -t "test/topic" -m "aaa_message" -u mqtt -P 0000 -q 1 -r

while my LM script gets an log saying "connect failed: Lookup error".

Code:
broker = 'homeassistant.local'
port = 1883
username = 'mqtt'
password = '0000'
topic = 'lm/test/1'
payload ="aaa_message"

mqtt = require('mosquitto')
client = mqtt.new()
client.ON_CONNECT = function(status, rc, msg)
  if status then
    log('mqtt connected')
    client:publish(topic, tostring(payload))
  else
    log('mqtt connect failed ' .. tostring(msg))
    client:disconnect()
  end
end
client.ON_PUBLISH = function()
  client:disconnect()
end
client:login_set(username, password)
status, rc, msg = client:connect(broker, port)
if status then
  client:loop_forever()
else
  log('connect failed: ' .. tostring(msg))
end


I have two questions:
1. Why is my LM script not working while I can publish message on my PC successfully?
2. I know LM can be MQTT Broker itself but I am trying to use homeassistant MQTT Broker in order to reduce the CPU/IO of LM. We are trying to provide a function for our client to send MQTT message to control facilities that we automate with KNX. Do you think this is effective to reduce CPU/IO of LM?
Reply
#2
LM won't resolve *.local addresses, use an IP address instead. Are you sure that the MQTT broker is causing high CPU load? Install the System load app on LM and sort the list by CPU usage to find out.
Reply
#3
Thank you !
I use IP address instead and I checked the load with System load app.
As you told me, even when I use LM MQTT broker it does not cause the high load.
Therefore I am using LM MQTT broker now : ) Thank you so much for you help!
Reply


Forum Jump: