Logic Machine Forum
Getting a log value and introduce it in a BacNet object - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Getting a log value and introduce it in a BacNet object (/showthread.php?tid=4398)



Getting a log value and introduce it in a BacNet object - mripoll - 25.11.2022

Hello, i'm new to the LUA language and to the LM interface and i need a bit of help.

Right now i have the following script in wich i get a string from a MQTT Topic and now i want to get that string and send it via BacNet to another system.

broker = '172.30.10.185' -- default port is 1883
username = 'icosaedro' -- device serial
password = 'hola' -- device credentials


topic = "Habitacion_02/a848faf8cb70/status"

mqtt = require('mosquitto')
client = mqtt.new()

client.ON_CONNECT = function(status, rc, err)
  if status then
    log('connect ok')
    client:subscribe(topic)
  else
    log('connect error', rc, err)
  end
end

client.ON_MESSAGE = function(mid, topic, data)
  log('message',topic, data)
end






client:login_set(username, password)
client:connect(broker)
client:loop_forever()


Firts of all i would like to know if i'm doing "Overexcessive" struggle and i can just put the string in a variable and then send it to a bacnet object or how can i get the value from the log and create a bacnet object that i could send later from another software.

Thank you very much!!


RE: Getting a log value and introduce it in a BacNet object - Daniel - 25.11.2022

You have to write your data to object but first you must make sure your data is in correct format for the dpt. Only numeric values work on bacnet in LM. Once this is done just export this object by selecting export option and configure bacnet settings in System config-Network-BACnet settings.