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.

MqTT in Wiser for KNX
#16
If you don't have a lot of frequent updates you can use event script to publish new values then disconnect.

Add to Common functions and change username/password:
Code:
function mqttpublish(topic, data)
  local broker = 'mqtt.eniris.be'

  local username = 'xxx'
  local password = 'xxx'

  local port = 1883

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

  if type(data) == 'table' then
    data = require('json').encode(data)
  end

  client.ON_CONNECT = function(status, rc, msg)
    if status then
      log('mqtt cloud connected')
      client:publish(topic, data)
    else
      log('mqtt cloud connect failed ' .. tostring(msg))
      client:disconnect()
    end
  end

  client.ON_PUBLISH = function()
    log('disconnecting')
    client:disconnect()
  end

  client:login_set(username, password)
  local status, rc, msg = client:connect(broker, port)

  if status then
    client:loop_forever()
  else
    log('cloud connect failed: ' .. tostring(msg))
  end
end

Event script example:
Code:
topic = 'Actual Temp/Hal A/S2'
data = {
  time = os.time(),
  extraTags = {
    subId = 'T19'
  },
  fields = {
    temperature_degC = event.getvalue()
  }
}

mqttpublish(topic, data)
Reply


Messages In This Thread
MqTT in Wiser for KNX - by JRP - 20.05.2020, 12:11
RE: MqTT in Wiser for KNX - by Daniel - 20.05.2020, 12:40
RE: MqTT in Wiser for KNX - by JRP - 20.05.2020, 13:55
RE: MqTT in Wiser for KNX - by Daniel - 20.05.2020, 13:59
RE: MqTT in Wiser for KNX - by JRP - 20.05.2020, 18:34
RE: MqTT in Wiser for KNX - by Daniel - 21.05.2020, 07:21
RE: MqTT in Wiser for KNX - by JRP - 21.05.2020, 10:40
RE: MqTT in Wiser for KNX - by Daniel - 21.05.2020, 10:42
RE: MqTT in Wiser for KNX - by JRP - 21.05.2020, 11:20
RE: MqTT in Wiser for KNX - by Daniel - 21.05.2020, 11:22
RE: MqTT in Wiser for KNX - by JRP - 21.05.2020, 11:47
RE: MqTT in Wiser for KNX - by Daniel - 21.05.2020, 11:50
RE: MqTT in Wiser for KNX - by JRP - 21.05.2020, 15:28
RE: MqTT in Wiser for KNX - by admin - 26.08.2022, 10:38
RE: MqTT in Wiser for KNX - by admin - 26.08.2022, 11:06
RE: MqTT in Wiser for KNX - by admin - 26.08.2022, 12:55
RE: MqTT in Wiser for KNX - by JRP - 19.05.2023, 10:18
RE: MqTT in Wiser for KNX - by admin - 19.05.2023, 10:24
RE: MqTT in Wiser for KNX - by JRP - 19.05.2023, 10:42
RE: MqTT in Wiser for KNX - by JRP - 20.05.2023, 17:10
RE: MqTT in Wiser for KNX - by admin - 22.05.2023, 06:52
RE: MqTT in Wiser for KNX - by JRP - 26.05.2023, 08:21

Forum Jump: