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

Error and changes for yeelink.light.strip2.js #19

Open
Pittini opened this issue Jan 6, 2021 · 1 comment
Open

Error and changes for yeelink.light.strip2.js #19

Pittini opened this issue Jan 6, 2021 · 1 comment

Comments

@Pittini
Copy link
Contributor

Pittini commented Jan 6, 2021

Hi, i own this device. Today you changed some, and there is an error, saturation dont work for me, but sat do. And i miss some properties: color_mode and rgb. Here is my file, this is testet and working except i can see but not set color and mode. How is the definition of the expected data? I tried [100,300] and also ['100','300'] for testing, nothing works. Do you have a hint?

const Device = require('../device-miio');
const { withLightEffect } = require('../utils');

module.exports = class extends Device {

  static model = 'yeelink.light.strip2';
  static name = 'Yeelight Lightstrip Plus';
  static image = 'https://static.home.mi.com/app/image/get/file/developer_1551948225adgd7h86.png';

  constructor(opts) {
    super(opts);

    this._propertiesToMonitor = ['power', 'bright', 'ct', 'hue', 'sat','rgb','color_mode'];
  }

  getPower() {
    const { power } = this.properties;
    if (power === 'on') return true;
    if (power === 'off') return false;
    return undefined;
  }

  getBrightness() {
    const brightness = parseInt(this.properties.bright, 10);
    if (brightness > 0) return brightness;
    return undefined;
  }

  getColorTemperature() {
    const colorTemperature = parseInt(this.properties.ct, 10);
    if (colorTemperature > 0) return colorTemperature;
    return undefined;
  }

  getColorRgb() {
    const colorRgb = parseInt(this.properties.rgb, 10);
    if (colorRgb >= 1) return colorRgb;
    return undefined;
  }

  getColorHue() {
    const colorHue = parseInt(this.properties.hue, 10);
    if (colorHue >= 0) return colorHue;
    return undefined;
  }

  getColorSaturation() {
    const colorSaturation = parseInt(this.properties.sat, 10);
    if (colorSaturation >= 0) return colorSaturation;
    return undefined;
  }

  getMode() {
    const mode = parseInt(this.properties.color_mode,10);
    if (mode >= 1) return mode;
    return undefined;
  }


  setPower(v) {
    return this.miioCall('set_power', withLightEffect(v ? 'on' : 'off'));
  }

  setBrightness(v) {
    return this.miioCall('set_bright', withLightEffect(v));
  }

  setColorTemperature(v) {
    return this.miioCall('set_ct_abx', withLightEffect(v));
  }

  setColorHSV(v) {
    this._miioCall('set_hsv', withLightEffect([v.hue, v.saturation]));
  }

};
@Cjkeenan
Copy link

Cjkeenan commented Dec 28, 2022

I am having this issue as well. Was it ever resolved?

Is there a reason it does not follow the format of the other setters? I.E. why isn't this the setColorHSV command:
return this.miioCall('set_hsv', withLightEffect([v.hue, v.saturation]));

Also according to this it should be sat not saturation, though I am not sure that is really relevant here:
https://github.com/stason325/node-red-contrib-miio-localdevices/files/10315663/Yeelight_Inter-Operation_Spec.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants