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

WIP: LCD T&H with date/time display #641

Open
wants to merge 7 commits into
base: SDK3
Choose a base branch
from
Open
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
479 changes: 479 additions & 0 deletions drivers/lcd_th_sensor/assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added drivers/lcd_th_sensor/assets/images/large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added drivers/lcd_th_sensor/assets/images/small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
413 changes: 413 additions & 0 deletions drivers/lcd_th_sensor/device.js

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions drivers/lcd_th_sensor/driver.compose.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"id": "lcd_th_sensor",
"name": {
"en": "LCD T&H Sensor"
},
"class": "sensor",
"platforms": ["local"],
"connectivity": ["zigbee"],
"capabilities": [
"measure_temperature",
"measure_humidity",
"measure_battery"
],
"energy": {
"batteries": [
"AAA", "AAA", "AAA"
]
},
"images": {
"large": "{{driverAssetsPath}}/images/large.png",
"small": "{{driverAssetsPath}}/images/small.png"
},
"zigbee": {
"manufacturerName": [
"_TZE200_locansqn"
],
"productId": [
"TS0601"
],
"endpoints": {
"1": {
"clusters": [
0,
4,
5,
10,
25,
61184
],
"bindings": [
4,
5,
10,
25,
61184
]
}
},
"learnmode": {
"instruction": {
"en": "Press the button on the side of the unit for 5 seconds."
}
}
}
}
81 changes: 81 additions & 0 deletions drivers/lcd_th_sensor/driver.settings.compose.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[
{
"id": "temperature_sensitivity",
"type": "number",
"label": {
"en": "Temperature sensitivity (0.X°C)"
},
"hint": {
"en": "Set temperature sensitivity. step size decimal [°C]"
},
"value": 3,
"attr": {
"min": 3,
"max": 10,
"step": 1
}
},
{
"id": "temp_periodic_report",
"type": "number",
"label": {
"en": "Temperature reporting interval in minutes"
},
"value": 1,
"attr": {
"min": 1,
"max": 120,
"step": 1
}
},
{
"id": "humidity_sensitivity",
"type": "number",
"label": {
"en": "Humidity sensitivity"
},
"hint": {
"en": "Set humidity sensitivity. default [6%]"
},
"value": 6,
"attr": {
"min": 3,
"max": 10,
"step": 1
},
"units": {
"en": "%"
}
},
{
"id": "hum_periodic_report",
"type": "number",
"label": {
"en": "Humidity reporting interval in minutes"
},
"value": 1,
"attr": {
"min": 1,
"max": 120,
"step": 1
}
},
{
"id": "temp_unit_convert",
"type": "dropdown",
"value": "c",
"label": {
"en": "Celsius / Fahrenheit"
},
"values": [
{
"id": "c",
"label": { "en": "Celsius" }
},
{
"id": "f",
"label": { "en": "Fahrenheit" }
}
]
}
]
42 changes: 42 additions & 0 deletions drivers/lcd_th_sensor/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const getDataValue = (dpValue) => {
const convertMultiByteNumberPayloadToSingleDecimalNumber = (chunks) => {
let value = 0;

for (let i = 0; i < chunks.length; i++) {
value = value << 8;
value += chunks[i];
}

return value;
};

switch (dpValue.datatype) {
case dataTypes.raw:
return dpValue.data;
case dataTypes.bool:
return dpValue.data[0] === 1;
case dataTypes.value:
return convertMultiByteNumberPayloadToSingleDecimalNumber(dpValue.data);
case dataTypes.string:
let dataString = '';
for (let i = 0; i < dpValue.data.length; ++i) {
dataString += String.fromCharCode(dpValue.data[i]);
}
return dataString;
case dataTypes.enum:
return dpValue.data[0];
case dataTypes.bitmap:
return convertMultiByteNumberPayloadToSingleDecimalNumber(dpValue.data);
}
}

const dataTypes = {
raw: 0, // [ bytes ]
bool: 1, // [0/1]
value: 2, // [ 4 byte value ]
string: 3, // [ N byte string ]
enum: 4, // [ 0-255 ]
bitmap: 5, // [ 1,2,4 bytes ] as bits
};

module.exports = { getDataValue }
3 changes: 1 addition & 2 deletions drivers/lcdtemphumidsensor_3/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"zigbee": {
"manufacturerName": [
"_TZE200_bjawzodf",
"_TZE200_zl1kmjqx",
"_TZE200_locansqn"
"_TZE200_zl1kmjqx"
],
"productId": [
"TS0601"
Expand Down