Skip to content

Added Aqara Cube support#271

Open
barbaris-in wants to merge 2 commits intoaholstenson:masterfrom
barbaris-in:aqara-cube
Open

Added Aqara Cube support#271
barbaris-in wants to merge 2 commits intoaholstenson:masterfrom
barbaris-in:aqara-cube

Conversation

@barbaris-in
Copy link
Copy Markdown

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

@daaru00
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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.

2 participants