Koenkk / zigbee-herdsman-converters

Collection of device converters to be used with zigbee-herdsman
MIT License
921 stars 3.04k forks source link

Add support for Zemismart ZM-L01E-Z (1 Gang) #810

Closed thedutchrockstar closed 4 years ago

thedutchrockstar commented 4 years ago
{
    zigbeeModel: ['TS0001'],
    model: 'ZM-L01E-Z',
    vendor: 'Zemismart',
    description: '1 gang switch',
    supports: 'on/off',
    fromZigbee: [fz.generic_state_multi_ep, fz.generic_power],
    toZigbee: [tz.on_off, tz.ignore_transition],
    endpoint: (device) => {
        return {'l1': 1};
    },  
},
thedutchrockstar commented 4 years ago

Let me know if this was supposed to be posted elsewhere, I'm pretty new to all of this :)

Koenkk commented 4 years ago

Does it also work with the following configuration, this removes the l1 thing which is not needed as it only exposes one endpoint.

{
    zigbeeModel: ['TS0001'],
    model: 'ZM-L01E-Z',
    vendor: 'Zemismart',
    description: '1 gang switch',
    supports: 'on/off, power',
    fromZigbee: [fz.on_off, fz.generic_power],
    toZigbee: [tz.on_off, tz.ignore_transition],
},
thedutchrockstar commented 4 years ago

I thought the same thing however I get these error messages if I remove the endpoint:

zigbee2mqtt:error 2019-12-12T19:34:40: Failed to call 'DeviceReceive' 'onZigbeeEvent' (TypeError: model.endpoint is not a function
    at Object.convert (/zigbee2mqtt-1.7.1/node_modules/zigbee-herdsman-converters/converters/fromZigbee.js:1843:47)
    at converters.forEach (/zigbee2mqtt-1.7.1/lib/extension/deviceReceive.js:144:41)
    at Array.forEach (<anonymous>)
    at DeviceReceive.onZigbeeEvent (/zigbee2mqtt-1.7.1/lib/extension/deviceReceive.js:142:20)
    at Controller.callExtensionMethod (/zigbee2mqtt-1.7.1/lib/controller.js:320:44)
    at Controller.onZigbeeEvent (/zigbee2mqtt-1.7.1/lib/controller.js:228:14)
    at Zigbee.emit (events.js:198:13)
    at Controller.herdsman.on (/zigbee2mqtt-1.7.1/lib/zigbee.js:57:52)
    at Controller.emit (events.js:198:13)
    at Controller.<anonymous> (/zigbee2mqtt-1.7.1/node_modules/zigbee-herdsman/dist/controller/controller.js:415:22))

zigbee2mqtt:error 2019-12-12T19:34:53: Failed to call 'DeviceReceive' 'onZigbeeEvent' (TypeError: model.endpoint is not a function
    at Object.convert (/zigbee2mqtt-1.7.1/node_modules/zigbee-herdsman-converters/converters/fromZigbee.js:1843:47)
    at converters.forEach (/zigbee2mqtt-1.7.1/lib/extension/deviceReceive.js:144:41)
    at Array.forEach (<anonymous>)
    at DeviceReceive.onZigbeeEvent (/zigbee2mqtt-1.7.1/lib/extension/deviceReceive.js:142:20)
    at Controller.callExtensionMethod (/zigbee2mqtt-1.7.1/lib/controller.js:320:44)
    at Controller.onZigbeeEvent (/zigbee2mqtt-1.7.1/lib/controller.js:228:14)
    at Zigbee.emit (events.js:198:13)
    at Controller.herdsman.on (/zigbee2mqtt-1.7.1/lib/zigbee.js:57:52)
    at Controller.emit (events.js:198:13)
    at Controller.<anonymous> (/zigbee2mqtt-1.7.1/node_modules/zigbee-herdsman/dist/controller/controller.js:415:22))

zigbee2mqtt:error 2019-12-12T19:40:47: Failed to call 'EntityPublish' 'onMQTTMessage' (AssertionError [ERR_ASSERTION]: Postfix 'l1' is given but device defines no endpoints
    at Zigbee.resolveEntity (/zigbee2mqtt-1.7.1/lib/zigbee.js:173:25)
    at EntityPublish.onMQTTMessage (/zigbee2mqtt-1.7.1/lib/extension/entityPublish.js:55:36)
    at Controller.callExtensionMethod (/zigbee2mqtt-1.7.1/lib/controller.js:320:44)
    at Controller.onMQTTMessage (/zigbee2mqtt-1.7.1/lib/controller.js:239:14)
    at MQTT.emit (events.js:198:13)
    at MQTT.onMessage (/zigbee2mqtt-1.7.1/lib/mqtt.js:86:14)
    at MqttClient.emit (events.js:198:13)
    at MqttClient._handlePublish (/zigbee2mqtt-1.7.1/node_modules/mqtt/lib/client.js:1162:12)
    at MqttClient._handlePacket (/zigbee2mqtt-1.7.1/node_modules/mqtt/lib/client.js:351:12)
    at work (/zigbee2mqtt-1.7.1/node_modules/mqtt/lib/client.js:283:12))

Maybe I'm missing something silly? The only other "bug" I'm getting is the following:

zigbee2mqtt:warn  2019-12-12T19:41:10: No converter available for 'ZM-L01E-Z' with cluster 'genBasic' and type 'attributeReport' and data '{"appVersion":66}'

But I get this message regardless of the endpoint

Koenkk commented 4 years ago

You probably use the wrong topic to control it? Try with zigbee2mqtt/[FRIENDLY_NAME]/set with payload TOGGLE.

thedutchrockstar commented 4 years ago

Ok so this is what I get now:

zigbee2mqtt:error 2019-12-12T20:20:31: Failed to call 'DeviceReceive' 'onZigbeeEvent' (TypeError: model.endpoint is not a function
    at Object.convert (/zigbee2mqtt-1.7.1/node_modules/zigbee-herdsman-converters/converters/fromZigbee.js:1843:47)
    at converters.forEach (/zigbee2mqtt-1.7.1/lib/extension/deviceReceive.js:144:41)
    at Array.forEach (<anonymous>)
    at DeviceReceive.onZigbeeEvent (/zigbee2mqtt-1.7.1/lib/extension/deviceReceive.js:142:20)
    at Controller.callExtensionMethod (/zigbee2mqtt-1.7.1/lib/controller.js:320:44)
    at Controller.onZigbeeEvent (/zigbee2mqtt-1.7.1/lib/controller.js:228:14)
    at Zigbee.emit (events.js:198:13)
    at Controller.herdsman.on (/zigbee2mqtt-1.7.1/lib/zigbee.js:57:52)
    at Controller.emit (events.js:198:13)
    at Controller.<anonymous> (/zigbee2mqtt-1.7.1/node_modules/zigbee-herdsman/dist/controller/controller.js:415:22))
zigbee2mqtt:info  2019-12-12T20:20:31: MQTT publish: topic 'zigbee2mqtt/slaapkamer_zemismart', payload '{"state_l1":"OFF","linkquality":15,"state":"ON"}'
zigbee2mqtt:error 2019-12-12T20:20:32: Failed to call 'DeviceReceive' 'onZigbeeEvent' (TypeError: model.endpoint is not a function
    at Object.convert (/zigbee2mqtt-1.7.1/node_modules/zigbee-herdsman-converters/converters/fromZigbee.js:1843:47)
    at converters.forEach (/zigbee2mqtt-1.7.1/lib/extension/deviceReceive.js:144:41)
    at Array.forEach (<anonymous>)
    at DeviceReceive.onZigbeeEvent (/zigbee2mqtt-1.7.1/lib/extension/deviceReceive.js:142:20)
    at Controller.callExtensionMethod (/zigbee2mqtt-1.7.1/lib/controller.js:320:44)
    at Controller.onZigbeeEvent (/zigbee2mqtt-1.7.1/lib/controller.js:228:14)
    at Zigbee.emit (events.js:198:13)
    at Controller.herdsman.on (/zigbee2mqtt-1.7.1/lib/zigbee.js:57:52)
    at Controller.emit (events.js:198:13)
    at Controller.<anonymous> (/zigbee2mqtt-1.7.1/node_modules/zigbee-herdsman/dist/controller/controller.js:415:22))
zigbee2mqtt:info  2019-12-12T20:20:32: MQTT publish: topic 'zigbee2mqtt/slaapkamer_zemismart', payload '{"state_l1":"OFF","linkquality":15,"state":"OFF"}'
zigbee2mqtt:warn  2019-12-12T20:20:53: No converter available for 'ZM-L01E-Z' with cluster 'genBasic' and type 'attributeReport' and data '{"appVersion":66}'

This how I have it set-up in hass.io

switch:
  - platform: "mqtt"
    name: "Slaapkamer Zemismart"
    state_topic: "zigbee2mqtt/slaapkamer_zemismart"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_off: "OFF"
    payload_on: "ON"
    value_template: "{{ value_json.state }}"
    command_topic: "zigbee2mqtt/slaapkamer_zemismart/set"

Probably an extremely simple oversight on my part somewhere...

thedutchrockstar commented 4 years ago

Ok I found the oversight, I still had the fromZigbee as fz.generic_state_multi_ep instead of fz.on_off... As I said, I'm still a noob in this field :)

the only message left is:

zigbee2mqtt:warn  2019-12-12T20:53:59: No converter available for 'ZM-L01E-Z' with cluster 'genBasic' and type 'attributeReport' and data '{"appVersion":66}'

For the rest everything is working as it did with the endpoint set

sjorge commented 4 years ago

Adding 'fz.ignore_basic_report' to from_zigbee should solve those I think.

Koenkk commented 4 years ago

