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
#8
(20.05.2020, 18:58)Erwin van der Zwart Wrote: Hi,

There is already a lib in the Wiser 2.4 firmware however i don't think it's the most recent version as 2.4 is out for quite a while.

I'm currently testing on FW 2.5 that will be released (don't pinpoint me on it) somewhere around this summer, and all features that are in Daniels latest script work on FW 2.5 including the broker app.

So you need to wait a couple of weeks (:

BR,

Erwin

(21.05.2020, 07:21)Daniel. Wrote: I just tried this script
https://forum.logicmachine.net/showthrea...6#pid16896
on SL with fw 2.4.0 and it works just fine. I used broker on LM.
Hello
Thanks Erwin for the information on the fw update. While the update arrives I will do some more tests.

Hellol Daniel.
Thanks for answering.
I have activated user and password in the mosquito broker, I have copied the script that you indicate and changed ip, user, password and port (1883 is where mosquitto runs on my PC).
I use the MQTT.fx client and post both topic in / topic1 and out / topic1.
I subscribe with the same MQTT.fx and with mosquitto_sub and it works perfectly, but I don't see any changes in the wiser.
In the register tab I see that it does not connect to the broker, put this.

* string: mqtt connect failed Operation timed out
This is the script (I remove the password).
Code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
if not broker then   socket = require('socket')   json = require('json')   broker = '192.168.0.12'   port = 1883   username = 'wiser'   password = 'mypassword'   -- topic to object map   mqtt_to_object = {     ['in/topic1'] = {       addr = '1/0/0',       convert = json.pdecode,     },     ['in/topic2'] = {       addr = '1/0/19',     }   }   -- object to topic map   object_to_mqtt = {     ['1/0/0'] = {       topic = 'out/topic1',       qos = 1,       retain = true,       convert = json.encode,     },     ['1/0/19'] = {       topic = 'out/topic2',     }   }   datatypes = {}   grp.sender = 'mq'   for addr, _ in pairs(object_to_mqtt) do     local obj = grp.find(addr)     if obj then       datatypes[ addr ] = obj.datatype     end   end   mclient = require('mosquitto').new()   mclient.ON_CONNECT = function(res, ...)     log('mqtt connect status', res, ...)     if res then       for topic, _ in pairs(mqtt_to_object) do         mclient:subscribe(topic)       end     else       mclient:disconnect()     end   end   mclient.ON_MESSAGE = function(mid, topic, payload)     local map = mqtt_to_object[ topic ]     if map then       if map.convert then         payload = map.convert(payload)       end       grp.write(map.addr, payload)     end   end   mclient.ON_DISCONNECT = function(...)     log('mqtt disconnect', ...)     mclientfd = nil   end   function mconnect()     local status, rc, msg, fd     status, rc, msg = mclient:connect(broker, port)     if not status then       log('mqtt connect failed ' .. tostring(msg))     end     fd = mclient:socket()     if fd then       mclientfd = fd     end   end   mclient:tls_insecure_set(true)   mclient:login_set(username, password or '')   mconnect()   function publishvalue(event)     -- message from us or client is not connected     if event.sender == 'mq' or not mclientfd then       return     end     local addr = event.dst     local dpt = datatypes[ addr ]     local map = object_to_mqtt[ addr ]     -- unknown object     if not dpt or not map then       return     end     local value = busdatatype.decode(event.datahex, dpt)     if value ~= nil then       if map.convert then         value = map.convert(value)       elseif type(value) == 'boolean' then         value = value and 1 or 0       end       mclient:publish(map.topic, tostring(value), map.qos or 0, map.retain)     end   end   lbclient = require('localbus').new(1)   lbclient:sethandler('groupwrite', publishvalue)   lbclientfd = socket.fdmaskset(lbclient:getfd(), 'r')   -- run timer every 5 seconds   timer = require('timerfd').new(5)   timerfd = socket.fdmaskset(timer:getfd(), 'r') end -- mqtt connected if mclientfd then   mclientfdset = socket.fdmaskset(mclientfd, mclient:want_write() and 'rw' or 'r')   res, lbclientstat, timerstat, mclientstat =       socket.selectfds(10, lbclientfd, timerfd, mclientfdset) -- mqtt not connected else   res, lbclientstat, timerstat =     socket.selectfds(10, lbclientfd, timerfd) end if mclientstat then   if socket.fdmaskread(mclientstat) then     mclient:loop_read()   end   if socket.fdmaskwrite(mclientstat) then     mclient:loop_write()   end end if lbclientstat then   lbclient:step() end if timerstat then   -- clear armed timer   timer:read()   if mclientfd then     mclient:loop_misc()   else     mconnect()   end end
The port number should not be between ''?
He does not put them in the thread from which he copies it.
Thank you very much for the help.
Greetings
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: