How to use homey - 10 common examples

To help you get started, we’ve selected a few homey examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jghaanstra / com.xiaomi-miio / drivers / mi-airpurifier / device.js View on Github external
onInit() {
    this.createDevice();
    setTimeout(() => { this.refreshDevice(); }, 600000);

    this.setUnavailable(Homey.__('unreachable'));

    // LISTENERS FOR UPDATING CAPABILITIES
    this.registerCapabilityListener('onoff', (value, opts) => {
      if (this.miio) {
        return this.miio.setPower(value);
      } else {
        this.setUnavailable(Homey.__('unreachable'));
        this.createDevice();
        return Promise.reject('Device unreachable, please try again ...');
      }
    });
  }
github jghaanstra / com.xiaomi-miio / drivers / philips-bulb / device.js View on Github external
onInit() {
    this.createDevice();
    setTimeout(() => { this.refreshDevice(); }, 600000);

    this.setUnavailable(Homey.__('unreachable'));

    // LISTENERS FOR UPDATING CAPABILITIES
    this.registerCapabilityListener('onoff', (value, opts) => {
      if (this.miio) {
        return this.miio.setPower(value);
      } else {
        this.setUnavailable(Homey.__('unreachable'));
        this.createDevice();
        return Promise.reject('Device unreachable, please try again ...');
      }
    });

    this.registerCapabilityListener('dim', (value, opts) => {
      if (this.miio) {
        var brightness = value * 100;
        return this.miio.setBrightness(brightness);
github jghaanstra / com.xiaomi-miio / drivers / mi-power-strip / device.js View on Github external
onInit() {
    this.createDevice();
    setTimeout(() => { this.refreshDevice(); }, 600000);

    this.setUnavailable(Homey.__('unreachable'));

    // LISTENERS FOR UPDATING CAPABILITIES
    this.registerCapabilityListener('onoff', (value, opts) => {
      if (this.miio) {
        return this.miio.setPower(value);
      } else {
        this.setUnavailable(Homey.__('unreachable'));
        this.createDevice();
        return Promise.reject('Device unreachable, please try again ...');
      }
    });
  }
github jghaanstra / com.xiaomi-miio / drivers / mi-humidifier / device.js View on Github external
onInit() {
    this.createDevice();
    setTimeout(() => { this.refreshDevice(); }, 600000);

    this.setUnavailable(Homey.__('unreachable'));

    // LISTENERS FOR UPDATING CAPABILITIES
    this.registerCapabilityListener('onoff', (value, opts) => {
      if (this.miio) {
        return this.miio.setPower(value);
      } else {
        this.setUnavailable(Homey.__('unreachable'));
        this.createDevice();
        return Promise.reject('Device unreachable, please try again ...');
      }
    });
  }
github jghaanstra / com.xiaomi-miio / drivers / air-monitor / device.js View on Github external
onInit() {
    this.createDevice();
    setTimeout(() => { this.refreshDevice(); }, 600000);

    this.setUnavailable(Homey.__('unreachable'));

    // LISTENERS FOR UPDATING CAPABILITIES
    this.registerCapabilityListener('onoff', (value, opts) => {
      if (this.miio) {
        return this.miio.setPower(value);
      } else {
        this.setUnavailable(Homey.__('unreachable'));
        this.createDevice();
        return Promise.reject('Device unreachable, please try again ...');
      }
    });

  }
github TedTolboom / com.xiaomi-mi-zigbee / node_modules / homey-meshdriver / lib / zwave / ZwaveDevice.js View on Github external
_composeCustomSaveMessage(oldSettings, newSettings, changedKeysArr) {

		// Provide user with proper feedback after clicking save
		let saveMessage = null;
		if (this.node.battery === true && this.node.online === false) saveMessage = Homey.__(i18n.settings.offlineNodeSaveMessage);
		if (typeof this.customSaveMessage === 'function') {
			const message = this.customSaveMessage(oldSettings, newSettings, changedKeysArr);

			if (typeof message !== 'object' && typeof message !== 'string') {
				this._debug('Save message\'s return value is not an object nor a string');
			} else if (typeof message === 'object' && !message.hasOwnProperty('en')) {
				this._debug('A custom save message needs at least the english translation');
			} else {
				saveMessage = message;
			}
		} else if (typeof this.customSaveMessage === 'object') {
			if (!this.customSaveMessage.hasOwnProperty('en')) {
				this._debug('A custom save message needs at least the english translation');
			} else {
				saveMessage = this.customSaveMessage;
			}
github athombv / node-homey-meshdriver / lib / zwave / ZwaveDevice.js View on Github external
_composeCustomSaveMessage(oldSettings, newSettings, changedKeysArr) {

		// Provide user with proper feedback after clicking save
		let saveMessage = null;
		if (this.node.battery === true && this.node.online === false) saveMessage = Homey.__(i18n.settings.offlineNodeSaveMessage);
		if (typeof this.customSaveMessage === 'function') {
			const message = this.customSaveMessage(oldSettings, newSettings, changedKeysArr);

			if (typeof message !== 'object' && typeof message !== 'string') {
				this._debug('Save message\'s return value is not an object nor a string');
			} else if (typeof message === 'object' && !message.hasOwnProperty('en')) {
				this._debug('A custom save message needs at least the english translation');
			} else {
				saveMessage = message;
			}
		} else if (typeof this.customSaveMessage === 'object') {
			if (!this.customSaveMessage.hasOwnProperty('en')) {
				this._debug('A custom save message needs at least the english translation');
			} else {
				saveMessage = this.customSaveMessage;
			}
github TedTolboom / com.xiaomi-mi-zigbee / drivers / sensor_86sw1lu / device.js View on Github external
onSceneAutocomplete(query, args, callback) {
		let resultArray = [];
		for (let sceneID in this.sceneMap) {
			resultArray.push({
				id: this.sceneMap[sceneID].scene,
				name: Homey.__(this.sceneMap[sceneID].scene),
			})
		}
		// filter for query
		resultArray = resultArray.filter(result => {
			return result.name.toLowerCase().indexOf(query.toLowerCase()) > -1;
		});
		this._debug(resultArray);
		return Promise.resolve(resultArray);
	}
github TedTolboom / com.xiaomi-mi-zigbee / drivers / remote.b186acn01 / device.js View on Github external
onSceneAutocomplete(query, args, callback) {

		let resultArray = [];
		for (let sceneID in this.sceneMap) {
			resultArray.push({
				id: this.sceneMap[sceneID].scene,
				name: Homey.__(this.sceneMap[sceneID].scene),
			})
		}
		// filter for query
		resultArray = resultArray.filter(result => {
			return result.name.toLowerCase().indexOf(query.toLowerCase()) > -1;
		});
		this._debug(resultArray);
		return Promise.resolve(resultArray);
	}
github TedTolboom / com.xiaomi-mi-zigbee / drivers / sensor_switch.aq2 / device.js View on Github external
onSceneAutocomplete(query, args, callback) {
		let resultArray = [];
		for (let sceneID in this.sceneMap) {
			resultArray.push({
				id: this.sceneMap[sceneID].scene,
				name: Homey.__(this.sceneMap[sceneID].scene),
			})
		}
		// filter for query
		resultArray = resultArray.filter(result => {
			return result.name.toLowerCase().indexOf(query.toLowerCase()) > -1;
		});
		this._debug(resultArray);
		return Promise.resolve(resultArray);
	}

homey

Command-line interface and type declarations for Homey Apps

ISC
Latest version published 17 days ago

Package Health Score

55 / 100
Full package analysis

Popular homey functions