10.07.2024, 08:25
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:
while my LM script gets an log saying "connect failed: Lookup error".
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?
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?