Skip to content

Commit 1869b7f

Browse files
authored
Merge pull request #31 from tago-io/fix/dashboard_match
Fix dashboard retrieval in device registration with connector-based lookup
2 parents e33e6cb + d69a1b5 commit 1869b7f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/services/device/register.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DeviceCreateInfo } from "@tago-io/sdk/lib/types";
44
import { createDashURL } from "../../lib/create-dash-url";
55
import { parseTagoObject } from "../../lib/data.logic";
66
import { fetchDeviceList } from "../../lib/fetch-device-list";
7-
import { getDashboardByTagID } from "../../lib/find-resource";
7+
import { getDashboardByConnectorID } from "../../lib/find-resource";
88
import { initializeValidation } from "../../lib/validation";
99
import { DeviceCreated, RouterConstructorData } from "../../types";
1010

@@ -122,7 +122,12 @@ async function sensorAdd({ context, scope, environment }: RouterConstructorData)
122122

123123
const connector_id = new_dev_type.value as string;
124124

125-
const dash_id = await getDashboardByTagID("hum_dashboard");
125+
let dash_id = "";
126+
try {
127+
({ id: dash_id } = await getDashboardByConnectorID(connector_id));
128+
} catch (error) {
129+
return validate("#VAL.ERROR__NO_DASHBOARD_FOUND#", "danger");
130+
}
126131

127132
const dash_info = await Resources.dashboards.info(dash_id);
128133
const type = dash_info.blueprint_devices.find((bp) => bp.conditions[0].key === "sensor");

0 commit comments

Comments
 (0)