A .NET application that bridges gsender events to MQTT, allowing you to integrate your gsender machine with MQTT-based home automation systems or other IoT applications. Remote mode must be enabled on gsender.
- Connects to gsender via Socket.IO
- Publishes events to an MQTT broker
- Configurable event filtering
- Automatic reconnection handling
- Docker support
- Environment-based configuration
The application can publish the following types of events to MQTT:
- Status events (connection state)
- Startup events
- Serial port events
- Controller events
- Feeder events
- Sender events
- Workflow events
- Configuration events
- Error events
- File events
- Job events
- Homing events
- G-code error events
The application can be configured using environment variables:
Variable | Description | Default |
---|---|---|
SERVERURL |
URL of the gsender server | http://localhost:8000 |
MQTTSERVER |
MQTT broker hostname | localhost |
MQTTPORT |
MQTT broker port | 1883 |
MQTTUSERNAME |
MQTT username | - |
MQTTPASSWORD |
MQTT password | - |
MQTTTOPIC |
Base MQTT topic | gsender |
MQTTCLIENTID |
MQTT client ID | gsender2mqtt |
RETRYDELAY |
Delay between reconnection attempts (ms) | 60000 |
INCLUDEALL |
Include all events | true |
INCLUDESTARTUP |
Include startup events | false |
INCLUDESERIALPORT |
Include serial port events | false |
INCLUDECONTROLLER |
Include controller events | false |
INCLUDEFEEDER |
Include feeder events | false |
INCLUDESENDER |
Include sender events | false |
INCLUDEWORKFLOW |
Include workflow events | false |
INCLUDECONFIG |
Include configuration events | false |
INCLUDEERROR |
Include error events | false |
INCLUDEFILE |
Include file events | false |
INCLUDEJOB |
Include job events | false |
INCLUDEHOMING |
Include homing events | false |
INCLUDEGCODEERROR |
Include G-code error events | false |
- Build the Docker image:
docker build -t gsender2mqtt .
- Run the container:
docker run -d \
-e SERVERURL=http://your-gsender-server:8000 \
-e MQTTSERVER=your-mqtt-broker \
-e MQTTPORT=1883 \
-e MQTTUSERNAME=your-username \
-e MQTTPASSWORD=your-password \
-e MQTTTOPIC=gsender \
-e MQTTCLIENTID=gsender2mqtt \
gsender2mqtt
- Install .NET 9.0 SDK
- Clone the repository
- Build the project:
dotnet build
- Run the application:
dotnet run
Events are published to MQTT topics in the following format:
{MQTTTOPIC}/{event_type}
For example:
gsender/status
- Connection statusgsender/startup
- Startup eventsgsender/serialport
- Serial port eventsgsender/controller
- Controller eventsgsender/feeder
- Feeder eventsgsender/sender
- Sender eventsgsender/workflow
- Workflow events
The project includes example data files in the ExampleData
directory that demonstrate the format of various events. These examples can be useful for testing and understanding the event structure:
status
- Shows connection status events (e.g., "disconnected")startup
- Contains startup configuration including loaded controllers and available portsfile.load
- Example of file loading eventsjob:start
- Example of job start eventsgcode_error
- Example of G-code error eventshoming:flag
- Example of homing eventsconfig:change
- Example of configuration change eventsgrbleHal:info
- Example of controller information eventssender:status
- Example of sender status events
These example files can be used to test your MQTT integration or to understand the expected format of different event types.
MIT