Denver e-Ribbon Fire

Denver e-Ribbon Fire control from LogicMachine #

Task #

This example will show how to integrate/control Decoflame’s Denver e-Ribbon bio fireplace system into LogicMachine.

Connection to the Denver e-Ribbon fire system is done over RS-232 port.

Common function for sending data to fireplace burner #

Add the following code to Scripting > Common Functions:

function firesend(dev, req)
  local port, b1, b2, cs, data, res, err

  -- checksum calculation
  function getcs(b1, b2)
    return 0xFF - bit.band(b1 + b2, 0xFF)
  end

  require('serial')
  port = serial.open(dev, { baudrate = 19200 })

  -- get two bytes from request
  b1 = bit.rshift(req, 8)
  b1 = bit.band(b1, 0xFF)
  b2 = bit.band(req, 0xFF)

  -- calculate checksum
  cs = getcs(b1, b2)

  -- send data
  data = string.char(0x01, b1, b2, cs, 0x04)
  port:flush()
  port:write(data)

  -- wait for reply
  res, err = port:read(#data, 1)
  port:close()

  -- valid reply
  if type(res) == 'string' and #res == #data then
    b1, b2, cs = res:byte(2, 4)

    -- verify checksum
    if cs == getcs(b1, b2) then
      return b1, b2
    -- invalid checksum
    else
      return nil, 'invalid checksum'
    end
  -- no reply or invalid reply
  else
    return nil, err
  end
end

Send commands to fireplace burner #

Add control objects in LogicMachine and specify separate Event-based scripts for each control grp address. The following example sends the "flame5" command.

firesend('/dev/RS232', 0x0005)

Status of the fireplace burner #

The burner can return statuses based on specific commands e.g. fuel level.

Add the following code to Scripting > Common Functions:

function getfirestatus(port, data)
  local b1, b2 = firesend(port, data)
  if b1 then
    b1 = bit.band(b1, 0x0F)
    b1 = bit.lshift(b1, 8)
    return bit.bor(b1, b2)
  end
end

Add a resident script with necessary sleep time interval to update respective group addresses with the burner status.

-- fuel level status
fuel = getfirestatus('/dev/RS232', 0x9000)
if fuel then
  grp.update('1/1/1', fuel)
end