/* -- do not edit following lines - START -- { "expert": true, "debug": false, "verbose": false, "enabled": false } -- do not edit previous lines - END --*/ const SkriptVersion = "0.2.31-local"; const mihome = require('node-mihome'); const refresh = 10000; const SkipRssiRefresh = true; const praefix0 = "0_userdata.0.MiHomeAll"; const logging = false; // ***************************** Lokales Gerät ***************************** // ***************************** Lokale Geräte ***************************** const LocalDevices = [ { name: "Nachttischlampe Sarah", did: "306674154", model: "yeelink.light.bslamp2", localip: "192.168.178.30", token: "" }, { name: "Nachttischlampe Tobi", did: "306678610", model: "yeelink.light.bslamp2", localip: "192.168.178.28", token: "" }, { name: "Luftreiniger Wohnzimmer", did: "307543944", model: "zhimi.airpurifier.ma4", localip: "192.168.178.218", token: "" }, { name: "Luftreiniger Schlafzimmer", did: "315673091", model: "zhimi.airpurifier.mc2", localip: "192.168.178.217", token: "" }, { name: "Xiaomi Smart Humidifier 2", did: "821273588", model: "deerma.humidifier.jsq2w", localip: "192.168.178.216", token: "" } ]; let AllDevicesRaw = []; let device = []; const States = []; let DpCount = 0; let GenericDpRefreshIntervalObj; const DefineDevice = []; log("Starting AllMyMi LOCAL V." + SkriptVersion); // ***************************** Device Definitions ***************************** // ***************************** Airpurifiers ******************************** DefineDevice[0] = { // Tested and working info: {}, model: "zhimi.airpurifier.mb3",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mb3:2 description: "Purifier 3H", setter: { "air-purifier.on": async function (obj, val) { await device[obj].setPower(val) }, "air-purifier.mode": async function (obj, val) { await device[obj].setMode(val) }, "motor-speed.favorite-fan-level": async function (obj, val) { await device[obj].setFavLevel(val) }, "air-purifier.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setBuzzer(val) }, "indicator-light.brightness": async function (obj, val) { await device[obj].setLcdBrightness(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) }, "aqi.aqi-updata-heartbeat": async function (obj, val) { await device[obj].setAqiRealtimeUpdateDuration(val).catch(err => log(err.message, "error")) } }, common: [{ name: "air-purifier.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "air-purifier.fault", type: "number", read: true, write: false, min: 0, max: 5, states: { 0: "No faults", 1: "m1_run", 2: "m1_stuck", 3: "no_sensor", 4: "error_hum", 5: "error_temp", 6: "timer_error1", 7: "timer_error2" } }, { name: "air-purifier.mode", type: "number", read: true, write: true, min: 0, max: 3, states: { 0: "auto", 1: "sleep", 2: "favorite", 3: "fanset" } }, { name: "air-purifier.fan-level", type: "number", read: true, write: true, min: 1, max: 3 }, { name: "alarm.alarm", type: "boolean", read: true, write: true }, { name: "indicator-light.brightness", type: "number", read: true, write: true, min: 0, max: 2 }, { name: "indicator-light.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "environment.temperature", type: "number", role: "value.temperature", read: true, write: false, min: -40, max: 125, unit: "°C" }, { name: "motor-speed.motor-speed", type: "number", read: true, write: false, min: 0, max: 3000, unit: "rpm" }, { name: "motor-speed.motor-set-speed", type: "number", read: true, write: false, min: 0, max: 3000, unit: "rpm" }, { name: "motor-speed.favorite-fan-level", type: "number", read: true, write: true, min: 0, max: 14 }, { name: "use-time.use-time", type: "number", read: true, write: false }, { name: "environment.relative-humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "environment.pm2_5-density", type: "number", read: true, write: false, min: 0, max: 600, unit: "μg/m³" }, { name: "filter.filter-life-level", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "filter.filter-used-time", type: "number", read: true, write: false, unit: "h" }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "aqi.aqi-updata-heartbeat", type: "number", read: true, write: true, min: 0, max: 65534, unit: "s", step: 1 }] }; DefineDevice[20] = { // Tested and working - https://github.com/Pittini/iobroker-nodemihome/issues/28 info: {}, model: "zhimi.airpurifier.mc1",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mc1:1 description: "Purifier 2S", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "mode": async function (obj, val) { await device[obj].setMode(val) }, "favorite_level": async function (obj, val) { await device[obj].setFavoriteLevel(val) }, "led": async function (obj, val) { await device[obj].setLed(val) }, "buzzer": async function (obj, val) { await device[obj].setBuzzer(val) }, "child_lock": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "mode", type: "string", role: "state", read: true, write: true, states: { "auto": "auto", "silent": "silent", "favorite": "favorite" } }, { name: "favorite_level", type: "number", role: "state", read: true, write: true, min: 1, max: 10 }, { name: "temp_dec", type: "number", role: "value.temperature", read: true, write: false, min: -40.0, max: 525.0, unit: "°C" }, { name: "humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "aqi", type: "number", role: "value", read: true, write: false, min: 0, max: 600, unit: "μg/m³" }, { name: "led", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "buzzer", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "filter1_life", type: "number", role: "value", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "f1_hour", type: "number", role: "value", read: true, write: false, unit: "h" }, { name: "f1_hour_used", type: "number", role: "value", read: true, write: false, unit: "h" }, { name: "child_lock", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }] }; DefineDevice[26] = { // Tested and working info: {}, model: "zhimi.airpurifier.ma2",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ma2:1 description: "Purifier 2S", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "mode": async function (obj, val) { await device[obj].setMode(val) }, "favorite_level": async function (obj, val) { await device[obj].setFavoriteLevel(val) }, "led": async function (obj, val) { await device[obj].setLed(val) }, "buzzer": async function (obj, val) { await device[obj].setBuzzer(val) }, "child_lock": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "mode", type: "string", role: "state", read: true, write: true, states: { "auto": "auto", "silent": "silent", "favorite": "favorite" } }, { name: "favorite_level", type: "number", role: "state", read: true, write: true, min: 0, max: 14 }, { name: "temp_dec", type: "number", role: "value.temperature", read: true, write: false, min: -40.0, max: 525.0, unit: "°C" }, { name: "humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "aqi", type: "number", role: "value", read: true, write: false, min: 0, max: 600, unit: "μg/m³" }, { name: "led", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "buzzer", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "filter1_life", type: "number", role: "value", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "f1_hour", type: "number", role: "value", read: true, write: false, unit: "h" }, { name: "f1_hour_used", type: "number", role: "value", read: true, write: false, unit: "h" }, { name: "child_lock", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }] }; DefineDevice[22] = { // Tested and working - https://github.com/Pittini/iobroker-nodemihome/issues/34 info: {}, model: "zhimi.airpurifier.m1",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-m1:1 description: "Purifier 2", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "mode": async function (obj, val) { await device[obj].setMode(val) }, "favorite_level": async function (obj, val) { await device[obj].setFavoriteLevel(val) }, "led": async function (obj, val) { await device[obj].setLed(val) }, "buzzer": async function (obj, val) { await device[obj].setBuzzer(val) }, "child_lock": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "mode", type: "string", role: "state", read: true, write: true, states: { "auto": "auto", "silent": "silent", "favorite": "favorite" } }, { name: "favorite_level", type: "number", role: "state", read: true, write: true, min: 1, max: 10 }, { name: "temp_dec", type: "number", role: "value.temperature", read: true, write: false, min: -40.0, max: 525.0, unit: "°C" }, { name: "humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "aqi", type: "number", role: "value", read: true, write: false, min: 0, max: 600, unit: "μg/m³" }, { name: "led", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "buzzer", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "filter1_life", type: "number", role: "value", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "f1_hour", type: "number", role: "value", read: true, write: false, unit: "h" }, { name: "f1_hour_used", type: "number", role: "value", read: true, write: false, unit: "h" }, { name: "child_lock", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }] }; DefineDevice[8] = { // Tested and working - https://github.com/Pittini/iobroker-nodemihome/issues/6 info: {}, model: "zhimi.airpurifier.mc2",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mc2:1 description: "Purifier 2H", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "mode": async function (obj, val) { await device[obj].setMode(val) }, "favorite_level": async function (obj, val) { await device[obj].setFavoriteLevel(val) }, "led": async function (obj, val) { await device[obj].setLed(val) }, "led_b": async function (obj, val) { await device[obj].setLedB(val) }, "buzzer": async function (obj, val) { await device[obj].setBuzzer(val) }, "child_lock": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "mode", type: "string", role: "state", read: true, write: true, states: { "auto": "auto", "silent": "silent", "favorite": "favorite" } }, { name: "favorite_level", type: "number", role: "state", read: true, write: true, min: 0, max: 16 }, { name: "temp_dec", type: "number", role: "value.temperature", read: true, write: false, min: -40.0, max: 525.0, unit: "°C" }, { name: "humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "aqi", type: "number", role: "value", read: true, write: false, min: 0, max: 600, unit: "μg/m³" }, { name: "average_aqi", type: "number", role: "value", read: true, write: false, min: 0, max: 600, unit: "μg/m³" }, { name: "led", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "led_b", type: "number", role: "state", read: true, write: true, min: 0, max: 2, states: { 0: "bright", 1: "dim", 2: "off" } }, { name: "buzzer", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "filter1_life", type: "number", role: "value", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "f1_hour", type: "number", role: "value", read: true, write: false, unit: "h" }, { name: "f1_hour_used", type: "number", role: "value", read: true, write: false, unit: "h" }, { name: "motor1_speed", type: "number", role: "value", read: true, write: false, unit: "rpm" }, { name: "child_lock", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }] }; DefineDevice[13] = { // Tested and working info: {}, model: "zhimi.airpurifier.vb2",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-vb2:1 description: "Mi Air Purifier Pro H", setter: { "air-purifier.on": async function (obj, val) { await device[obj].setPower(val) }, "air-purifier.mode": async function (obj, val) { await device[obj].setMode(val) }, "motor-speed.favorite-level": async function (obj, val) { await device[obj].setFavLevel(val) }, "air-purifier.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "alarm.volume": async function (obj, val) { await device[obj].setBuzzer(val) }, "indicator-light.brightness": async function (obj, val) { await device[obj].setLcdBrightness(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "air-purifier.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "air-purifier.fault", type: "number", read: true, write: false, min: 0, max: 5, states: { 0: "No faults", 1: "m1_run", 2: "m1_stuck", 3: "no_sensor", 4: "error_hum", 5: "error_temp", 6: "timer_error1", 7: "timer_error2" } }, { name: "air-purifier.mode", type: "number", read: true, write: true, min: 0, max: 3, states: { 0: "auto", 1: "sleep", 2: "favorite", 3: "fanset" } }, { name: "air-purifier.fan-level", type: "number", read: true, write: true, min: 1, max: 3 }, { name: "alarm.volume", type: "number", read: true, write: true, min: 0, max: 100 }, { name: "indicator-light.brightness", type: "number", read: true, write: true, min: 0, max: 2 }, { name: "indicator-light.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "environment.temperature", type: "number", role: "value.temperature", read: true, write: false, min: -40, max: 125, unit: "°C" }, { name: "motor-speed.motor1-speed", type: "number", read: true, write: false, min: 0, max: 3000, unit: "rpm" }, { name: "motor-speed.motor1-set-speed", type: "number", read: true, write: false, min: 0, max: 3000, unit: "rpm" }, { name: "motor-speed.favorite-level", type: "number", read: true, write: true, min: 0, max: 14 }, { name: "use-time.use-time", type: "number", read: true, write: false }, { name: "environment.relative-humidity", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "environment.pm2_5-density", type: "number", read: true, write: false, min: 0, max: 600, unit: "μg/m³" }, { name: "filter.filter-life-level", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "filter.filter-used-time", type: "number", read: true, write: false, unit: "h" }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }] }; DefineDevice[14] = { // Tested and working - https://github.com/Pittini/iobroker-nodemihome/issues/6 info: {}, model: "zhimi.airpurifier.v7",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-v7:1 description: "Mi Air Purifier", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "mode": async function (obj, val) { await device[obj].setFanLevel(val) }, "led": async function (obj, val) { await device[obj].setDisplay(val) }, "child_lock": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "mode", type: "string", read: true, write: true, states: { "auto": "auto", "silent": "silent", "favorite": "favorite" } }, { name: "favorite_level", type: "number", read: true, write: false, min: 0, max: 16 }, { name: "temp_dec", type: "number", role: "value.temperature", read: true, write: false }, { name: "humidity", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "aqi", type: "number", read: true, write: false, unit: "μg/m³" }, { name: "average_aqi", type: "number", read: true, write: false, unit: "μg/m³" }, { name: "led", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "bright", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "volume", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "filter1_life", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "f1_hour", type: "number", read: true, write: false }, { name: "f1_hour_used", type: "number", read: true, write: false }, { name: "motor1_speed", type: "number", read: true, write: false, unit: "rpm" }, { name: "motor2_speed", type: "number", read: true, write: false, unit: "rpm" }, { name: "child_lock", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }] }; DefineDevice[15] = { // Tested and working info: {}, model: "zhimi.airpurifier.mb4",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mb4:2 description: "Purifier 3C", setter: { "air-purifier.on": async function (obj, val) { await device[obj].setPower(val) }, "air-purifier.mode": async function (obj, val) { await device[obj].setMode(val) }, "custom-service.favorite-speed": async function (obj, val) { await device[obj].setFavSpeed(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setBuzzer(val) }, "screen.brightness": async function (obj, val) { await device[obj].setLcdBrightness(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "air-purifier.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "air-purifier.fault", type: "string", read: true, write: false }, { name: "air-purifier.mode", type: "number", read: true, write: true, min: 0, max: 3, states: { 0: "auto", 1: "sleep", 2: "favorite", 3: "fanset" } }, { name: "alarm.alarm", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "screen.brightness", type: "number", read: true, write: true, min: 0, max: 8 }, { name: "environment.pm2_5-density", type: "number", read: true, write: false, min: 0, max: 600, unit: "μg/m³" }, { name: "custom-service.moto-speed-rpm", type: "number", read: true, write: false, min: 0, max: 65535, unit: "rpm" }, { name: "custom-service.favorite-speed", type: "number", read: true, write: true, min: 300, max: 2300, unit: "rpm" }, { name: "filter.filter-life-level", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "filter.filter-used-time", type: "number", read: true, write: false, unit: "h" }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }] }; DefineDevice[18] = { // Untested info: {}, model: "zhimi.airpurifier.ma4",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ma4:1 description: "Air Purifier", setter: { "air-purifier.on": async function (obj, val) { await device[obj].setPower(val) }, "air-purifier.mode": async function (obj, val) { await device[obj].setMode(val) }, "air-purifier.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setBuzzer(val) }, "indicator-light.brightness": async function (obj, val) { await device[obj].setLcdBrightness(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "air-purifier.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "air-purifier.fault", type: "number", read: true, write: false, min: 0, max: 5, states: { 0: "No faults", 1: "m1_run", 2: "m1_stuck", 3: "no_sensor", 4: "error_hum", 5: "error_temp", 6: "timer_error1", 7: "timer_error2" } }, { name: "air-purifier.mode", type: "number", read: true, write: true, min: 0, max: 3, states: { 0: "auto", 1: "sleep", 2: "favorite", 3: "none" } }, { name: "air-purifier.fan-level", type: "number", read: true, write: true, min: 1, max: 3 }, { name: "alarm.alarm", type: "boolean", read: true, write: true, min: false, max: true }, { name: "indicator-light.brightness", type: "number", read: true, write: true, min: 0, max: 2 }, { name: "indicator-light.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "environment.temperature", type: "number", role: "value.temperature", read: true, write: false, min: -40, max: 125, unit: "°C" }, { name: "environment.relative-humidity", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "environment.pm2_5-density", type: "number", read: true, write: false, min: 0, max: 600, unit: "μg/m³" }, { name: "filter.filter-life-level", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "filter.filter-used-time", type: "number", read: true, write: false, unit: "h" }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }] }; DefineDevice[28] = { // Tested and working info: {}, model: "zhimi.airpurifier.mb5",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mb5:1 description: "Purifier 4", setter: { "air-purifier.on": async function (obj, val) { await device[obj].setPower(val).catch(err => log(err.message, "error")) }, "air-purifier.mode": async function (obj, val) { await device[obj].setMode(val).catch(err => log(err.message, "error")) }, "air-purifier.fan-level": async function (obj, val) { await device[obj].setFanLevel(val).catch(err => log(err.message, "error")) }, "air-purifier.anion": async function (obj, val) { await device[obj].setAnion(val).catch(err => log(err.message, "error")) }, "custom-service.favorite-level": async function (obj, val) { await device[obj].setFavLevel(val).catch(err => log(err.message, "error")) }, "alarm.alarm": async function (obj, val) { await device[obj].setBuzzer(val).catch(err => log(err.message, "error")) }, "screen.brightness": async function (obj, val) { await device[obj].setLcdBrightness(val).catch(err => log(err.message, "error")) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val).catch(err => log(err.message, "error")) }, "aqi.aqi-updata-heartbeat": async function (obj, val) { await device[obj].setAqiRealtimeUpdateDuration(val).catch(err => log(err.message, "error")) } }, common: [ { name: "air-purifier.on", type: "boolean", role: "switch", read: true, write: true }, { name: "air-purifier.anion", type: "boolean", role: "switch", read: true, write: true }, { name: "air-purifier.fault", type: "number", read: true, write: false, min: 0, max: 4, states: { 0: "No faults", 1: "Sensor PM Error", 2: "Temp Error", 3: "Hum Error", 4: "No Filter" } }, { name: "air-purifier.mode", type: "number", read: true, write: true, min: 0, max: 3, states: { 0: "Auto", 1: "Sleep", 2: "Favorite", 3: "Manual" } }, { name: "air-purifier.fan-level", type: "number", read: true, write: true, min: 1, max: 3, states: { 1: "Level1", 2: "Level2", 3: "Level3" } }, { name: "alarm.alarm", type: "boolean", read: true, write: true }, { name: "environment.temperature", type: "number", role: "value.temperature", read: true, write: false, min: -30, max: 100, unit: "°C", step: 0.1 }, { name: "custom-service.favorite-level", type: "number", read: true, write: true, min: 0, max: 11, step: 1 }, { name: "environment.relative-humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "environment.pm2_5-density", type: "number", read: true, write: false, min: 0, max: 1000, unit: "μg/m³", step: 1 }, { name: "filter.filter-life-level", type: "number", read: true, write: false, min: 0, max: 100, unit: "%", step: 1 }, { name: "filter.filter-used-time", type: "number", read: true, write: false, min: 0, max: 65000, unit: "h", step: 1 }, { name: "filter.filter-left-time", type: "number", read: true, write: false, min: 0, max: 1000, unit: "days", step: 1 }, { name: "screen.brightness", type: "number", read: true, write: true, min: 0, max: 2, states: { 0: "Close", 1: "Bright", 2: "Brightest" } }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true }, { name: "aqi.aqi-updata-heartbeat", type: "number", read: true, write: true, min: 0, max: 65535, unit: "s", step: 1 } ] }; // ***************************** Fans ********************************* // TODO https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:zhimi-sa1:1 DefineDevice[1] = { // untested info: {}, model: "leshow.fan.ss4",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:leshow-ss4:1 description: "Leshow Fan", setter: { "power": async function (obj, val) { await device[obj].setPower(val ? 'on' : 'off') }, "blow": async function (obj, val) { await device[obj].setFanLevel(val) }, "yaw": async function (obj, val) { await device[obj].setFanSwing(val ? 'on' : 'off') }, "mode": async function (obj, val) { await device[obj].setSleepMode(val) }, "sound": async function (obj, val) { await device[obj].setBuzzer(val ? 'on' : 'off') }, "timer": async function (obj, val) { await device[obj].setTimer(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "blow", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "yaw", type: "boolean", role: "switch", read: true, write: true }, { name: "mode", type: "boolean", role: "switch", read: true, write: true }, { name: "sound", type: "boolean", role: "switch", read: true, write: true }, { name: "timer", type: "number", read: true, write: true, min: 0, max: 540, unit: "m" }] }; DefineDevice[9] = { // Tested and working info: {}, model: "zhimi.fan.za4",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:zhimi-za4:1 description: "Mi Fan 2S", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "angle": async function (obj, val) { await device[obj].setSwingAngle(val) }, "angle_enable": async function (obj, val) { await device[obj].setSwing(val) }, "natural_level": async function (obj, val) { await device[obj].setSleepMode((val == 1) ? true : false) }, "buzzer": async function (obj, val) { await device[obj].setBuzzer(val ? 'on' : 'off') }, "child_lock": async function (obj, val) { await device[obj].setChildLock(val ? 'on' : 'off') }, "led_b": async function (obj, val) { await device[obj].setLcdBrightness(val) }, "speed_level": async function (obj, val) { await device[obj].setFanLevel(val) }, "poweroff_time": async function (obj, val) { await device[obj].setTimer(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "angle", type: "number", read: true, write: true, min: 1, max: 120 }, { name: "angle_enable", type: "boolean", role: "switch", read: true, write: true }, { name: "natural_level", type: "number", read: true, write: true, min: 0, max: 1, states: { 0: "Straight Wind", 1: "Natural Wind" } }, { name: "buzzer", type: "boolean", role: "switch", read: true, write: true }, { name: "child_lock", type: "boolean", role: "switch", read: true, write: true }, { name: "led_b", type: "boolean", role: "switch", read: true, write: true }, { name: "speed_level", type: "number", read: true, write: true, min: 1, max: 100, unit: "%" }, { name: "poweroff_time", type: "number", read: true, write: true, min: 0, max: 540, unit: "m" }] }; DefineDevice[24] = { // Tested and working info: {}, model: "zhimi.fan.za5",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:zhimi-za5:1 description: "Smartmi Fan 3", setter: { "fan.on": async function (obj, val) { await device[obj].setPower(val) }, "fan.mode": async function (obj, val) { await device[obj].setMode(val) }, "fan.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "fan.horizontal-swing": async function (obj, val) { await device[obj].setHorizontalSwing(val) }, "fan.horizontal-angle": async function (obj, val) { await device[obj].setHorizontalAngle(val) }, "fan.anion": async function (obj, val) { await device[obj].setAnion(val) }, "custom-service.speed-level": async function (obj, val) { await device[obj].setSpeedLevel(val) }, "indicator-light.brightness": async function (obj, val) { await device[obj].setLcdBrightness(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setAlarm(val) }, "custom-service.swing-step-move": async function (obj, val) { if (val != "") await device[obj].setSwingStepMove(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) }, "fan.off-delay": async function (obj, val) { await device[obj].setOffDelayTime(val) } }, common: [{ name: "fan.on", type: "boolean", role: "switch", read: true, write: true }, { name: "fan.mode", type: "number", role: "switch", read: true, write: true, min: 0, max: 1, states: { 0: "Natural Wind", 1: "Straight Wind" } }, { name: "fan.fan-level", type: "number", role: "switch", read: true, write: true, min: 1, max: 4, states: { 1: "1", 2: "2", 3: "3", 4: "4" } }, { name: "fan.horizontal-swing", type: "boolean", role: "switch", read: true, write: true }, { name: "fan.horizontal-angle", type: "number", role: "switch", read: true, write: true, min: 30, max: 120, unit: "°", states: { 30: "30", 60: "60", 90: "90", 120: "120" } }, { name: "fan.anion", type: "boolean", role: "switch", read: true, write: true }, { name: "custom-service.speed-level", type: "number", role: "switch", read: true, write: true, min: 1, max: 100 }, { name: "custom-service.battery-state", type: "boolean", role: "switch", read: true, write: false, states: { true: "used", false: "unused" } }, { name: "custom-service.speed-now", type: "number", role: "switch", read: true, write: false, min: 0, max: 3000, unit: "RPM" }, { name: "custom-service.ac-state", type: "boolean", role: "switch", read: true, write: false, states: { true: "plugged", false: "unplugged" } }, { name: "indicator-light.brightness", type: "number", read: true, write: true, min: 0, max: 100, unit: "%" }, { name: "alarm.alarm", type: "boolean", role: "switch", read: true, write: true }, { name: "custom-service.swing-step-move", type: "string", role: "switch", read: false, write: true, states: { "": "None", "left": "Left", "right": "Right" } }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true }, { name: "fan.off-delay", type: "number", role: "switch", read: true, write: true, min: 0, max: 36000, unit: "s" }, { name: "environment.temperature", type: "number", role: "value.temperature", read: true, write: false, min: -30.0, max: 100.0, unit: "°C" }, { name: "environment.relative-humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" } ] }; DefineDevice[17] = { // Tested and working info: {}, model: "dmaker.fan.p15",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p15:1 description: "Mi Smart Standing Fan Pro", setter: { "fan.on": async function (obj, val) { await device[obj].setPower(val) }, "fan.mode": async function (obj, val) { await device[obj].setMode(val) }, "fan.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "fan.horizontal-swing": async function (obj, val) { await device[obj].setHorizontalSwing(val) }, "fan.horizontal-angle": async function (obj, val) { await device[obj].setHorizontalAngle(val) }, "indicator-light.on": async function (obj, val) { await device[obj].setIndicatorLight(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setAlarm(val) }, "motor-controller.motor-control": async function (obj, val) { await device[obj].setMotorController(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) }, "off-delay-time.off-delay-time": async function (obj, val) { await device[obj].setOffDelayTime(val) } }, common: [{ name: "fan.on", type: "boolean", role: "switch", read: true, write: true }, { name: "fan.mode", type: "number", role: "switch", read: true, write: true, min: 0, max: 1, states: { 0: "Straight Wind", 1: "Natural Wind" } }, { name: "fan.fan-level", type: "number", role: "switch", read: true, write: true, min: 1, max: 4, states: { 1: "Slow", 2: "Middle", 3: "High", 4: "Turbo" } }, { name: "fan.horizontal-swing", type: "boolean", role: "switch", read: true, write: true }, { name: "fan.horizontal-angle", type: "number", role: "switch", read: true, write: true, min: 30, max: 140, unit: "°", states: { 30: "30°", 60: "60°", 90: "90°", 120: "120°", 140: "140°" } }, { name: "fan.status", type: "number", role: "indicator", read: true, write: false, min: 1, max: 100 }, { name: "indicator-light.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "alarm.alarm", type: "boolean", role: "switch", read: true, write: true }, { name: "motor-controller.motor-control", type: "number", role: "switch", read: false, write: true, min: 0, max: 2, states: { 0: "None", 1: "Left", 2: "Right" } }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "off-delay-time.off-delay-time", type: "number", role: "switch", read: true, write: true, min: 0, max: 480, unit: "m" } ] }; DefineDevice[19] = { // Tested and working info: {}, model: "dmaker.fan.1c",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-1c:1 description: "Mi Smart Standing Fan 1C", setter: { "fan.on": async function (obj, val) { await device[obj].setPower(val) }, "fan.mode": async function (obj, val) { await device[obj].setMode(val) }, "fan.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "fan.horizontal-swing": async function (obj, val) { await device[obj].setHorizontalSwing(val) }, "fan.brightness": async function (obj, val) { await device[obj].setBrightness(val) }, "fan.alarm": async function (obj, val) { await device[obj].setAlarm(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) }, "fan.off-delay-time": async function (obj, val) { await device[obj].setOffDelayTime(val) } }, common: [{ name: "fan.on", type: "boolean", role: "switch", read: true, write: true }, { name: "fan.mode", type: "number", role: "switch", read: true, write: true, min: 0, max: 1, states: { 0: "Straight Wind", 1: "Sleep" } }, { name: "fan.fan-level", type: "number", role: "switch", read: true, write: true, min: 1, max: 3, states: { 1: "Slow", 2: "Middle", 3: "High" } }, { name: "fan.horizontal-swing", type: "boolean", role: "switch", read: true, write: true }, { name: "fan.status", type: "number", role: "indicator", read: true, write: false, min: 1, max: 100 }, { name: "fan.brightness", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "fan.alarm", type: "boolean", role: "switch", read: true, write: true }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "fan.off-delay-time", type: "number", role: "switch", read: true, write: true, min: 0, max: 480, unit: "m" } ] }; DefineDevice[23] = { // Tested and working info: {}, model: "dmaker.fan.p18",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p18:1 description: "Mi Smart Standing Fan 2", setter: { "fan.on": async function (obj, val) { await device[obj].setPower(val) }, "fan.mode": async function (obj, val) { await device[obj].setMode(val) }, "fan.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "fan.horizontal-swing": async function (obj, val) { await device[obj].setHorizontalSwing(val) }, "fan.horizontal-angle": async function (obj, val) { await device[obj].setHorizontalAngle(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setAlarm(val) }, "motor-controller.motor-control": async function (obj, val) { await device[obj].setMotorController(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) }, "off-delay-time.off-delay-time": async function (obj, val) { await device[obj].setOffDelayTime(val) } }, common: [{ name: "fan.on", type: "boolean", role: "switch", read: true, write: true }, { name: "fan.mode", type: "number", role: "switch", read: true, write: true, min: 0, max: 1, states: { 0: "Straight Wind", 1: "Natural Wind" } }, { name: "fan.fan-level", type: "number", role: "switch", read: true, write: true, min: 1, max: 4, states: { 1: "Slow", 2: "Middle", 3: "High", 4: "Turbo" } }, { name: "fan.horizontal-swing", type: "boolean", role: "switch", read: true, write: true }, { name: "fan.horizontal-angle", type: "number", role: "switch", read: true, write: true, min: 30, max: 140, unit: "°", states: { 30: "30°", 60: "60°", 90: "90°", 120: "120°", 140: "140°" } }, { name: "fan.status", type: "number", role: "indicator", read: true, write: false, min: 1, max: 100 }, { name: "alarm.alarm", type: "boolean", role: "switch", read: true, write: true }, { name: "motor-controller.motor-control", type: "number", role: "switch", read: false, write: true, min: 0, max: 2, states: { 0: "None", 1: "Left", 2: "Right" } }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "off-delay-time.off-delay-time", type: "number", role: "switch", read: true, write: true, min: 0, max: 480, unit: "m" } ] }; // ***************************** Lights ********************************* DefineDevice[2] = { // Tested and ok except setting color info: {}, model: "yeelink.light.strip2",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:yeelink-color2:1 description: "Yeelight Lightstrip Plus", setter: { "power": async function (obj, val) { await device[obj].setPower(val ? 'on' : 'off') }, "bright": async function (obj, val) { await device[obj].setBrightness(val) }, "hue": async function (obj, val) { await device[obj].setColorHSV(val) }, "color_mode": async function (obj, val) { await device[obj].setColorMode(val) }, "ct": async function (obj, val) { await device[obj].setCt(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "bright", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "hue", type: "number", read: true, write: true, min: 0, max: 16777215 }, { name: "sat", type: "number", read: true, write: true, min: 0, max: 100 }, { name: "color_mode", type: "number", read: true, write: true, min: 1, max: 2 }, { name: "ct", type: "number", read: true, write: true, min: 1700, max: 6500 }] }; DefineDevice[5] = { // Tested and working info: {}, model: "yeelink.light.ct2",// http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:yeelink-ct2:1 description: "Yeelight LED Bulb (Tunable)", setter: { "power": async function (obj, val) { await device[obj].setPower(val ? 'on' : 'off') }, "bright": async function (obj, val) { await device[obj].setBrightness(val) }, "ct": async function (obj, val) { await device[obj].setColorTemperature(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "bright", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "ct", type: "number", read: true, write: true, min: 1700, max: 6500 }] }; DefineDevice[6] = { // Tested and working except color setting info: {}, model: "yeelink.light.color2",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:yeelink-color2:1 description: "Yeelight LED Bulb (Color)", setter: { "power": async function (obj, val) { await device[obj].setPower(val ? 'on' : 'off') }, "bright": async function (obj, val) { await device[obj].setBrightness(val) }, "rgb": async function (obj, val) { await device[obj].setColorRgb(val) }, "color_mode": async function (obj, val) { await device[obj].setColorMode(val) }, "ct": async function (obj, val) { await device[obj].setCt(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "bright", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "rgb", type: "number", read: true, write: true, min: 1, max: 16777215 }, { name: "color_mode", type: "number", read: true, write: true, min: 1, max: 2 }, { name: "ct", type: "number", read: true, write: true, min: 1700, max: 6500 }] }; DefineDevice[10] = { // untested info: {}, model: "yeelink.light.ceiling3",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:yeelink-ceiling3:1 description: "Yeelight LED Ceiling Light", setter: { "power": async function (obj, val) { await device[obj].setPower(val ? 'on' : 'off') }, "bright": async function (obj, val) { await device[obj].setBrightness(val) }, "nl_br": async function (obj, val) { await device[obj].setBrightness(val) }, "night_mode": async function (obj, val) { await device[obj].setSleepMode(val) }, "ct": async function (obj, val) { await device[obj].setCt(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "bright", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "nl_br", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "night_mode", type: "boolean", role: "switch", read: true, write: true }, { name: "ct", type: "number", read: true, write: true, min: 1700, max: 6500 }] }; DefineDevice[11] = { // untested info: {}, model: "yeelink.light.ceiling1",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:yeelink-ceiling1:1 description: "Yeelight Crystal Pedestal Light", setter: { "power": async function (obj, val) { await device[obj].setPower(val ? 'on' : 'off') }, "bright": async function (obj, val) { await device[obj].setBrightness(val) }, "nl_br": async function (obj, val) { await device[obj].setBrightness(val) }, "night_mode": async function (obj, val) { await device[obj].setSleepMode(val) }, "ct": async function (obj, val) { await device[obj].setCt(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "bright", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "nl_br", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "night_mode", type: "boolean", read: true, write: true }, { name: "ct", type: "number", read: true, write: true, min: 1700, max: 6500 }] }; DefineDevice[21] = { // untested info: {}, model: "yeelink.light.ceiling10",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:yeelink-ceiling10:1 description: "Yeelight Meteorite Pedestal Light", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "main_power": async function (obj, val) { await device[obj].setMainPower(val) }, "bg_power": async function (obj, val) { await device[obj].setBgPower(val) }, "bg_bright": async function (obj, val) { await device[obj].setBgBrightness(val) }, "active_bright": async function (obj, val) { await device[obj].setActiveBrightness(val) }, "color_mode": async function (obj, val) { await device[obj].setColorMode(val) }, "ct": async function (obj, val) { await device[obj].setColorTemperature(val) }, "bg_ct": async function (obj, val) { await device[obj].setBgColorTemperature(val) }, "bg_rgb": async function (obj, val) { await device[obj].setBgColorRgb(val) }, "bg_hue": async function (obj, val) { await device[obj].setBgColorHSV([val, 100]) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "main_power", type: "boolean", role: "switch", read: true, write: true }, { name: "bg_power", type: "boolean", role: "switch", read: true, write: true }, { name: "bg_bright", type: "number", role: 'level.dimmer', read: true, write: true, min: 1, max: 100, unit: "%" }, { name: "active_bright", type: "number", role: 'level.dimmer', read: true, write: true, min: 1, max: 100, unit: "%" }, { name: "color_mode", type: "boolean", role: 'switch.mode.color', read: true, write: true }, { name: "moon_mode", type: "boolean", role: 'switch.mode.moon', read: true, write: true }, { name: "bg_ct", type: "number", role: 'level.color.temperature', read: true, write: true, min: 2600, max: 6500, unit: "K" }, { name: "ct", type: "number", role: 'level.color.temperature', read: true, write: true, min: 2600, max: 6500, unit: "K" }, { name: "bg_rgb", type: "string", role: 'level.color.rgb', read: true, write: true }, { name: "bg_hue", type: "number", role: 'level.color.hue', read: true, write: true, min: 0, max: 359 }, { name: "bg_sat", type: "number", role: 'level.color.saturation', read: true, write: true, min: 1, max: 100 }] }; DefineDevice[16] = { // untested info: {}, model: "yeelink.light.lamp4",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:yeelink-lamp4:1 description: "Mi LED Desk Lamp 1S", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "bright": async function (obj, val) { await device[obj].setBrightness(val) }, "ct": async function (obj, val) { await device[obj].setColorTemperature(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "bright", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "ct", type: "number", read: true, write: true, min: 1700, max: 6500 }] }; DefineDevice[27] = { // Tested and ok -https://github.com/Pittini/iobroker-nodemihome/issues/52 info: {}, model: "yeelink.light.bslamp2",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:yeelink-bslamp2:1 description: "Yeelink Bedside Lamp", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "bright": async function (obj, val) { await device[obj].setBrightness(val) }, "rgb": async function (obj, val) { await device[obj].setColorRgb(val) }, "color_mode": async function (obj, val) { await device[obj].setColorMode(val) }, "ct": async function (obj, val) { await device[obj].setCt(val) } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true }, { name: "bright", type: "number", read: true, write: true, min: 1, max: 100 }, { name: "rgb", type: "number", read: true, write: true, min: 1, max: 16777215 }, { name: "color_mode", type: "number", read: true, write: true, min: 1, max: 2 }, { name: "ct", type: "number", read: true, write: true, min: 1700, max: 6500 }] }; // ***************************** Humidifier ********************************* DefineDevice[3] = { // Tested and working info: {}, model: "zhimi.humidifier.cb1",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:humidifier:0000A00E:zhimi-cb1:1 description: "Smartmi Evaporative Humidifier", setter: { "power": async function (obj, val) { await device[obj].setPower(val) }, "buzzer": async function (obj, val) { await device[obj].setBuzzer(val ? 'on' : 'off') }, "mode": async function (obj, val) { await device[obj].setFanLevel(val) }, "limit_hum": async function (obj, val) { await device[obj].setTargetHumidity(val) }, "led": async function (obj, val) { await device[obj].setLedBrightness(val) }, "child_lock": async function (obj, val) { await device[obj].setChildLock(val) }, "dry": async function (obj, val) { await device[obj].setMode(val ? 'dry' : 'humidify') } }, common: [{ name: "power", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "depth", type: "number", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "limit_hum", type: "number", read: true, write: true, min: 0, max: 100, unit: "%", states: { 30: "30%", 40: "40%", 50: "50%", 60: "60%", 70: "70%", 80: "80%" } }, { name: "led", type: "number", read: true, write: true, min: 0, max: 2, states: { 0: "bright", 1: "dim", 2: "off" } }, { name: "buzzer", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "temperature", type: "number", role: "value.temperature", read: true, write: false, min: -40, max: 125, unit: "°C" }, { name: "humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "child_lock", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "dry", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "mode", type: "string", read: true, write: true, states: { "auto": "auto", "silent": "silent", "medium": "medium", "high": "high" } }] }; DefineDevice[4] = { // untested info: {}, model: "deerma.humidifier.jsq",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:humidifier:0000A00E:deerma-jsq:1 description: "Mi Smart Antibacterial Humidifier", setter: { "humidifier.on": async function (obj, val) { await device[obj].setPower(val) }, "humidifier.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setBuzzer(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "humidifier.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "power", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "humidifier.fan-level", type: "number", read: true, write: true, min: 0, max: 3, states: { 0: "auto", 1: "level1", 2: "level2", 3: "level3" } }, { name: "humidifier.water-level", type: "number", read: true, write: false, min: 0, max: 127 }, { name: "alarm.alarm", type: "boolean", read: true, write: true, min: false, max: true }, { name: "environment.temperature", type: "number", role: "value.temperature", read: true, write: false, min: -40, max: 125, unit: "°C" }, { name: "environment.relative-humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }] }; DefineDevice[12] = { // Tested and working info: {}, model: "zhimi.humidifier.ca4",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:humidifier:0000A00E:zhimi-ca4:1 description: "Smartmi Evaporative Humidifier", setter: { "humidifier.on": async function (obj, val) { await device[obj].setPower(val) }, "humidifier.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "humidifier.target-humidity": async function (obj, val) { await device[obj].setTargetHumidity(val) }, "humidifier.dry": async function (obj, val) { await device[obj].setMode(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setBuzzer(val) }, "screen.brightness": async function (obj, val) { await device[obj].setBright(val) }, "physical-controls-locked.physical-controls-locked": async function (obj, val) { await device[obj].setChildLock(val) } }, common: [{ name: "humidifier.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "humidifier.fault", type: "number", read: true, write: false, min: 0, max: 15 }, { name: "humidifier.fan-level", type: "number", read: true, write: true, min: 0, max: 3, states: { 0: "auto", 1: "level1", 2: "level2", 3: "level3" } }, { name: "humidifier.target-humidity", type: "number", read: true, write: true, min: 30, max: 80, unit: "%" }, { name: "humidifier.water-level", type: "number", read: true, write: false, min: 0, max: 128 }, { name: "humidifier.speed-level", type: "number", read: true, write: false, min: 200, max: 2000 }, { name: "humidifier.dry", type: "boolean", read: true, write: true, min: false, max: true }, { name: "humidifier.use-time", type: "number", read: true, write: false, min: 0, max: 2147483600 }, { name: "environment.temperature", type: "number", role: "value.temperature", read: true, write: false, min: -40, max: 125, unit: "°C" }, { name: "environment.relative-humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "alarm.alarm", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "screen.brightness", type: "number", role: "value.brightnesss", read: true, write: true, min: 0, max: 2, states: { 0: "Dark", 1: "Glimmer", 2: "Brightest" } }, { name: "physical-controls-locked.physical-controls-locked", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "other.actual-speed", type: "number", read: true, write: false, min: 0, max: 2000 }, { name: "other.power-time", type: "number", read: true, write: false, min: 0, max: 4294967295, unit: "Seconds" }] }; DefineDevice[25] = { // Tested and working - https://github.com/Pittini/iobroker-nodemihome/issues/50 info: {}, model: "deerma.humidifier.jsq4",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:humidifier:0000A00E:deerma-jsq4:1 description: "XIAOMI Mijia CJSJSQ01DY Pure Evaporation", setter: { "humidifier.on": async function (obj, val) { await device[obj].setPower(val) }, "humidifier.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "humidifier.target-humidity": async function (obj, val) { await device[obj].setTargetHumidity(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setBuzzer(val) }, "indicator-light.on": async function (obj, val) { await device[obj].setBright(val) } }, common: [{ name: "humidifier.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "humidifier.fault", type: "number", read: true, write: false, min: 0, max: 2, states: { 0: "No faults", 1: "Insufficient Water", 2: "Water Separation" } }, { name: "humidifier.fan-level", type: "number", read: true, write: true, min: 0, max: 3, states: { 1: "Level1", 2: "Level2", 3: "Humidity" } }, { name: "humidifier.target-humidity", type: "number", read: true, write: true, min: 40, max: 80, unit: "%" }, { name: "environment.temperature", type: "number", role: "value.temperature", read: true, write: false, min: -30, max: 100, unit: "°C" }, { name: "environment.relative-humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "alarm.alarm", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "indicator-light.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "custom.water-shortage-fault", type: "boolean", role: "switch", read: true, write: false, min: false, max: true }, { name: "custom.the-tank-filed", type: "boolean", role: "switch", read: true, write: false, min: false, max: true }] }; DefineDevice[29] = { // Untestet info: {}, model: "deerma.humidifier.jsq2w",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:humidifier:0000A00E:deerma-jsq2w:1 description: "Xiaomi Smart Humidifier 2", setter: { "humidifier.on": async function (obj, val) { await device[obj].setPower(val) }, "humidifier.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }, "humidifier.target-humidity": async function (obj, val) { await device[obj].setTargetHumidity(val) }, "alarm.alarm": async function (obj, val) { await device[obj].setBuzzer(val) }, "indicator-light.on": async function (obj, val) { await device[obj].setBright(val) } }, common: [{ name: "humidifier.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "humidifier.fault", type: "number", read: true, write: false, min: 0, max: 2, states: { 0: "No faults", 1: "Insufficient Water", 2: "Water Separation" } }, { name: "humidifier.fan-level", type: "number", read: true, write: true, min: 0, max: 3, states: { 1: "Level1", 2: "Level2", 3: "Humidity" } }, { name: "humidifier.target-humidity", type: "number", read: true, write: true, min: 40, max: 80, unit: "%" }, { name: "environment.temperature", type: "number", role: "value.temperature", read: true, write: false, min: -30, max: 100, unit: "°C" }, { name: "environment.relative-humidity", type: "number", role: "value.humidity", read: true, write: false, min: 0, max: 100, unit: "%" }, { name: "alarm.alarm", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "indicator-light.on", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }, { name: "custom.water-shortage-fault", type: "boolean", role: "switch", read: true, write: false, min: false, max: true }, { name: "custom.the-tank-filed", type: "boolean", role: "switch", read: true, write: false, min: false, max: true }] }; // Generische Info-Datenpunkte for (let x in DefineDevice) { DefineDevice[x].info = [ { id: "localip", initial: "", common: { read: true, write: true, name: "Ip Adress", type: "string", role: "value" } }, { id: "token", initial: "", common: { read: true, write: true, name: "Token", type: "string", role: "value" } }, { id: "did", initial: "", common: { read: true, write: true, name: "Device Id", type: "string", role: "value" } }, { id: "model", initial: "", common: { read: true, write: true, name: "Model", type: "string", role: "value" } }, { id: "rssi", initial: 0, common: { read: true, write: false, name: "rssi", type: "number", role: "value.rssi" } }, { id: "name", initial: "", common: { read: true, write: true, name: "Name", type: "string", role: "value" } }, { id: "isOnline", initial: false, common: { read: true, write: true, name: "Is online", type: "boolean", role: "value" } } ]; } // ***************************** Init – NUR LOKAL ***************************** async function Init() { if (logging) log("Init (LOCAL MODE)"); mihome.miioProtocol.init(); // Alle lokalen Geräte übernehmen AllDevicesRaw = LocalDevices; log("Found " + AllDevicesRaw.length + " local devices."); for (let x = 0; x < AllDevicesRaw.length; x++) { if (!AllDevicesRaw[x]) continue; // ✅ NEU: Schutz gegen undefined-Einträge log("Preparing device " + AllDevicesRaw[x].name); await PrepareGenericDps(AllDevicesRaw[x].did); for (let y = 0; y < DefineDevice.length; y++) { if (!DefineDevice[y]) continue; if (AllDevicesRaw[x].model == DefineDevice[y].model) { log("Device " + AllDevicesRaw[x].name + " is supported."); await PrepareDeviceDps(AllDevicesRaw[x].did, AllDevicesRaw[x].model); } } } CreateStates(); } // Script starten Init(); // *** Temperatur-Korrektur für alte Geräte (temp_dec → °C) *** on({ id: /\.temp_dec$/, change: "ne" }, (obj) => { if (!obj?.state || typeof obj.state.val !== "number") return; const raw = obj.state.val; // Verhindere doppelte Umrechnung if (raw < 80) return; // Wenn schon °C, nichts tun const rounded = Math.round((raw / 10) * 10) / 10; setState(obj.id, rounded, true); }); // ***************************** Rest bleibt unverändert ***************************** function PrepareDeviceDps(did, model) { if (logging) log("Reaching PrepareDeviceDps, did=" + did + " model=" + model); for (let x in DefineDevice) { if (DefineDevice[x].model == model) { for (let y in DefineDevice[x].common) { States[DpCount] = { id: praefix0 + "." + did + "." + DefineDevice[x].common[y].name, common: DefineDevice[x].common[y] }; DpCount++; }; }; }; } function PrepareGenericDps(did) { // das erste Device mit info suchen const def = Object.values(DefineDevice).find(d => d && d.info); if (!def) { log("No DefineDevice with info found!", "error"); return; } for (let y in def.info) { States[DpCount] = { id: praefix0 + "." + did + ".info." + def.info[y].id, common: def.info[y].common }; DpCount++; }; } function CreateStates() { if (logging) log("Reaching CreateStates()"); let numStates = States.length; States.forEach(function (state) { createState(state.id, state.initial, state.forceCreation, state.common, function () { numStates--; if (numStates === 0) { if (logging) log(States.length + " States created, now setting up channels!"); setObject(praefix0, { type: 'channel', common: { name: "" }, native: {} }); for (let x = 0; x < AllDevicesRaw.length; x++) { setObject(praefix0 + "." + AllDevicesRaw[x].did, { type: 'device', common: { name: AllDevicesRaw[x].name }, native: {} }); }; main(); }; }); }); } async function main() { if (logging) log("Reaching main"); await WriteGenericDpValues(); await CreateDevices(); CreateDpTrigger(); } function WriteGenericDpValues() { if (logging) log("Reaching WriteGenericDpValues()"); for (let x in AllDevicesRaw) { for (let y in DefineDevice[0].info) { setState(praefix0 + "." + AllDevicesRaw[x].did + ".info." + DefineDevice[0].info[y].id, AllDevicesRaw[x][DefineDevice[0].info[y].id], true); }; }; return true; } async function CreateDevices() { if (logging) log("Reaching CreateDevices "); let z = 0; for (let x in AllDevicesRaw) { for (let y in DefineDevice) { if (AllDevicesRaw[x].model == DefineDevice[y].model) { log("Now creating device for " + AllDevicesRaw[x].model + " / " + AllDevicesRaw[x].did + " / " + AllDevicesRaw[x].localip + " / " + AllDevicesRaw[x].token + " / " + refresh); device[z] = mihome.device({ id: AllDevicesRaw[x].did, model: AllDevicesRaw[x].model, address: AllDevicesRaw[x].localip, token: AllDevicesRaw[x].token, refresh: refresh }); device[z].model = AllDevicesRaw[x].model; device[z].setter = DefineDevice[y].setter; device[z].definition = DefineDevice[y]; device[z].firstrun = true; device[z].rssi = 0; device[z].isOnline = true; await device[z].init(); z++; }; }; }; for (let i in device) { device[i].on('properties', (data) => { if (typeof data != "undefined" && data != {}) { if (JSON.stringify(device[i].data) !== JSON.stringify(data)) { if (typeof device[i].data == "undefined") { device[i].data = data; }; RefreshDps(i, data); }; } }); }; if (!SkipRssiRefresh) { GenericDpRefreshIntervalObj = setInterval(function () { RefreshGenericDpsTicker(); }, refresh); }; onStop(function () { for (let x in device) { device[x].destroy(); }; unsubscribe('properties'); clearInterval(GenericDpRefreshIntervalObj); }, 10); } function RefreshDps(DeviceIndex, NewData) { for (let x in device[DeviceIndex].data) { for (let i in NewData) { if ((NewData[i] !== device[DeviceIndex].data[x] || device[DeviceIndex].firstrun == true) && i === x) { device[DeviceIndex].data[x] = NewData[i]; for (let y in device[DeviceIndex].definition.common) { if (device[DeviceIndex].definition.common[y].name == CorrectChannelId(x) && device[DeviceIndex].definition.common[y].read == true) { switch (device[DeviceIndex].data[x]) { case 'on': setState(praefix0 + "." + device[DeviceIndex].id + "." + CorrectChannelId(x), true, true); break; case 'off': setState(praefix0 + "." + device[DeviceIndex].id + "." + CorrectChannelId(x), false, true); break; default: setState(praefix0 + "." + device[DeviceIndex].id + "." + CorrectChannelId(x), device[DeviceIndex].data[x], true); }; }; }; }; }; }; device[DeviceIndex].firstrun = false; return true; } function CreateDpTrigger() { for (let i in device) { for (let x in device[i].definition.common) { if (device[i].definition.common[x].write) { on({ id: praefix0 + "." + device[i].id + "." + device[i].definition.common[x].name, change: "ne", ack: false }, function (dp) { SetDevice(i, x, CheckDataTypeAndConvert(dp.state.val, device[i].definition.common[x].type)); }); } } } } async function SetDevice(i, key, keyvalue) { if (device[i].setter && device[i].definition.common[key]) { const name = device[i].definition.common[key].name; if (device[i].setter[name]) { await device[i].setter[name](i, keyvalue); } } } function CheckDataTypeAndConvert(value, HasToBe) { if (typeof value == "string" && HasToBe == "number") { if (parseFloat(value) == parseInt(value)) { return parseInt(value); } else { return parseFloat(value); }; } else { return value; }; } function CorrectChannelId(cid) { let temp = cid; if (typeof temp == "object") temp = JSON.stringify(cid); cid = temp.replace(".", '_'); temp = cid.replace(/:/g, "."); return temp; }