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

Installation #63

Open
waterchill opened this issue Sep 30, 2022 · 21 comments
Open

Installation #63

waterchill opened this issue Sep 30, 2022 · 21 comments

Comments

@waterchill
Copy link

Hi, in point 3 you have to fill in the xiaomi credentials in the script settings. My problem is, where are the scriptsettings? Sorry I cannot find these

@dontobi
Copy link

dontobi commented Sep 30, 2022

Have a look at lines 6 to 8 of the script.

@waterchill
Copy link
Author

waterchill commented Sep 30, 2022

ok I understand. Now I have under objects the mihomeall and my 2 devices. These are dmaker.fan.p220 also known as bplds05dm. Which plugin do I need now? Thank you

@waterchill
Copy link
Author

Ich ahbe die dmaker.fan.p15 und p18 in das Verzeichnis reinkopiert und mit iob restart alles neugestartet. Wo kann ich den Lüfter jetzt sehen? Unter Objekte oder woanders? Oder gar nicht weil ich für das Modell das Skript selber schreiben muss? Wäre für eine Hilfe dankbar

@Pittini
Copy link
Owner

Pittini commented Sep 30, 2022

Did you find your fan model in the list of supported devices? I think no, the script doesnt know a dmaker.fan.p220, so its normal that is not working. You can copy whatever you want, if its not for your device, it doesnt works.

@waterchill
Copy link
Author

So I have to go now for this description right?

https://github.com/Pittini/iobroker-nodemihome/blob/main/HowToAddNewDevices.md

@Pittini
Copy link
Owner

Pittini commented Sep 30, 2022

Yes. But you havent found the scriptsettings, so I assume, maybe your skills are not enough.

@waterchill
Copy link
Author

We will see, I will take look on this later.

@waterchill
Copy link
Author

waterchill commented Sep 30, 2022

So I have tried two versions, in both cases objects created, but cannot power on the fan. There is "false" in red. Here are my examples:

The filename is always which is uploaded correctly: dmaker.fan.p220.js

In the script:

DefineDevice[28] = { // Untestet
    info: {},
    model: "dmaker.fan.p220",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p220:1
    description: "Mi Smart Standing Fan (with Battery)",
    setter: {
        "fan.on": async function (obj, val) { await device[obj].setPower(val) }
    },
    common:
        [{ name: "fan.on", type: "boolean", role: "switch", read: true, write: true }]
};

In the file:

const Device = require('../device-miio');

module.exports = class extends Device {

static model = 'dmaker.fan.p220';
static name = 'Mi Smart Standing Fan (with Battery)';
static image = 'http://static.home.mi.com/app/image/get/file/developer_1543307568u9wu6wij.png';

  constructor(opts) {
    super(opts);

    this._miotSpecType = 'urn:miot-spec-v2:device:fan:0000A005:dmaker-p220:1';
    this._propertiesToMonitor = [
        'fan:on'
    ];
  }

   getPower() {
     return this.properties['fan:on'];
  }

};

Second try:

In the script:

DefineDevice[28] = { // Untestet
    info: {},
    model: "dmaker.fan.p220",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p220:1
    description: "Mi Smart Standing Fan (with Battery)",
    setter: {
        "power": async function (obj, val) { await device[obj].setPower(val) }
    },
    common:
        [{ name: "power", type: "boolean", role: "switch", read: true, write: true, min: false, max: true }]
};

In the File:

const Device = require('../device-miio');

module.exports = class extends Device {

static model = 'dmaker.fan.p220';
static name = 'Mi Smart Standing Fan (with Battery)';
static image = 'http://static.home.mi.com/app/image/get/file/developer_1543307568u9wu6wij.png';

constructor(opts) {
  super(opts);

  this._propertiesToMonitor = [
      'power'
  ];
}

setPower(v) {
  return this.miotSetProperty('power', v);
}


};

There are no errors in th the log. Any thoughts? By the way I have two of exact same fans here, maybe this is a problem?

@waterchill
Copy link
Author

ok I got it to work 😊

File:

const Device = require('../device-miio');

 module.exports = class extends Device {

   static model = 'dmaker.fan.p220';
   static name = 'Mi Smart Standing Fan (with Battery)';
   static image = 'http://static.home.mi.com/app/image/get/file/developer_1541408255kg3xtr1j.png';

   constructor(opts) {
     super(opts);

     this._miotSpecType = 'urn:miot-spec-v2:device:fan:0000A005:dmaker-p220:1';
     this._propertiesToMonitor = [
      'fan:on',
      'fan:fan-level'
      ];
  }
 
  getPower() {
    return this.properties['fan:on'];
  }
   
  setPower(v) {
    return this.miotSetProperty('fan:on', v);
  }
 
  setFanLevel(v) {
    return this.miotSetProperty('fan:fan-level', v);
  }



};

File:

