Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.22k stars 1.69k forks source link

[New device support]: WOOX R7046_V2 #16602

Closed elninosi closed 1 year ago

elninosi commented 1 year ago

Link

https://wooxhome.com/woox-r7046-smart-pir-motion-sensor-p46

Database entry

{"id":5,"type":"EndDevice","ieeeAddr":"0xa4c1381ecbadad4c","nwkAddr":1064,"manufId":4417,"manufName":"_TZ3000_sr0vaafi","powerSource":"Battery","modelId":"TS0202","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":1026,"inClusterList":[1,1280,3,0],"outClusterList":[4096,6,25,10],"clusters":{"genBasic":{"attributes":{"modelId":"TS0202","manufacturerName":"_TZ3000_sr0vaafi","powerSource":3,"zclVersion":3,"appVersion":70,"stackVersion":0,"hwVersion":1,"dateCode":""}},"ssIasZone":{"attributes":{"61441":1,"iasCieAddr":"0xe0798dfffe882952","zoneState":1,"currentZoneSensitivityLevel":1}}},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":70,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1675954798932,"defaultSendRequestWhen":"immediate"}

Comments

I tried to add new device WOOX R7046 it identifies itself in Tuya as R7046_V2.

I tried to add external converter below. Data points have been scraped through Tuya IoT platform.

It's currently not working in Zigbee2MQTT.

External converter

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 ota = require('zigbee-herdsman-converters/lib/ota');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const utils = require('zigbee-herdsman-converters/lib/utils');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
    fingerprint: [{modelID: 'TS0202', manufacturerName: '_TZ3000_sr0vaafi'}],
    model: 'R7046',
    vendor: 'WOOX',
    description: 'Motion sensor',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],

    exposes: [
        e.motion(), e.battery()
        // Here you should put all functionality that your device exposes
    ],
    meta: {
        // All datapoints go in here
        tuyaDatapoints: [
            [1, 'motion', tuya.valueConverter.trueFalse1],
            [4, 'battery', tuya.valueConverter.raw]
        ],
    },
};
    module.exports = definition;

Supported color modes

No response

Color temperature range

No response

Koenkk commented 1 year ago

Does it work with this converter?

elninosi commented 1 year ago

It's not working. I'm not getting anything in the logs.

Koenkk commented 1 year ago

How does it apear in the frontend -> state, does this get updated?

elninosi commented 1 year ago

Sorry for late reply. It does not show any states, just link quality.

slika slika

Koenkk commented 1 year ago

Probably the data points are incorrect, see https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html how to find them.

elninosi commented 1 year ago

I re-checked and data points are correct: [1, 'motion', tuya.valueConverter.trueFalse1], [4, 'battery', tuya.valueConverter.raw]

Koenkk commented 1 year ago

Could you check with this external converter:

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 ota = require('zigbee-herdsman-converters/lib/ota');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const utils = require('zigbee-herdsman-converters/lib/utils');
const globalStore = require('zigbee-herdsman-converters/lib/store');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
    fingerprint: [{modelID: 'TS0202', manufacturerName: '_TZ3000_sr0vaafi'}],
    model: 'TS0202',
    vendor: 'TuYa',
    description: 'Motion sensor',
    // Note: if occupancy: false is never send, replace fz.ias_occupancy_alarm_1 with fz.ias_occupancy_alarm_1_with_timeout
    fromZigbee: [fz.ias_occupancy_alarm_1, fz.battery, fz.ignore_basic_report, fz.ias_occupancy_alarm_1_report],
    toZigbee: [],
    exposes: [e.occupancy(), e.battery_low(), e.tamper(), e.battery(), e.battery_voltage()],
    configure: async (device, coordinatorEndpoint, logger) => {
        const endpoint = device.getEndpoint(1);
        await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg']);
        try {
            await reporting.batteryPercentageRemaining(endpoint);
        } catch (error) {/* Fails for some https://github.com/Koenkk/zigbee2mqtt/issues/13708*/}
    },
};

module.exports = definition;
elninosi commented 1 year ago

I checked with provided external converter and the result is still the same, not getting any exposes.

I tried with both "fz.ias_occupancy_alarm_1" and "fz.ias_occupancy_alarm_1_with_timeout".

