aformusatii / node-red-contrib-xiaomi-miio

miIO device library for node red
6 stars 4 forks source link

Node-Red support for m2 version #3

Open wojtulab opened 6 years ago

wojtulab commented 6 years ago

Hello, I've installed :

npm install node-red-contrib-xiaomi-miio
npm install -g miio

In the nodered I am trying to execute any commands with failure:

for example

msg = {
    payload: {
        power: true

    }
}
return msg;

image

msg : error "TypeError: device.setPower is not a function"

Getting the status via node-red image

but the NPM can successfully detect, query or control all properties usuing miio library: miio inspect 70545715

Properties:
  - power: false
  - mode: idle
  - temperature: 20.6
  - humidity: 60
  - aqi: 49
  - favoriteLevel: 10
  - filterLifeRemaining: 99
  - filterHoursUsed: 15
  - useTime: 55200
  - led: true
  - ledBrightness: bright
  - buzzer: true

miio control 70545715 power true

INFO  Attempting to invoke power on 70545715
true

and again query the parameters: miio inspect 70545715

Properties:
  **- power: true**
  - mode: idle

Please find that my AirPurifier is a zhimi.airpurifier.m2

aformusatii commented 6 years ago

Could you try again with latest library 0.0.6, thanks.

wojtulab commented 5 years ago

Sorry for delay. Looks better for me: image I can listen to more than one device.

Temperature is readable: image

Cube motion is NOT readable still: image

miio inspect cube successfully:

INFO  Attempting to inspect 158d00027d738c

Device ID: 158d00027d738c
Model info: lumi.generic.68
Address: Owned by miio:130076930
Token: Automatic via parent device
Support: At least basic

Type info: miio, miio:subdevice, sub-thing
Capabilities:

Parent:
  Device ID: 130076930
  Model info: lumi.gateway.v3
  Address: 192.168.1.15
  Token: mytokenmytoken via stored token
  Support: At least basic
wojtulab commented 5 years ago

The resolution is: https://github.com/aholstenson/miio/issues/203

now the cube is recognized however I can't select it via node: image

image

debug: image

My question is: is it correct add: } else if (model.indexOf('generic.68') !== -1) { return 'controller';

into a: ./../common/devices.js

or another solution is better?

wojtulab commented 5 years ago

I've replace also following line in cube.html: if (device.model.indexOf('cube') !== -1) { $('#node-input-deviceId').append('<option value="' + device.id + '">' + device.id + ' ' + device.model + '</option>'); } into: if (device.model.indexOf('.generic.68') !== -1) { $('#node-input-deviceId').append('<option value="' + device.id + '">' + device.id + ' ' + device.model + '</option>'); }

After that my device is visible in nodered but without any output (tap, flip etc). image

how to correct that?

wojtulab commented 5 years ago

Hello, are u there?

aformusatii commented 4 years ago

Hey, very sorry :) have been busy, if you or anybody else need a solution for this type of issue, I would recommend using the Generic Device Listener Node, there are too many devices and it is not possible to code for all of them so in the latest version 1.0.0 of this library the listener node will listen for all events and property changes.

image