-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[New device support]: Aqara Cube T1 Pro support request #15652
[New device support]: Aqara Cube T1 Pro support request #15652
Comments
+1 from me - just purchased a Cube T1 Pro, not realising it's not yet supported. I'm happy to help with figuring out how to integrate it - but creating a custom converter is beyond my (very limited) abilities. It's really difficult to test too, because some cube actions seem to trigger every zigbee device on the network |
+1! |
From what I understand, the most important parts are the "fromZigbee" key (to process the input) and the "exposes" key (to output the entities that are displayed on HA). On the older version, they've created custom methods for the zigbee input processing. Maybe taking inspiration from there could lead us somewhere. |
What is logged to the debug log when triggering actions on this device? See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging. |
I couldn't get it to log anything at all when I enabled debug logging - I'm bound to be doing something wrong. Part of the problem is that even without any external converter, the cube does weird 'stuff', messing with every other zigbee device - so there's a lot of noise to contend with. In response to @dabrahim 's comment - I played with the converter you specified at the top of this post, but couldn't get the device to show any values in Zigbee2MQTT |
T1 Pro is a lot different than the classic cube.
UPDATE 1/3 Pressing the LINK/PAIRING button 5 times can toggle between the two modes. Some folks reporting my converter code doesn't work, and they run into debug messages like this: Debug 2023-01-03 21:52:45 - Received Zigbee message from '0x54ef44100062c386', type 'commandToggle', cluster 'genOnOff', data '{}' from endpoint 1 with groupID 0
Debug 2023-01-03 21:52:45 - No converter available for 'CTP-R01' with cluster 'genOnOff' and type 'commandToggle' and data '{}' It never occurred to me, I guess it could be because the cube needs the Aqara Home app for initial configuration, and I happen to have an Aqara hub and played with that first before pairing to Z2M and coding my converter. Anyways, Here's my code, feel free to take it: /**
# Two Modes
## Scene Mode
- rotate
- shake
- hold
- side up
- trigger after one-min inactivity
## Action Mode
- slide
- rotate
- tap twice
- flip90, flip180
- shake
- trigger after one-min inactivity
# Clusters (Scene Mode):
## Endpoint 2:
| Cluster | Data | Description |
| ------------------ | ------------------------- | ----------------------------- |
| aqaraopple | {329: 0-5} | i side facing up |
| genMultistateInput | {presentValue: 0} | action: shake |
| genMultistateInput | {presentValue: 4} | action: hold |
| genMultistateInput | {presentValue: 2} | action: wakeup |
| genMultistateInput | {presentValue: 1024-1029} | action: fall with ith side up |
## Endpoint 3:
| Cluster | Data | Desc |
| --------- | ------------------------------------- | ------------------------------------------ |
| genAnalog | {267: 500, 329: 3, presentValue: -51} | 267: NA, 329: side up, presentValue: angle |
*/
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const xiaomi = require('zigbee-herdsman-converters/lib/xiaomi');
const e = exposes.presets;
const ea = exposes.access;
const OPS_MODE = {
ACTION: 0,
SCENE: 1,
};
const ops_mode_lookup = { 0: 'action mode', 1: 'scene mode' };
const aqara_opple = {
cluster: 'aqaraOpple',
type: ['attributeReport', 'readResponse'],
options: (definition) => [
...xiaomi.numericAttributes2Options(definition),
exposes.enum('operation_mode', ea.STATE, ['scene mode', 'action mode']),
],
convert: (model, msg, publish, options, meta) => {
// console.log('>>>> ops mode', meta.state.operationMode);
if (msg.data.hasOwnProperty('155') || msg.data.hasOwnProperty('328')) {
const ops_mode = msg.data['155'] || msg.data['328'];
meta.state.operationMode = ops_mode;
}
const operation_mode = ops_mode_lookup[meta.state.operationMode];
return {
...xiaomi.numericAttributes2Payload(msg, meta, model, options, msg.data),
operation_mode,
action: 'side_up',
side_up: msg.data['329'],
};
},
};
const action_multistate = {
...fz.MFKZQ01LM_action_multistate,
convert: (model, msg, publish, options, meta) => {
if (meta.state.operationMode === OPS_MODE.ACTION) {
return fz.MFKZQ01LM_action_multistate.convert(
model,
msg,
publish,
options,
meta
);
} else {
const value = msg.data['presentValue'];
let scene_action_multistate;
if (value === 0) scene_action_multistate = { action: 'shake' };
else if (value === 2) scene_action_multistate = { action: 'wakeup' };
else if (value === 4) scene_action_multistate = { action: 'hold' };
else if (value >= 1024)
scene_action_multistate = { action: 'side_up', side_up: value - 1024 };
return scene_action_multistate;
}
},
};
const definition = {
zigbeeModel: ['lumi.remote.cagl02'],
model: 'CTP-R01',
vendor: 'Lumi',
description: 'Aqara cube T1 Pro',
meta: { battery: { voltageToPercentage: '3V_2850_3000' } },
fromZigbee: [aqara_opple, action_multistate, fz.MFKZQ01LM_action_analog],
toZigbee: [],
exposes: [
/* Device Info */
e.battery(),
e.battery_voltage(),
e.device_temperature(),
e.power_outage_count(false),
exposes
.enum('operation_mode', ea.STATE, ['scene mode', 'action mode'])
.withDescription(
'Press LINK button 5 times to toggle between action mode and scene mode'
),
/* Actions */
e.angle('action_angle'),
e.cube_side('action_from_side'),
e.cube_side('action_side'),
e.cube_side('action_to_side'),
e.cube_side('side').withDescription('Destination side of action'),
e.cube_side('side_up').withDescription('Upfacing side of current scene'),
e.action([
'shake',
'wakeup',
'fall',
'tap',
'slide',
'flip180',
'flip90',
'hold',
'side_up',
'rotate_left',
'rotate_right',
]),
],
};
module.exports = definition; |
I tried using the external converter code provided by @JJPro and although the cube is now correctly identified by Z2M (including sensor, configuration and diagnostic entities), they all report N/A or Unknown states. |
Do you mean the following:
It's normal you see null values, cause they only contain values while in motion, and change very fast and won't get a chance to show in z2m frontend. If you take a look at the z2m logs or node-red debug console, you'll see their values being logged.
I don't have this issue. Could it be the gateway you use? T1 Pro requires Zigbee 3.0. I'm using SONOFF Dongle Plus-E. |
@JJPro, thank you for the reply. My logs are not reporting any activity from the Cube T1 Pro. As for the dongle, I'm using the SONOFF Dongle Plus-P, which supports Zigbee 3.0 as well. The configuration is correct, so I'm not really sure why this is happening. |
I have a similar problem. The only activity i see in my logs is from endpoint 1 cluster "genOnOff". These messages are empty but are toggling all of my devices on/off, despite having no automation set up. |
@filipeaparicio91 @sjohannsen1 I've updated code in my original comment. Last night, I reset my cube and found all my actions failing to work. Then I figured the cube is now in action mode (which works exactly like the classic cube). Most likely during my last experiment, I have switched its operation mode to scene mode in Aqara Home app before pairing to Z2M, and the mode was saved. I wasn't aware of the situation, and assumed that to be the default operation mode. Now the code has been updated, it should pull data in correctly, and work like the classic cube. I still haven't figured how to switch between modes yet. For your issue randomly toggling other devices on/off, it yet haven't occurred to me. |
@JJPro,
I keep getting these entries when I shake the cube and occasionally when I rotate it on a random side. I continue not getting any values reported in Z2M, even in the info logs. As for the connection, it is currently connected through a router (which supports Zigbee 3.0), but the same behavior was observed when connected directly to the coordinator. |
I'm having this exact same issue. I have noticed this behavior Rotate: Tap: Attempt to switch modes by pressing the reset button 5x: |
Hey, I updated my code again in original comment, Now it's working on both scene mode and action mode. Pressing the LINK button 5 times to toggle between them. I never saw the I only have one cube and can't start from fresh to cover the |
So your comment about the device being configured when you first connected it to the aqara hub got me thinking and I think I'm onto something. Here's a snippet from your code with the added configure section
I'm not sure if this is complete and fully configured but I am finally starting to see the proper actions.
I also needed to comment out these lines (55 and 68): |
You two are getting somewhere! Commenting lines 55 & 68 was not required for my cube to start behaving correctly. I have not tried any automation yet, but the action mode is showing some inconsistent behaviours. For example, occasionally it becomes stuck on one of the sides and does not update until a rotate or shake action happens. Using the scene mode is much more reliable, and accurately reports the side facing up every time.
Nevertheless, this is a massive improvement and I can finally start testing the cube without having my lights flashing all the time. |
Thank you @JJPro & @jzee923! The cube is finally reporting correctly with the addition of your code.
adapted from "zigbee-herdsman-converters/converters/fromZigbee" I added:
and changed @JJPro converters by adding the old converter with updated sides:
Now everything works consistently and as it should for me. |
@sjohannsen1 this works! I had to reformat some of the else statements as Z2M was not starting, and it's now reporting the correct side every time. Here is the full working code:
EDIT: I just tried automating the cube while in "scene mode" and everything runs smoothly. Using MQTT as the trigger to listen to "zigbee2mqtt/[YOUR_CUBE_NAME]/action", I can choose between "tap", "side_up", "rotate_left", "rotate_right", "hold", "shake" and "wakeup" payloads in combination with the "Side up" sensor. As previously mentioned, I think the last missing piece is being able to change the Operation mode directly on HA or Z2M without having to open the cube. |
I'm fairly certain we need to create or use an existing converter in toZigbee in order for this to work. |
@CrazyCoder no, |
Thank you all for your support ! I was finally able to set up the cube and trigger a few events ! The only event I'm failing to trigger so far is the "double tap" one. Aside from that everything works flawlessly on my side. |
How do you find the data points (0x0148, 0x20) to overwrite? I'm still new to z2m, there's a lot to learn. Thanks~ |
0x0148 is just 328 in hex. (the value we were seeing for changing modes)
I saw this in there and just gave it a shot So datatype: 32 translates to 0x20 in hex. But this wasn't working. |
Hi, thanks all for your great job. I've started a thread (#15956) yesterday for this device but your job is much more advanced.
|
@Rhysgh r u talking about Null values for battery stuff? Those info takes a long time to show. It's normal for battery powered devices. |
I would try to remove/unlink and add the device again - maybe even a couple of times. |
Ok tried deleign (forece reoved) , reatrted and readded .. i noticed the values where N/A and then changed to Null .. but are always Null nomatter what I try.. and the avalibility is still disabled. |
@Rhysgh, when you perform an action on the cube, does Z2M produce any logs? You should be seeing a payload with the action show up when you rotate, flip, shake, etc.
This will trigger the automation when an action payload is detected by MQTT, and only perform it if the cube was rotated left. The Availability showing up as "Disabled" is standard on Z2M. To change this you need to modify your Z2M configuration: https://www.zigbee2mqtt.io/guide/configuration/device-availability.html EDIT: If you want to enable availability, edit your configuration.yaml in the zigbee2mqtt folder and add this line: |
Make sure you're using the latest code (https://github.com/JJPro/CTP-R01-converter/blob/trunk/CTPR01.js) |
@Rhysgh |
I used this file - https://github.com/JJPro/CTP-R01-converter This is my setup. Is that correct? |
@Rhysgh |
I am on Home Assistant 2023.2.0b7 maybe that's an issue? |
Also check your battery, the first screenshot you posted has a linkquality of 42. That's probably too low. |
The pairing process will draw a lot of power. |
The minimum working linkquality from my experiment, just tested minutes ago, in my environment, is around 67. |
Hey @Rhysgh, telegram me if u still need help diagnosing the problem. Let me know. |
Ah shoot, already added. I just saw this pop up on the 2023.2 HA update log:
|
@amaisano It's nothing about the converter. z2m emits empty action values when you have home assistant integration enabled. See here., and the empty value ( After looking at HA codebase, it's the newly introduced |
Has anyone noticed that the temp reported by this thing is always 25C? I even see it in the shared logs and cube data above from other users. It should currently be reading about 15c... Always 25. operation_mode: 'scene_mode',
voltage: 3061,
battery: 100,
device_temperature: 25,
power_outage_count: 17,
current: 0,
... |
yes, it's always 25°C for me as well. |
The device reports static temperature 25 °C, rendering |
What a shame. I use that as a sensor on the old cubes... Related / unrelated question. @JJPro ... |
@SirGoodenough |
Hi everyone, The scene mode of the new cube is amazingly accurate indeed. I wanted to ask if anyone else experiences the same (inconsistent) behaviour of the cube as I do:
This second message/payload:
So, it feels a bit like 'rotating_left' and 'rotating_right' directly is not working as expected right now? In the ideal situation, you would like to choose a face up - like 'lights on' and use rotate_left/right to dim those lights directly. Or have consistent feedback when using the cube and rotating left or right. Or maybe I'm missing something here? What are you guys thinking? |
Hi @NicoQubo, I see what you were trying to achieve. If I understand you correctly, you want to achieve "rotating on side change", e.g. turning on lights and dimming at the same time.
That is the expected behavior.
Hope this clears your confusion. |
Hi @JJPro, Thanks for your insightful reply! There was something in what you said that triggered me. This sounds pretty obvious, but actually was the key for me! I now also understand the inconsistency in 1. and 2., because I wasn't aware that my hand resting on the cube in between actions influenced the sensors! I probably sometimes 'let go' or 'rested hand on it' which obviously gave these weird reports. So: THANKS for that brilliant remark.
In both these cases: I placed down the cube and probably sometimes removed my hand from it in advance of wanting to rotate. I tried 'placing down, letting go and rotating' a dozen times now, and it works every time. |
Link
https://www.aqara.com/en/product/cube-t1-pro
Database entry
{"id":5,"type":"EndDevice","ieeeAddr":"0x54ef44100062e05a","nwkAddr":25105,"manufId":4447,"manufName":"LUMI","powerSource":"Battery","modelId":"lumi.remote.cagl02","epList":[1,2,3],"endpoints":{"1":{"profId":260,"epId":1,"devId":259,"inClusterList":[0,3,6],"outClusterList":[0,3],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}},"2":{"epId":2,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}},"3":{"epId":3,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":25,"stackVersion":2,"hwVersion":1,"dateCode":"20220602","swBuildId":"2019\u0000www.","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1671404743897,"defaultSendRequestWhen":"immediate"}
Comments
I tried creating a custom converter using the one already exisiting for the older model MFKZQ01LM but I was stuck at some point, I didn't know how to properly fill the fromZigbee array in.
External converter
Supported color modes
No response
Color temperature range
No response
The text was updated successfully, but these errors were encountered: