zigbee-herdsman-converters-snkso
Version:
Collection of device converters to be used with zigbee-herdsman
214 lines • 10.4 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.definitions = void 0;
const exposes = __importStar(require("../lib/exposes"));
const tuya = __importStar(require("../lib/tuya"));
const e = exposes.presets;
const ea = exposes.access;
exports.definitions = [
{
zigbeeModel: ["SNT858Z"],
model: "SNT858Z",
vendor: "Soanalarm",
description: "Soil moisture sensor",
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
configure: tuya.configureMagicPacket,
exposes: [e.temperature(), e.soil_moisture(), tuya.exposes.temperatureUnit(), e.battery()],
meta: {
tuyaDatapoints: [
[3, "soil_moisture", tuya.valueConverter.raw],
[5, "temperature", tuya.valueConverter.raw],
[9, "temperature_unit", tuya.valueConverter.temperatureUnit],
[15, "battery", tuya.valueConverter.raw],
],
},
},
{
fingerprint: tuya.fingerprint("TS0601", ["_TZE204_navtwmd0"]),
model: "SNT857Z-TDE",
vendor: "Soanalarm",
description: "Temperature sensor",
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
configure: tuya.configureMagicPacket,
onEvent: (type, data, device, options, state) => {
if (type === "message" && state) {
if (state.temperature_unit === "fahrenheit" && state.temperature && state.temperature_f === null) {
const tempF = (state.temperature * 9) / 5 + 32;
state.temperature_f = Math.round(tempF * 10) / 10;
}
}
},
exposes: [
e.enum("temperature_unit", ea.STATE_SET, ["celsius", "fahrenheit"]).withDescription("Temperature unit"),
e.numeric("max_temperature", ea.STATE_SET).withUnit("°C").withValueMin(-400).withValueMax(1200).withDescription("Maximum temperature"),
e.numeric("min_temperature", ea.STATE_SET).withUnit("°C").withValueMin(-400).withValueMax(1200).withDescription("Minimum temperature"),
e
.numeric("max_temperature_f", ea.STATE_SET)
.withUnit("°F")
.withValueMin(-760)
.withValueMax(2192)
.withDescription("Maximum temperature in °F"),
e
.numeric("min_temperature_f", ea.STATE_SET)
.withUnit("°F")
.withValueMin(-760)
.withValueMax(2192)
.withDescription("Minimum temperature in °F"),
e.numeric("temperature", ea.STATE).withUnit("°C").withValueMin(0).withValueMax(1000).withDescription("Temperature"),
e.numeric("temperature_f", ea.STATE).withUnit("°F").withValueMin(32).withValueMax(1832).withDescription("Temperature in °F"),
e.enum("temperature_alarm", ea.STATE, ["lower_alarm", "upper_alarm", "cancel"]).withDescription("Temperature alarm"),
e
.numeric("temperature_calibration", ea.STATE_SET)
.withUnit("°C")
.withValueMin(-100)
.withValueMax(100)
.withDescription("Temperature calibration"),
],
meta: {
tuyaDatapoints: [
[1, "temperature", tuya.valueConverter.divideBy10],
[2, "temperature_f", tuya.valueConverter.divideBy10],
[9, "temperature_unit", tuya.valueConverter.temperatureUnit],
[10, "max_temperature", tuya.valueConverter.divideBy10],
[11, "min_temperature", tuya.valueConverter.divideBy10],
[12, "max_temperature_f", tuya.valueConverter.divideBy10],
[13, "min_temperature_f", tuya.valueConverter.divideBy10],
[
14,
"temperature_alarm",
{
from: (value) => {
const lookup = { 0: "cancel", 1: "lower_alarm", 2: "upper_alarm" };
return lookup[value] || "cancel";
},
to: (value) => {
const lookup = { cancel: 0, lower_alarm: 1, upper_alarm: 2 };
return lookup[value];
},
},
],
[23, "temperature_calibration", tuya.valueConverter.divideBy10],
],
},
},
{
fingerprint: tuya.fingerprint("TS0601", ["_TZE204_m9dzckna"]),
model: "SNT857Z",
vendor: "Soanalarm",
description: "Temperature and humidity sensor",
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
configure: tuya.configureMagicPacket,
onEvent: (type, data, device, options, state) => {
if (type === "message" && state) {
if (state.temperature_unit === "fahrenheit" && state.temperature && state.temperature_f === null) {
const tempF = (state.temperature * 9) / 5 + 32;
state.temperature_f = Math.round(tempF * 10) / 10;
}
}
},
exposes: [
e.humidity(),
e.enum("temperature_unit", ea.STATE_SET, ["celsius", "fahrenheit"]).withDescription("Temperature unit"),
e.numeric("max_temperature", ea.STATE_SET).withUnit("°C").withValueMin(-400).withValueMax(1200).withDescription("Maximum temperature"),
e.numeric("min_temperature", ea.STATE_SET).withUnit("°C").withValueMin(-400).withValueMax(1200).withDescription("Minimum temperature"),
e
.numeric("max_temperature_f", ea.STATE_SET)
.withUnit("°F")
.withValueMin(-760)
.withValueMax(2192)
.withDescription("Maximum temperature in °F"),
e
.numeric("min_temperature_f", ea.STATE_SET)
.withUnit("°F")
.withValueMin(-760)
.withValueMax(2192)
.withDescription("Minimum temperature in °F"),
e.numeric("temperature_f", ea.STATE).withUnit("°F").withValueMin(-760).withValueMax(2192).withDescription("Temperature in °F"),
e.numeric("temperature", ea.STATE).withUnit("°C").withValueMin(-400).withValueMax(1200).withDescription("Temperature"),
e.numeric("max_humidity", ea.STATE_SET).withUnit("%").withValueMin(0).withValueMax(1000).withDescription("Alarm humidity max"),
e.numeric("min_humidity", ea.STATE_SET).withUnit("%").withValueMin(32).withValueMax(1832).withDescription("Alarm humidity min"),
e.enum("temperature_alarm", ea.STATE, ["lower_alarm", "upper_alarm", "cancel"]).withDescription("Temperature alarm"),
e.enum("humidity_alarm", ea.STATE, ["lower_alarm", "upper_alarm", "cancel"]).withDescription("Humidity alarm"),
tuya.exposes.temperatureCalibration(),
tuya.exposes.humidityCalibration(),
],
meta: {
tuyaDatapoints: [
[1, "temperature", tuya.valueConverter.divideBy10],
[2, "humidity", tuya.valueConverter.raw],
[9, "temperature_unit", tuya.valueConverter.temperatureUnit],
[10, "max_temperature", tuya.valueConverter.divideBy10],
[11, "min_temperature", tuya.valueConverter.divideBy10],
[12, "max_humidity", tuya.valueConverter.raw],
[13, "min_humidity", tuya.valueConverter.raw],
[
14,
"temperature_alarm",
{
from: (value) => {
const lookup = { 0: "cancel", 1: "lower_alarm", 2: "upper_alarm" };
return lookup[value] || "cancel";
},
to: (value) => {
const lookup = { cancel: 0, lower_alarm: 1, upper_alarm: 2 };
return lookup[value];
},
},
],
[
15,
"humidity_alarm",
{
from: (value) => {
const lookup = { 0: "cancel", 1: "lower_alarm", 2: "upper_alarm" };
return lookup[value] || "cancel";
},
to: (value) => {
const lookup = { cancel: 0, lower_alarm: 1, upper_alarm: 2 };
return lookup[value];
},
},
],
[23, "temperature_calibration", tuya.valueConverter.divideBy10],
[24, "humidity_calibration", tuya.valueConverter.raw],
],
},
},
];
//# sourceMappingURL=soanalarm.js.map