Skip to content

Feat/mqtt integration#680

Draft
jona159 wants to merge 8 commits intodevfrom
feat/mqtt-integration
Draft

Feat/mqtt integration#680
jona159 wants to merge 8 commits intodevfrom
feat/mqtt-integration

Conversation

@jona159
Copy link
Contributor

@jona159 jona159 commented Jan 4, 2026

This PR includes:

To test this branch with the mqtt service, clone the mqtt service repo and create the .env file.
Run npm run dev to run the service.
On the api side create a test device with sensors and add an mqtt integration, e.g. like:

const [integration] = await client
		.insert(mqttIntegration)
		.values({
			enabled: true,
			url: 'mqtt://test.mosquitto.org', // Public test broker
			topic: `opensensemap/test/${testDevice.id}`,
			messageFormat: 'json',
			decodeOptions: null,
			connectionOptions: {
				keepalive: 60,
				connectTimeout: 5000,
			},
			deviceId: testDevice.id,
		})
		.returning()

await client.insert(deviceToIntegrations).values({
		deviceId: testDevice.id,
		mqttIntegrationId: integration.id,
	})

Afterwards install mosquitto, e.g. on ubuntu:
sudo apt install mosquitto mosquitto-clients -y

and run e.g.:

mosquitto_pub -h test.mosquitto.org \
  -t "opensensemap/test/_DEVICE_ID" \
  -m '{"SENSOR_ID_1": 3.5, "SENSOR_ID_2": 95}'

The logs should indicate if it worked and the measurements should be saved to the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant