Logic Machine Forum
[OLD] LogicMachine firmware 2020.07 - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: Announcements (https://forum.logicmachine.net/forumdisplay.php?fid=7)
+--- Forum: Software updates (https://forum.logicmachine.net/forumdisplay.php?fid=13)
+--- Thread: [OLD] LogicMachine firmware 2020.07 (/showthread.php?tid=2710)

Pages: 1 2 3 4 5


RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - johanax - 26.01.2021

(26.01.2021, 10:58)Daniel. Wrote: Just enable MQTT without encryption in the app and set MQTT explorer like this. If it won't connect then most likely it is firewall.

Hi Daniel,
this is exactly the set setup that I have, but I have tried to connect from my LAN (inside the firewall).

Regards Johan

(26.01.2021, 10:52)admin Wrote: Post full listing of your test script.

Code:
if not broker then
  broker = '127.0.0.1.'

  function multiply(mult)
    return function(value)
      local num = tonumber(value)
      if num then
        return num * mult
      else
        return value
      end
    end
  end

  -- topic to object map
  mqtt_to_object = {
    ['in/topic1'] = '1/1/1',
    ['in/topic2'] = '1/1/2',
  }

  -- optional topic value conversion function
  mqtt_to_object_conv = {
    ['in/topic1'] = multiply(100),
    ['in/topic2'] = multiply(0.01),
  }

  -- object to topic map
  object_to_mqtt = {
    ['1/1/1'] = 'out/topic1',
    ['1/1/2'] = 'out/topic2',
  }

  datatypes = {}

  grp.sender = 'mq'
  require('socket')

  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_LOG = log

  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 addr = mqtt_to_object[ topic ]
    if addr then
      local fn = mqtt_to_object_conv[ topic ]

      if fn then
        payload = fn(payload)
      end

      grp.write(addr, payload)
    end
  end

  mclient.ON_DISCONNECT = function(...)
    log('mqtt disconnect', ...)
    mclientfd = nil
  end

  function mconnect()
    local fd

    mclient:connect(broker)
    fd = mclient:socket()

    -- fd ref is valid
    if fd then
      mclientfd = fd
    end
  end

  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 topic = object_to_mqtt[ addr ]

    -- unknown object
    if not dpt or not topic then
      return
    end

    local value = busdatatype.decode(event.datahex, dpt)
    if value ~= nil then
      if type(value) == 'boolean' then
        value = value and 1 or 0
      end

      mclient:publish(topic, tostring(value))
    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 mclientfd and 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



RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - Daniel - 26.01.2021

I meant PC firewall.


RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - johanax - 26.01.2021

Hi again, 
I get some MQTT errors from Mosaic, see below.




RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - admin - 26.01.2021

You have an extra dot in the broker address: broker = '127.0.0.1.'


RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - johanax - 26.01.2021

(26.01.2021, 12:31)admin Wrote: You have an extra dot in the broker address: broker = '127.0.0.1.'

Thanks, works perfect now

(26.01.2021, 12:26)Daniel. Wrote: I meant PC firewall.

Thanks, will check that


RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - tuxtof - 01.04.2021

I try to wake up this thread

hope everybody is safe

do you know when we will have a chance to see an official release ?

Cheers


RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - admin - 01.04.2021

Next week we're publishing new firmware beta version.


RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - tuxtof - 01.04.2021

and GA ??

personally i'm not confortable to put a beta on a working home !!!!


RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - balatis - 07.04.2021

hello everyone please give us more information about the synchronization between the new mosiac beta and the cloud of logic machine, also give us more information about the mqtt app. After of the beta update how can i sync with the cloud???

      Best regards,
            Chris Balatis


RE: [PRE-RELEASE 3] LogicMachine firmware 2020.07 - Daniel - 08.04.2021

(07.04.2021, 19:02)balatis Wrote: hello everyone please give us more information about the synchronization between the new mosiac beta and the cloud of logic machine, also give us more information about the mqtt app. After of the beta update how can i sync with the cloud???

      Best regards,
            Chris Balatis

https://forum.logicmachine.net/showthread.php?tid=3263&pid=21069#pid21069