Skip to content

Commit e1662f7

Browse files
authored
Add a virtual color sensor. (#48)
1 parent 19ff960 commit e1662f7

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,5 @@
140140
}
141141
},
142142
"short_name": "Virtual",
143-
"version": "0.7.1"
143+
"version": "0.7.2"
144144
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "virtual-things-adapter",
33
"display_name": "Virtual Things",
4-
"version": "0.7.1",
4+
"version": "0.7.2",
55
"description": "Mozilla WebThings Gateway Virtual Things Adapter",
66
"main": "index.js",
77
"scripts": {

virtual-things-adapter.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ function on() {
107107
};
108108
}
109109

110-
function color() {
110+
function color(readOnly = false) {
111111
return {
112112
name: 'color',
113113
value: '#ffffff',
114114
metadata: {
115115
title: 'Color',
116116
type: 'string',
117117
'@type': 'ColorProperty',
118+
readOnly,
118119
},
119120
};
120121
}
@@ -911,6 +912,17 @@ const lock = {
911912
events: [],
912913
};
913914

915+
const colorSensor = {
916+
'@context': 'https://iot.mozilla.org/schemas',
917+
'@type': ['ColorSensor'],
918+
name: 'Virtual Color Sensor',
919+
properties: [
920+
color(true),
921+
],
922+
actions: [],
923+
events: [],
924+
};
925+
914926
if (ffmpegMajor !== null && ffmpegMajor >= 4) {
915927
videoCamera.properties[0].metadata.links.push({
916928
rel: 'alternate',
@@ -946,6 +958,7 @@ const VIRTUAL_THINGS = [
946958
colorControl,
947959
thermostat,
948960
lock,
961+
colorSensor,
949962
];
950963

951964
/**

0 commit comments

Comments
 (0)