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

Added Aqara Cube support #271

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

barbaris-in
Copy link

Aqara Cube has a device type id 68.
Used the same code as for Mi Cube (device type id 8)

@daaru00
Copy link

daaru00 commented Jan 3, 2020

Hello,

my device is correctly recognized after adding mapping to type id 68, my model name is lumi.sensor_cube.aqgl01.

When I try to listen for actions no one is fired:

device.on('action', event => {
    console.log(`Action handled!`) // never called
})
device.on('action:flip90', event => {
    console.log(`Action flip90 handled!`) // never called
})
device.on('action:rotate', event => {
    console.log('Action rotate handled!', event.amount) // never called
})

being too complex the logic of the library I am not able to do any kind of debugging... Any suggestions? Can you provide a code snippet to listen to ?

@barbaris-in
Copy link
Author

barbaris-in commented Jan 3, 2020

Hello @daaru00
Here is the list of events I receive from cube

device.on('action:rotate', (e) => logger.info('cube rotate', e))
device.on('action:flip90', (e) => logger.info('cube action:flip90', e))
device.on('action:flip180', (e) => logger.info('cube action:flip180', e))
device.on('action:move', (e) => logger.info('cube action:move', e))
device.on('action:free_fall', (e) => logger.info('cube action:free_fall', e))
device.on('action:swing', (e) => logger.info('cube action:swing', e))
device.on('action:iam', (e) => logger.info('cube action:iam', e))
device.on('action:shake_air', (e) => logger.info('cube action:shake_air', e))

Make sure that your device is your cube but not Gateway.
You can use .onAny method to see what events are fired e.g.

device.onAny(event, params => console.log(event, params);

Hope it helps

@daaru00
Copy link

daaru00 commented Jan 3, 2020

Hi,

Make sure that your device is your cube but not Gateway.

yes, I double checked and I correctly using the subdevice:

device.on('action', async data => console.log('Action handled!', data))
console.log(device)

MiioDevice {
  model=lumi.cube,
  types=controller, miio, miio:subdevice, sub-thing,
  capabilities=actions, state
}

but nothing, even using device.onAny((event, params) => console.log(event, params)) is only fired for thing:initialized and thing:metadata event, no other Cube actions..

  // Listen for all actions
  device.onAny((event, params) => {
    console.log('Action handled!', event, params)
  })

  // Bind all actions one by one
  const actions = await device.actions()
  actions.forEach(action => {
    console.log(`Start listening for action ${action.id}..`)
    device.on(`action:${action.id}`, async data => {
      console.log(`Action '${action.id}' handled! ${JSON.stringify(data)}`)
    })
  })

even adding export DEBUG=* && nodejs mytask.js I can't see no one message (after bootstrap/connection), any cube movement seems not triggering any message (or not correctly handled, not requested or pooling not working).

What's your device model? I suspect it's not the same model.. mine is lumi.sensor_cube.aqgl01

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

Successfully merging this pull request may close these issues.

None yet

2 participants