Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add milesight new sensors #682

Merged
merged 6 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .Makefile.swp
Binary file not shown.
320 changes: 252 additions & 68 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"homepage": "https://github.com/TheThingsNetwork/lorawan-devices#readme",
"devDependencies": {
"ajv": "^6.12.6",
"ajv-cli": "^0.6.0",
"ajv-cli": "^5.0.0",
"prettier": "^2.6.2"
},
"dependencies": {
Expand Down
14 changes: 14 additions & 0 deletions vendor/milesight-iot/am103-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Uplink decoder decodes binary data uplink into a JSON object
uplinkDecoder:
fileName: am103.js
examples:
- description: Ambience Monitoring Sensors (example 1) - Milesight IoT
input:
fPort: 85
bytes: [0x01, 0x75, 0x5C, 0x03, 0x67, 0x34, 0x01, 0x04, 0x68, 0x65, 0x07, 0x7D, 0xE7, 0x04]
output:
data:
battery: 92
temperature: 30.8
humidity: 50.5
co2: 1255
92 changes: 92 additions & 0 deletions vendor/milesight-iot/am103.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

function decodeUplink(input) {
var res = Decoder(input.bytes, input.fPort);
if (res.error) {
return {
errors: [res.error],
};
}
return {
data: res,
};
}

/**
* Payload Decoder for The Things Network
*
* Copyright 2021 Milesight IoT
*
* @product AM104 / AM107
*/
function Decoder(bytes, port) {
var decoded = {};

for (var i = 0; i < bytes.length;) {
var channel_id = bytes[i++];
var channel_type = bytes[i++];
// BATTERY
if (channel_id === 0x01 && channel_type === 0x75) {
decoded.battery = bytes[i];
i += 1;
}
// TEMPERATURE
else if (channel_id === 0x03 && channel_type === 0x67) {
// ℃
decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10;
i += 2;

// ℉
// decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10 * 1.8 + 32;
// i +=2;
}
// HUMIDITY
else if (channel_id === 0x04 && channel_type === 0x68) {
decoded.humidity = bytes[i] / 2;
i += 1;
}
// PIR
else if (channel_id === 0x05 && channel_type === 0x6A) {
decoded.activity = readUInt16LE(bytes.slice(i, i + 2));
i += 2;
}
// LIGHT
else if (channel_id === 0x06 && channel_type === 0x65) {
decoded.illumination = readUInt16LE(bytes.slice(i, i + 2));
decoded.infrared_and_visible = readUInt16LE(bytes.slice(i + 2, i + 4));
decoded.infrared = readUInt16LE(bytes.slice(i + 4, i + 6));
i += 6;
}
// CO2
else if (channel_id === 0x07 && channel_type === 0x7D) {
decoded.co2 = readUInt16LE(bytes.slice(i, i + 2));
i += 2;
}
// TVOC
else if (channel_id === 0x08 && channel_type === 0x7D) {
decoded.tvoc = readUInt16LE(bytes.slice(i, i + 2));
i += 2;
}
// PRESSURE
else if (channel_id === 0x09 && channel_type === 0x73) {
decoded.pressure = readUInt16LE(bytes.slice(i, i + 2)) / 10;
i += 2;
} else {
break;
}
}

return decoded;
}

/* ******************************************
* bytes to number
********************************************/
function readUInt16LE(bytes) {
var value = (bytes[1] << 8) + bytes[0];
return value & 0xffff;
}

function readInt16LE(bytes) {
var ref = readUInt16LE(bytes);
return ref > 0x7fff ? ref - 0x10000 : ref;
}
Binary file added vendor/milesight-iot/am103.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 116 additions & 0 deletions vendor/milesight-iot/am103.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Milesight AM103-LoRaWAN Indoor Air Quality Sensor (3 in 1)
description: Milesight AM103 is a compact indoor ambience monitoring sensor that supports long-lasting battery life, wall-mounted installation, and visual display via an E-ink screen. Meanwhile, AM103L is a more economical model without E-ink screen to meet your various needs. Their built-in NFC lead to easy batch installation. The clean and modern design of AM103 and AM103L is ideal for offices, classrooms, libraries, hospitals, etc.

hardwareVersions:
- version: '1.x'
numeric: 1

firmwareVersions:
- version: '1.x'
numeric: 1
hardwareVersions:
- '1.x'

profiles:
EU863-870:
id: profile-eu868
lorawanCertified: true
codec: am103-codec
US902-928:
id: profile-us915
lorawanCertified: true
codec: am103-codec
AU915-928:
id: profile-au915
lorawanCertified: true
codec: am103-codec
AS923:
id: profile-as923
lorawanCertified: true
codec: am103-codec
CN470-510:
id: profile-cn470
lorawanCertified: true
codec: am103-codec
KR920-923:
id: profile-kr920
lorawanCertified: true
codec: am103-codec
IN865-867:
id: profile-in865
lorawanCertified: true
codec: am103-codec
RU864-870:
id: profile-ru864
lorawanCertified: true
codec: am103-codec

sensors:
- battery
- temperature
- humidity
- co2

dimensions:
width: 20.5
length: 68
height: 65

battery:
replaceable: true
type: ER14505

operatingConditions:
temperature:
min: -20
max: 60

relativeHumidity:
min: 0
max: 0.95

ipCode: IP30

keyProvisioning:
- custom
- join server
keySecurity: none
productURL: https://www.milesight-iot.com/lorawan/sensor/am103/?utm_source=platform&utm_medium=web&utm_campaign=milesight
dataSheetURL: https://resource.milesight-iot.com/milesight/document/am100-series-datasheet-en.pdf
resellerURLs:
- name: '[email protected]'
region:
- United States
- European Union
- Canada
url: https://www.alibaba.com/product-detail/AM103-AM103L-Temperature-and-Humidity-Sensor_1600552633106.html?spm=a2700.galleryofferlist.normal_offer.d_title.40bd4794jPiLIT

photos:
main: am103.png

compliances:
safety:
- body: IEC
norm: EN
standard: 62368-1
radioEquipment:
- body: ETSI
norm: EN
standard: 300 220-1
version: 3.1.1
- body: ETSI
norm: EN
standard: 300 220-2
version: 2.2.1
- body: ETSI
norm: EN
standard: 301 489-1
version: 2.2.3
- body: ETSI
norm: EN
standard: 301 489-3
version: 2.1.1
- body: ETSI
norm: EN
standard: 300 330
version: 2.1.1
14 changes: 14 additions & 0 deletions vendor/milesight-iot/am103l-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Uplink decoder decodes binary data uplink into a JSON object
uplinkDecoder:
fileName: am103l.js
examples:
- description: Ambience Monitoring Sensors (example 1) - Milesight IoT
input:
fPort: 85
bytes: [0x01, 0x75, 0x5C, 0x03, 0x67, 0x34, 0x01, 0x04, 0x68, 0x65, 0x07, 0x7D, 0xE7, 0x04]
output:
data:
battery: 92
temperature: 30.8
humidity: 50.5
co2: 1255
92 changes: 92 additions & 0 deletions vendor/milesight-iot/am103l.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

function decodeUplink(input) {
var res = Decoder(input.bytes, input.fPort);
if (res.error) {
return {
errors: [res.error],
};
}
return {
data: res,
};
}

/**
* Payload Decoder for The Things Network
*
* Copyright 2021 Milesight IoT
*
* @product AM104 / AM107
*/
function Decoder(bytes, port) {
var decoded = {};

for (var i = 0; i < bytes.length;) {
var channel_id = bytes[i++];
var channel_type = bytes[i++];
// BATTERY
if (channel_id === 0x01 && channel_type === 0x75) {
decoded.battery = bytes[i];
i += 1;
}
// TEMPERATURE
else if (channel_id === 0x03 && channel_type === 0x67) {
// ℃
decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10;
i += 2;

// ℉
// decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10 * 1.8 + 32;
// i +=2;
}
// HUMIDITY
else if (channel_id === 0x04 && channel_type === 0x68) {
decoded.humidity = bytes[i] / 2;
i += 1;
}
// PIR
else if (channel_id === 0x05 && channel_type === 0x6A) {
decoded.activity = readUInt16LE(bytes.slice(i, i + 2));
i += 2;
}
// LIGHT
else if (channel_id === 0x06 && channel_type === 0x65) {
decoded.illumination = readUInt16LE(bytes.slice(i, i + 2));
decoded.infrared_and_visible = readUInt16LE(bytes.slice(i + 2, i + 4));
decoded.infrared = readUInt16LE(bytes.slice(i + 4, i + 6));
i += 6;
}
// CO2
else if (channel_id === 0x07 && channel_type === 0x7D) {
decoded.co2 = readUInt16LE(bytes.slice(i, i + 2));
i += 2;
}
// TVOC
else if (channel_id === 0x08 && channel_type === 0x7D) {
decoded.tvoc = readUInt16LE(bytes.slice(i, i + 2));
i += 2;
}
// PRESSURE
else if (channel_id === 0x09 && channel_type === 0x73) {
decoded.pressure = readUInt16LE(bytes.slice(i, i + 2)) / 10;
i += 2;
} else {
break;
}
}

return decoded;
}

/* ******************************************
* bytes to number
********************************************/
function readUInt16LE(bytes) {
var value = (bytes[1] << 8) + bytes[0];
return value & 0xffff;
}

function readInt16LE(bytes) {
var ref = readUInt16LE(bytes);
return ref > 0x7fff ? ref - 0x10000 : ref;
}
Binary file added vendor/milesight-iot/am103l.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading