Vibration sensor Tuya Zigbee

Good evening,

I would like to pair a Tuya vibration sensor ordered on Ali: Vibration Sensor with a CC2652 BLE dongle.

It doesn’t seem to work, here is the beginning of the configuration log:

debug 2021-10-26 16:38:21: Loaded state from file /app/data/state.json
info 2021-10-26 16:38:21: Logging to console and directory: ‹ /app/data/log/2021-10-26.16-37-59 › filename: log.txt
debug 2021-10-26 16:38:22: Removing old log directory ‹ /app/data/log/2021-10-26.09-35-58 ›
info 2021-10-26 16:38:22: Starting Zigbee2MQTT version 1.21.2 (commit #4492212)
info 2021-10-26 16:38:22: Starting zigbee-herdsman (0.13.149)
debug 2021-10-26 16:38:22: Using zigbee-herdsman with settings: ‹ {"adapter":{"concurrent":null,"delay":null,"disableLED":false},"backupPath":"/app/data/coordinator_backup.json","databaseBackupPath":"/app/data/database.db.backup","databasePath":"/app/data/database.db","network":{"channelList":[11],"extendedPanID":[221,221,221,221,221,221,221,221],"networkKey":"HIDDEN","panID":6754},"serialPort":{"path":"/dev/ttyACM0"}} ›
info 2021-10-26 16:38:33: zigbee-herdsman started (resumed)
info 2021-10-26 16:38:33: Coordinator firmware version: ‹ {"meta":{"maintrel":1,"majorrel":2,"minorrel":7,"product":1,"revision":20210708,"transportrev":2},"type":"zStack3x0"} ›
debug 2021-10-26 16:38:33: Zigbee network parameters: {"channel":11,"extendedPanID":"0x00124b0022a4cbcf","panID":6754}
info 2021-10-26 16:38:33: Currently 0 devices are joined:
info 2021-10-26 16:38:33: Zigbee: disabling joining new devices.
info 2021-10-26 16:38:33: Connecting to MQTT server at mqtt://localhost:1884
debug 2021-10-26 16:38:33: Using MQTT login with username: z2m
info 2021-10-26 16:38:38: Connected to MQTT server
info 2021-10-26 16:38:38: MQTT publish: topic ‹ zigbee2mqtt/bridge/state ›, payload ‹ online ›
info 2021-10-26 16:38:40: Started frontend on port 0.0.0.0:8080
debug 2021-10-26 16:40:32: Received MQTT message on ‹ zigbee2mqtt/bridge/config/devices/get › with data ‹  ›
debug 2021-10-26 16:42:43: Received MQTT message on ‹ zigbee2mqtt/bridge/config/devices/get › with data ‹  ›
debug 2021-10-26 16:43:11: Received MQTT message on ‹ zigbee2mqtt/bridge/config/devices/get › with data ‹  ›
debug 2021-10-26 16:43:21: Saving state to file /app/data/state.json
debug 2021-10-26 16:45:43: Received MQTT message on ‹ zigbee2mqtt/bridge/config/devices/get › with data ‹  ›
debug 2021-10-26 16:48:21: Saving state to file /app/data/state.json

When I do a scan, I get the message: « No new device found »

I am using the official Gladys image, can someone help me troubleshoot, it’s the first time I use Zigbee devices.

Thanks to the community.

Hello.
You need to authorize the association (see documentation here Gérez ses appareils Zigbee dans sa domotique avec une clé USB Zigbee et Zigbee2mqtt | Gladys Assistant)

Then pair your device with the Zigbee network. The procedure depends on each device, but generally, a long press on the physical button works.

But I think no one has integrated this sensor into Gladys yet :neutral_face:
https://github.com/GladysAssistant/Gladys/blob/master/server/services/zigbee2mqtt/model/TuYa.js

There is ongoing work to integrate many more Zigbee devices.
https://github.com/GladysAssistant/Gladys/pull/1302

Thanks @cicoub13 it’s just after authorizing the association and long press that pairing doesn’t seem to work.

The log says that pairing is disabled. That’s why I was indicating these steps.
Do you have a line like that in the logs?

Zigbee2mqtt device <name> not configured in Gladys.

Eureka!
Finally, I managed to pair my vibration sensor by adding the right converter file in the /z2m folder.
I can see the payloads in the logs with the correct data, but it is still not recognized in the device list by Gladys, I still have the message: « Auncun zigbee2mqtt device has not been added yet. »
How to add it to the list?

For information, to report a small typo: the message is indeed ’ Auncun’ instead of ‹ Aucun › in the Gladys interface

Hello @jparbel!

Following your email, I think it’s better to discuss this here.

I’m not an expert in Zigbee2mqtt (I’ve never used this integration) but I can still help :smiley:

Can you be more specific about what works and what doesn’t?

@cicoub13 @AlexTrovato
My sensor is a TuYa TS0210

To make this sensor recognized, I added an external converter in the file /var/lib/gladysassistant/zigbee2mqtt/z2m/configuration.yaml:

external_converters:
** - TS0210.js**
devices:
** ‹ 0x50325ffffe031386 ›:**
** # friendly_name: ‹ 0x50325ffffe031386 ›**
** friendly_name: ‹ vibration ›**

Then I defined the file TS0210.js as follows:

const fz = require(‹ zigbee-herdsman-converters/converters/fromZigbee ›);
const tz = require(‹ zigbee-herdsman-converters/converters/toZigbee ›);
const exposes = require(‹ zigbee-herdsman-converters/lib/exposes ›);
const reporting = require(‹ zigbee-herdsman-converters/lib/reporting ›);
const extend = require(‹ zigbee-herdsman-converters/lib/extend ›);
const e = exposes.presets;
const ea = exposes.access;
const tuya = require(« zigbee-herdsman-converters/lib/tuya »);

const definition = {
** // Since a lot of Tuya devices use the same modelID, but use different data points**
** // it’s usually necessary to provide a fingerprint instead of a zigbeeModel**
** fingerprint: [**
** {**
** // The model ID from: Device with modelID ‹ TS0210 › is not supported**
** // You may need to add \u0000 at the end of the name in some cases**
** modelID: ‹ TS0210 ›,**
** // The manufacturer name from: Device with modelID ‹ TS0210 › is not supported.**
** manufacturerName: ‹ _TYZB01_3zv6oleo ›**
** },**
** ],**
** model: ‹ TS0210 ›,**
** vendor: ‹ TuYa ›,**
** description: ‹ Vibration sensor ›,**
** fromZigbee: [fz.battery, fz.ias_vibration_alarm_1_with_timeout],**
** toZigbee: [tz.TS0210_sensitivity],**
** configure: async (device, coordinatorEndpoint, logger) => {**
** const endpoint = device.getEndpoint(1);**
** await reporting.bind(endpoint, coordinatorEndpoint, [‹ genBasic ›]);**
** },**
** exposes: [**
** // Here you should put all functionality that your device exposes**
[e.battery(), e.vibration(), exposes.enum(‹ sensitivity ›, exposes.access.STATE_SET, [‹ low ›, ‹ medium ›, ‹ high ›])],
};

module.exports = definition;

If I check the logs, it is well recognized, here is an excerpt:

debug 2021-11-01 20:12:25: Received Zigbee message from ‹ vibration ›, type ‹ commandStatusChangeNotification ›, cluster ‹ ssIasZone ›, data ‹ {"extendedstatus":0,"zonestatus":1025} › from endpoint 1 with groupID 0
info 2021-11-01 20:12:25: MQTT publish: topic ‹ zigbee2mqtt/vibration ›, payload ‹ {"battery":100,"battery_low":false,"linkquality":132,"tamper":false,"vibration":true,"voltage":3000} ›
debug 2021-11-01 20:13:10: Saving state to file /app/data/state.json
info 2021-11-01 20:13:55: MQTT publish: topic ‹ zigbee2mqtt/vibration ›, payload ‹ {"battery":100,"battery_low":false,"linkquality":132,"tamper":false,"vibration":false,"voltage":3000} ›
debug 2021-11-01 20:18:10: Saving state to file /app/data/state.json

However, it does not appear in the list of devices after scanning a new device.

I tried to check on the server side: /var/lib docker/overlay2/…/server/services/zigbee2mqtt/model/tuya.js

I added my sensor in the file tuya.js:
TS0210: [features.battery, features.vibration, features.sensitivity, features.linkquality],

I also modified the file …/utils/features.js by adding the definition of the vibration value:

vibration: {
** category: DEVICE_FEATURE_CATEGORIES.VIBRATION,**
** type: DEVICE_FEATURE_TYPES.SENSOR.BINARY,**
** name: ‹ Vibration Sensor ›,**
** read_only: true,**
** has_feedback: false,**
** min: 0,**
** max: 1,**
** zigbeeField: ‹ vibration ›,**
** },**

I did not do it for the other payload values, maybe it is necessary?

After each modification, I restart the container but it still doesn’t work.

I admit that I don’t master everything, I tried to follow your last live @pierre-gilles on integrations, but I don’t quite understand the respective roles of the front and the back, to the point that I had a hard time following after a while.

But don’t spend too much time, if it’s too complicated, I ordered a Xiaomi which should be recognized by default, at least I hope so.

Another question, with Gladys 4 how to open the database, with V3, I used express-admin?

Thanks for your help.

Hi, this has changed. If you update the code, you will no longer have a tuya.js file, but a binaryType (if vibration is a boolean), with the zigbee2mqtt attribute name as the key.
You will only need to declare the category and type of the feature.

Thanks @AlexTrovato for your reply.
But could you be a bit more explicit?
Are you talking about the Gladys update? I thought it was automatic with V4, otherwise how do we do a manual update?
For now, I still have the tuya.js file.

It is indeed automatic, there’s nothing to do :slight_smile:

The PR from @AlexTrovato was merged at the beginning of the week, I will make a release in the coming days/weeks (I don’t have a date to give you on that, but it will come), and it will come automatically for you!

@jparbel I still advise you not to modify the files in the Gladys container (is that what you did?), it’s the best way to break something :smiley:

@pierre-gilles
Ah, thanks, I understand better.

For now, I’m in the testing phase with V4, so even if I break something it’s not a big deal, I don’t have anything important to lose.

Ok! In that case no worries :slight_smile:

@AlexTrovato I just tested Gladys V4.7, thank you for this release regarding the Zigbee integration.

Unfortunately, my Tuya TS0210 detector still doesn’t seem to be recognized, the device appears in the scan window and then a few seconds later it disappears and I get the following message:

Name
0x50325ffffe031386
The device is not yet supported, please contact us to help connect it in Gladys!
Propose this device

However, it is found in the state.json file

Good evening

This is an unsupported vibration sensor at the moment (like everything related to vibration)

Also, just because it is compatible with zigbee2mqtt does not mean it is supported in Gladys.

There isn’t much to do to support it, we will add it quickly

Nothing to do with it but how/why do you use it?

Thanks @VonOx my project is to equip my secondary residence with an alarm system, preferably with Zigbee for the intrusion detectors.
I had therefore started with a single sensor, which is not recognized at the moment. Since then, I have ordered a Xiaomi vibration sensor, which is perfectly recognized. I think I will equip myself with this kind of sensor in the future.
For the Tuya sensor, it’s, for the time being, just for a feedback, if it can help to integrate it…

@VonOx, you say:

But yet I see it in the available types:

Should I understand that it’s just the display on the dashboard that is missing?

EDIT: @jparbel I made a mapping error by considering that the vibration sensor was a digital sensor, whereas it is binary. I propose a fix.

I was going to reply but you edited, so it will be in the next release :+1:

@VonOx @AlexTrovato

I’ve integrated your pull request modification regarding binary vibration sensors and it works. Thanks for this integration, great job!

We still need to integrate the sensitivity to adjust the 3 levels. But maybe we can do this adjustment manually, with an MQTT client?

Good evening.

With this test image, can you check that the controllers are still working?

Because I made a change to integrate a power strip, I would like to check that I haven’t broken anything on the actuator side.

@AlexTrovato Actually, I didn’t download the test image, I just modified the 2 files related to your PR.
Which controllers and actuators are you talking about?