Log does not show anything that would help: info 2023-02-19 10:52:17Successfully interviewed '0xa4c1381ecbadad4c', device has successfully been paired warning 2023-02-19 10:52:17Device '0xa4c1381ecbadad4c' with Zigbee model 'TS0202' and manufacturer name '_TZ3000_sr0vaafi' is NOT supported, please follow https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html info 2023-02-19 10:52:17MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"definition":null,"friendly_name":"0xa4c1381ecbadad4c","ieee_address":"0xa4c1381ecbadad4c","status":"successful","supported":false},"type":"device_interview"}' info 2023-02-19 10:52:17MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"message":"interview_successful","meta":{"friendly_name":"0xa4c1381ecbadad4c","supported":false},"type":"pairing"}' debug 2023-02-19 10:52:18Received Zigbee message from '0xa4c1381ecbadad4c', type 'commandStatusChangeNotification', cluster 'ssIasZone', data '{"extendedstatus":0,"zonestatus":0}' from endpoint 1 with groupID 0 info 2023-02-19 10:52:18MQTT publish: topic 'zigbee2mqtt/0xa4c1381ecbadad4c', payload '{"last_seen":"2023-02-19T10:52:17+01:00","linkquality":176}' debug 2023-02-19 10:52:18Received Zigbee message from '0xa4c1381ecbadad4c', type 'commandStatusChangeNotification', cluster 'ssIasZone', data '{"extendedstatus":0,"zonestatus":1}' from endpoint 1 with groupID 0 info 2023-02-19 10:52:18MQTT publish: topic 'zigbee2mqtt/0xa4c1381ecbadad4c', payload '{"last_seen":"2023-02-19T10:52:18+01:00","linkquality":176}' debug 2023-02-19 10:52:20Received Zigbee message from '0xa4c1381ecbadad4c', type 'read', cluster 'genTime', data '["localTime"]' from endpoint 1 with groupID 0 info 2023-02-19 10:52:20MQTT publish: topic 'zigbee2mqtt/0xa4c1381ecbadad4c', payload '{"last_seen":"2023-02-19T10:52:20+01:00","linkquality":148}' debug 2023-02-19 10:52:23Received Zigbee message from '0xa4c1381ecbadad4c', type 'attributeReport', cluster 'ssIasZone', data '{"61441":1}' from endpoint 1 with groupID 0 info 2023-02-19 10:52:23MQTT publish: topic 'zigbee2mqtt/0xa4c1381ecbadad4c', payload '{"last_seen":"2023-02-19T10:52:22+01:00","linkquality":152}' debug 2023-02-19 10:52:23Received Zigbee message from '0xa4c1381ecbadad4c', type 'attributeReport', cluster 'ssIasZone', data '{"currentZoneSensitivityLevel":1}' from endpoint 1 with groupID 0 info 2023-02-19 10:52:23MQTT publish: topic 'zigbee2mqtt/0xa4c1381ecbadad4c', payload '{"last_seen":"2023-02-19T10:52:23+01:00","linkquality":152}' debug 2023-02-19 10:53:18Received Zigbee message from '0xa4c1381ecbadad4c', type 'commandStatusChangeNotification', cluster 'ssIasZone', data '{"extendedstatus":0,"zonestatus":1}' from endpoint 1 with groupID 0 info 2023-02-19 10:53:18MQTT publish: topic 'zigbee2mqtt/0xa4c1381ecbadad4c', payload '{"last_seen":"2023-02-19T10:53:17+01:00","linkquality":168}'

Koenkk commented 1 year ago

It is not recognised as supported, did you add the converter file to the configuration.yaml correctly and restarted z2m?

elninosi commented 1 year ago

Sorry, my bad. Had some problems with HA.

Your solution works. "fz.ias_occupancy_alarm_1" is the right parameter.

Here is the log: 2023-02-20 19:52:27MQTT publish: topic 'zigbee2mqtt/0xa4c1381ecbadad4c', payload '{"battery":80,"battery_low":false,"last_seen":"2023-02-20T19:52:27+01:00","linkquality":160,"occupancy":true,"tamper":false,"voltage":null}' Only voltage is not reported. I'm sure this device does not report voltage.

Thanks for your help!

Koenkk commented 1 year ago

Added, voltage may also work after this change.

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)