GithubHelp home page GithubHelp logo

Comments (2)

Bluebie avatar Bluebie commented on June 5, 2024

TypeError: Cannot read property 'then' of undefined at Object.<anonymous> means '.promise' doesn't exist. when you have .promise, you get undefined, and when you try to run .then() on that, you get the typeerror. getProperties returns a regular object, not something you can get a promise on. It returns the data immediately.

var value = device.getProperties([ 'aqi', 'temp_dec', 'humidity' ])
console.log(value)

should output something like:

{
  "aqi": 3,
  "temp_dec": 20,
  "humidity": 50
}

(just guessing at values)

from miio.

aholstenson avatar aholstenson commented on June 5, 2024

As commented before, getProperties does not return a Promise. Instead it returns the previously loaded properties, using names as defined by the type of device. Refer to the documentation for details about the properties available.

If you want to load properties from the device using the internal names you can use loadProperties(arrayWithNames) to do so.

In addition, please do not use createDevice unless you have a use case where you need it. If your use case actually requires it, you have to call init and wait for it to resolve before doing anything else with the device. It is recommended to use miio.device() instead which will resolve the correct model and initialize the device before resolving its promise.

from miio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.