You have two distinct issues that need addressing:
Route Config Validation: Your current route only handles ‘sensor’ devices. Update to handle all device types:
{
"routes": {
"toDownstreamSensors": "FROM /messages/* WHERE deviceType = 'sensor' INTO BrokeredEndpoint(/devices/{deviceId}/messages/devicebound)",
"toDownstreamActuators": "FROM /messages/* WHERE deviceType = 'actuator' INTO BrokeredEndpoint(/devices/{deviceId}/messages/devicebound)"
}
}
Or use a single route with OR condition:
{
"routes": {
"toDownstream": "FROM /messages/* WHERE deviceType IN ['sensor', 'actuator'] INTO BrokeredEndpoint(/devices/{deviceId}/messages/devicebound)"
}
}
The IN operator is cleaner when handling multiple device types.
Downstream Device Mapping: Verify your gateway’s config.toml includes the new devices:
[[downstream_devices]]
device_id = "actuator01"
auth_type = "sas_key"
auth_value = "SharedAccessKey=..."
[[downstream_devices]]
device_id = "actuator02"
auth_type = "sas_key"
auth_value = "SharedAccessKey=..."
Each downstream device must be explicitly listed with valid authentication credentials.
Log Analysis: Enable detailed logging to diagnose routing failures:
iotedge logs edgeHub --tail 100
Look for:
- “Route evaluation failed” - indicates condition problems
- “Device not found” - mapping issue
- “Authentication failed” - credential problems
For the new actuator devices, ensure they’re configured to connect through the gateway. On each actuator device, set the gateway hostname:
# In device connection string
HostName=iothub.azure-devices.net;DeviceId=actuator01;SharedAccessKey=...;GatewayHostName=gateway-device.local
The GatewayHostName parameter tells the device to route through your gateway instead of connecting directly to IoT Hub.
After updating routes and device mapping:
- Restart edgeHub: `iotedge restart edgeHub
- Reconnect downstream devices
- Monitor logs: `iotedge logs edgeHub -f
- Test with a command from IoT Hub to verify routing
The root cause is that your route condition didn’t account for the new device type, AND the new devices weren’t properly registered in the gateway’s downstream device list. Both must be configured correctly for message routing to work.