Example - Modbus Ingestor

Example - TCP Modbus Ingestor

This ingestor will start a TCP Modbus listener that will poll 192.168.2.10 on port 502 every 15 seconds with a read coils (function code 0x01) request to address 0 and slave_id 255. The output of the listener ([]byte) is then passed directly to the template translator via the passthrough handler. The translator then uses the template ('script' field) to generate an EdgeIQ Report.

Ingestor JSON:

{
  "name": "webrelay ingestor - fan",
  "cloud_ingestor": false,
  "device_ids": [
    "5984ce31f1f179e7c826b555"
  ],

  "listener_type": "tcp_modbus",
  "listener": {
    "host": "192.168.2.10",
    "port": 502,
    "poll_interval": 15,
    "timeout": 2,
    "params": {
      "request_type": "read_coils",
      "address": "0",
      "slave_id": 255,
      "quantity": 1
    }
  },
  
  "handler_type": "passthrough",
  
  "translator": {
    "name": "webrelay translator - fan",
    "cloud_translator": false,
    "type": "template",
    "script": "{\"device_id\":\"webrelay-device-9458\", \"payload\":{\"coil_status\": {{.output}}}}"
  }
}

Generated EdgeIQ Report JSON:

{
  "device_id": "webrelay-device-9458",
  "payload": {
    "coil_status": [1] 
  }
}

NOTE: The result ({{.output}}) from the read coils command will be [1] when the coil is on and [0] when it's off.


Did this page help you?