Skip to content

Commit

Permalink
Simplify interface for getDeviceFactory
Browse files Browse the repository at this point in the history
Get the kind from the class
  • Loading branch information
gcampax committed Oct 18, 2019
1 parent bc7fefc commit 1337835
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 7 additions & 7 deletions lib/device_factory_utils.js
Expand Up @@ -70,15 +70,15 @@ function makeDeviceFactory(classDef, device) {
return {
type: 'discovery',
category: device.category,
kind: device.primary_kind,
kind: classDef.kind,
text: device.name,
discoveryType: 'bluetooth'
};
case 'org.thingpedia.config.discovery.upnp':
return {
type: 'discovery',
category: device.category,
kind: device.primary_kind,
kind: classDef.kind,
text: device.name,
discoveryType: 'upnp'
};
Expand All @@ -87,15 +87,15 @@ function makeDeviceFactory(classDef, device) {
return {
type: 'interactive',
category: device.category,
kind: device.primary_kind,
kind: classDef.kind,
text: device.name
};

case 'org.thingpedia.config.none':
return {
type: 'none',
category: device.category,
kind: device.primary_kind,
kind: classDef.kind,
text: device.name
};

Expand All @@ -104,15 +104,15 @@ function makeDeviceFactory(classDef, device) {
return {
type: 'oauth2',
category: device.category,
kind: device.primary_kind,
kind: classDef.kind,
text: device.name
};

case 'org.thingpedia.config.form':
return {
type: 'form',
category: device.category,
kind: device.primary_kind,
kind: classDef.kind,
text: device.name,
fields: toFields(getInputParam(config, 'params'))
};
Expand All @@ -121,7 +121,7 @@ function makeDeviceFactory(classDef, device) {
return {
type: 'form',
category: device.category,
kind: device.primary_kind,
kind: classDef.kind,
text: device.name,
fields: [
{ name: 'username', label: 'Username', type: 'text' },
Expand Down
6 changes: 0 additions & 6 deletions test/test_device_factories.js
Expand Up @@ -19,7 +19,6 @@ const TEST_CASES = [
import loader from @org.thingpedia.v2();
import config from @org.thingpedia.config.none();
}`, {
primary_kind: "com.bing",
name: "Bing Search",
category: 'data',
}, {
Expand All @@ -33,7 +32,6 @@ const TEST_CASES = [
import loader from @org.thingpedia.v2();
import config from @org.thingpedia.config.basic_auth(extra_params=makeArgMap(serial_number : String));
}`, {
primary_kind: "com.bodytrace.scale",
name: "BodyTrace Scale",
category: 'physical',
}, {
Expand Down Expand Up @@ -69,7 +67,6 @@ const TEST_CASES = [
import loader from @org.thingpedia.v2();
import config from @org.thingpedia.config.custom_oauth();
}`, {
primary_kind: "com.twitter",
name: "Twitter Account",
category: 'online',
}, {
Expand All @@ -83,7 +80,6 @@ const TEST_CASES = [
import loader from @org.thingpedia.v2();
import config from @org.thingpedia.config.oauth2(client_id="foo", client_secret="bar");
}`, {
primary_kind: "com.linkedin",
name: "LinkedIn Account",
category: 'online',
}, {
Expand All @@ -97,7 +93,6 @@ const TEST_CASES = [
import loader from @org.thingpedia.v2();
import config from @org.thingpedia.config.discovery.upnp(search_target=['urn:lge:com:service:webos:second-screen-1']);
}`, {
primary_kind: "com.lg.tv.webos2",
name: "LG TV",
category: 'physical',
}, {
Expand All @@ -112,7 +107,6 @@ const TEST_CASES = [
import loader from @org.thingpedia.v2();
import config from @org.thingpedia.config.discovery.bluetooth(uuids=['0000110b-0000-1000-8000-00805f9b34fb']);
}`, {
primary_kind: "org.thingpedia.bluetooth.speaker.a2dp",
name: "Bluetooth Speaker",
category: 'physical',
}, {
Expand Down

0 comments on commit 1337835

Please sign in to comment.