Added, will be supported in zigbee2mqtt dev branch in a few hours.

Koenkk commented 4 years ago

It seems that for the first time in zigbee2mqtt history we run into a duplicate zigbee model, can you share your database.db so I can create a fix for this?

thedutchrockstar commented 4 years ago
{"id":1,"type":"Coordinator","ieeeAddr":"0x00124b000be89ed4","nwkAddr":0,"manufId":0,"epList":[110,11,8,6,5,4,3,2,1],"endpoints":{"1":{"profId":260,"epId":1,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[]},"2":{"profId":257,"epId":2,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[]},"3":{"profId":261,"epId":3,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[]},"4":{"profId":263,"epId":4,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[]},"5":{"profId":264,"epId":5,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[]},"6":{"profId":265,"epId":6,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[]},"8":{"profId":260,"epId":8,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[]},"11":{"profId":260,"epId":11,"devId":1024,"inClusterList":[],"outClusterList":[1280],"clusters":{},"binds":[]},"110":{"profId":260,"epId":110,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{},"binds":[]}},"interviewCompleted":false,"meta":{}}
{"id":2,"type":"Router","ieeeAddr":"0xec1bbdfffe687fad","nwkAddr":45897,"manufId":0,"manufName":"_TYZB01_3xe7wzpw","powerSource":"Mains (single phase)","modelId":"TS0001","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":256,"inClusterList":[0,3,4,5,6],"outClusterList":[25],"clusters":{"genBasic":{"attributes":{"modelId":"TS0001","manufacturerName":"_TYZB01_3xe7wzpw","powerSource":1,"zclVersion":3,"appVersion":66}}},"binds":[]}},"appVersion":66,"zclVersion":3,"interviewCompleted":true,"meta":{}}

database.zip

Happy to help!

update:

Adding 'fz.ignore_basic_report' to from_zigbee should solve those I think.

So far I'm not receiving the warnings, this seems to have worked!

Koenkk commented 4 years ago

Does the power metering work? (I cannot find if the device even supports it?? https://www.zemismart.com/eu-1-gang-2-gang-3-gang-wifi-wall-switch-work-with-alexa-smart-home-remote-control-light-panel-control-via-app-voice-control-p0250.html).

thedutchrockstar commented 4 years ago

Power metering does not work, the aliexpress listing showed it as having power metering and the code for the TS0002 (the 2 gang variant) also had this added, which is the reason I put it in.

I can't find it on the official zemismart listing either: https://www.zemismart.com/zemismart-tuya-zigbee-light-switch-3-gangs-physical-wall-switches-push-interruptor-110v-220v-p0230-p0230.html

Koenkk commented 4 years ago

I see, the problem is that a different device also uses this zigbeeModel (https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/devices.js#L5983). I need to check if the manufacturerName (from database.db) is different between these devices so we can distinguish both. But as I don't have this device anymore I need to contact someone.

Anyway, as this other device (CR Smart Home Valve control), also support on/off your device should already work fine in the latest zigbee2mqtt dev branch (besides power measurements). I will update you once I know more.

Koenkk commented 4 years ago

Btw for the time being, you can already switch to the latest dev branch and use the following device definition, this should give you access to the power readings:

{
    zigbeeModel: ['TS0001'],
    model: 'ZM-L01E-Z',
    vendor: 'Zemismart',
    description: '1 gang switch',
    supports: 'on/off, power',
    fromZigbee: [fz.on_off, fz.generic_power],
    toZigbee: [tz.on_off, tz.ignore_transition],
    meta: {configureKey: 1},
    configure: async (device, coordinatorEndpoint) => {
        const endpoint = device.getEndpoint(1);
        await bind(endpoint, coordinatorEndpoint, ['genOnOff']);
        await configureReporting.onOff(endpoint);
        await endpoint.read('seMetering', ['multiplier', 'divisor']);
    },
},
thedutchrockstar commented 4 years ago

I doubt the switch has power metering, with the new line of code I'm getting these error messages:

zigbee2mqtt:error 2019-12-15T14:46:00: Failed to configure 'slaapkamer_zemismart', attempt 1 (Error: Timeout - 45897 - 1 - 2 - 6 - 7 after 10000ms
    at Timeout.object.timer.setTimeout [as _onTimeout] (/zigbee2mqtt-1.7.1/node_modules/zigbee-herdsman/dist/utils/waitress.js:44:24)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10))

Furthermore still no reading on the sensor.

Koenkk commented 4 years ago

Can you try removing the device and re-pairing it? Maybe it configures ok then.

thedutchrockstar commented 4 years ago

Re-pairing removed the error messages! No reading on the powermetering sensor though.

Koenkk commented 4 years ago

I guess it doesn't support it then. Which means that in zigbee2mqtt 1.8.0 it should work (besides that it is identified incorrectly but this is just a cosmetic).

thedutchrockstar commented 4 years ago

Awesome, thank you!

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.