DefineDevice[28] = { // Untestet
    info: {},
    model: "dmaker.fan.p220",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p220:1
    description: "Mi Smart Standing Fan (with Battery)",
    setter: {
        "fan.on": async function (obj, val) { await device[obj].setPower(val) },
        "fan.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }
   
    },
    common:
        [{ name: "fan.on", type: "boolean", role: "switch", read: true, write: true },
        { 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" } }
        ]
};

@Pittini
Copy link
Owner

Pittini commented Sep 30, 2022

Congratulations, well done. Does this fan have only two settings?

@waterchill
Copy link
Author

Thanks. This fans has a lot of functions but I need for iobroker only speed and power.

@waterchill
Copy link
Author

waterchill commented Oct 5, 2022

This fan can also adjust speed level by 1% from 0% to 100%. I would like to add this feature, so I spotted in the urn file this part:

{
      "iid": 8,
      "type": "urn:dmaker-spec:service:dm-service:00007802:dmaker-p220:1",
      "description": "dm-service",
      "properties": [
        {
          "iid": 1,
          "type": "urn:dmaker-spec:property:speed-level:00000001:dmaker-p220:1",
          "description": "speed-level",
          "format": "uint8",
          "access": [
            "write",
            "read",
            "notify"
          ],
          "value-range": [
            1,
            100,
            1
          ]
        },

I added this to the script:

DefineDevice[28] = { // Untestet
    info: {},
    model: "dmaker.fan.p220",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p220:1
    description: "Mi Smart Standing Fan (with Battery)",
    setter: {
        "fan.on": async function (obj, val) { await device[obj].setPower(val) },
        "fan.speed-level": async function (obj, val) { await device[obj].setFanLevel(val) },
        "fan.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }
   
    },
    common:
        [{ name: "fan.on", type: "boolean", role: "switch", read: true, write: true },
        { name: "fan.speed-level", type: "number", read: true, write: true, min: 1, max: 100, unit: "%" },
        { 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" } }
        ]
};

And to the definition file:

const Device = require('../device-miio');

 module.exports = class extends Device {

   static model = 'dmaker.fan.p220';
   static name = 'Mi Smart Standing Fan (with Battery)';
   static image = 'http://static.home.mi.com/app/image/get/file/developer_1541408255kg3xtr1j.png';

   constructor(opts) {
     super(opts);

     this._miotSpecType = 'urn:miot-spec-v2:device:fan:0000A005:dmaker-p220:1';
     this._propertiesToMonitor = [
      'fan:on',
      'fan:fan-level',
      'fan:speed-level'
      ];
  }
 
  getPower() {
    return this.properties['fan:on'];
  }
   
  setPower(v) {
    return this.miotSetProperty('fan:on', v);
  }
 
  setFanLevel(v) {
    return this.miotSetProperty('fan:fan-level', v);
  }

  setSpeedLevel(v) {
    return this.miotSetProperty('fan:speed-level', v);
  }


};

But it will not work. Please can you help me to fix this? Thank you

@waterchill
Copy link
Author

Maybe this will help

Bildschirmfoto 2022-10-05 um 13 12 06

@Pittini
Copy link
Owner

Pittini commented Oct 5, 2022

fan:speed-level is not shown. You have to use fan:fan-level OR dm-service:speed-level (I dont know the difference between those two)

@waterchill
Copy link
Author

waterchill commented Oct 5, 2022

fan-level is only 4 steps. slow - middle - high - turbo speed
speed-level has 100steps in 1% from 0% to 100% fan speed

I tried this now and it looks good now so far:

DefineDevice[28] = { // Untestet
    info: {},
    model: "dmaker.fan.p220",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p220:1
    description: "Mi Smart Standing Fan (with Battery)",
    setter: {
        "fan.on": async function (obj, val) { await device[obj].setPower(val) },
        "dm-service:speed-level": async function (obj, val) { await device[obj].setSpeedLevel(val) },
        "fan.fan-level": async function (obj, val) { await device[obj].setFanLevel(val) }
   
    },
    common:
        [{ name: "fan.on", type: "boolean", role: "switch", read: true, write: true },
        { name: "dm-service:speed-level", type: "number", read: true, write: true, min: 1, max: 100, unit: "%" },
        { 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" } }
        ]
};

And in the File:

const Device = require('../device-miio');

 module.exports = class extends Device {

   static model = 'dmaker.fan.p220';
   static name = 'Mi Smart Standing Fan (with Battery)';
   static image = 'http://static.home.mi.com/app/image/get/file/developer_1541408255kg3xtr1j.png';

   constructor(opts) {
     super(opts);

     this._miotSpecType = 'urn:miot-spec-v2:device:fan:0000A005:dmaker-p220:1';
     this._propertiesToMonitor = [
      'fan:on',
      'fan:fan-level',
      'dm-service:speed-level'
      ];
  }
 
  getPower() {
    return this.properties['fan:on'];
  }
   
  setPower(v) {
    return this.miotSetProperty('fan:on', v);
  }
 
  setFanLevel(v) {
    return this.miotSetProperty('fan:fan-level', v);
  }
  
  setSpeedLevel(v) {
    return this.miotSetProperty('dm-service:speed-level', v);
  }
  

};

I have no idea if the syntax is ok. Can you check please? Thank you

@Pittini
Copy link
Owner

Pittini commented Oct 5, 2022

I have no idea if the syntax is ok. Can you check please? Thank you

Looks good for me. And if it works, the syntax is ok, every error leads to malfunktions.

@waterchill
Copy link
Author

It seems to work, but the numbers are always shown in red color. So I can set every number and the fan is reacting. But when I set on level for example level 2 the numbers in speed level do not change. Maybe there is something missing, something like a backchannel or a refresh for this object.

@Pittini
Copy link
Owner

Pittini commented Oct 5, 2022

Red color is ok, that means there is no ack flag set, what is normal for manual written values. The not synched values behaviour maybe will set the right value at next refresh (10seks if not changed). If not...how is the behaviour in the orig app?

@waterchill
Copy link
Author

When set in iobroker for example 27% it goes in the app within 1 second to 27% and so on. When I change the value in the app nothing happens in iobroker.

@waterchill
Copy link
Author

So far it has worked very well. Today I rebooted my Raspi and now I get this error, I donÄt understand it:

Bildschirmfoto 2022-10-18 um 17 15 46

@waterchill
Copy link
Author

I found out for some reason the file dmaker.fan.p220 was deleted. I copied again and now it works.

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

3 participants