zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Legrand 067646

Open cocapic opened this issue 1 year ago • 20 comments

What happened?

inconsistant actions results

I have 11 Legrand 067646 shutter switch, firmware 1e or latest 46

actions reported are not consistant ! we need to press multiple time trying all possibility to have a miracle : the right action executed

I recently moved from deconz and switchs have a different behavior on it :

Montée : 1002 / Montée puis relâché : 1002/3002 Descente : 2002 / Descente puis relâché : 2002/3003 Les deux en même temps : 3003

And consistant actions, everything related was working fine

Is there annyway to change z2m interpretation of what the switch is giving ?

support of this product need to be removed, nothing at all can be done

Regards

What did you expect to happen?

consistant operation

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

1.37.0 commit: ee5cf5a

Adapter firmware version

20230507

Adapter

sonoff

Setup

pi5 jeedom

Debug log

No response

cocapic avatar May 23 '24 08:05 cocapic

Hello

Are you using binding? If yes, binding to a group or a device?

Antoine

Tonio16 avatar May 23 '24 19:05 Tonio16

Hi,

No binding, automation thru Jeedom behind

Merci, Regards

cocapic avatar May 23 '24 21:05 cocapic

Hello, Exactly same problem here on 1.36.1 Inconsistent, I need to press 10 or 20 times a button for it to work. What is weird is the logs :

In exemple, I pressed the close button, nothing happened in Home assistant and I've got these lines in the logs :

**Info 2024-06-13 19:25:46**MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"friendly_name":"Volet parents","ieee_address":"0x0004740000a97b5b"},"type":"device_announce"}'

**Debug 2024-06-13 19:25:46**Received Zigbee message from 'Volet parents', type 'commandDownClose', cluster 'closuresWindowCovering', data '{}' from endpoint 1 with groupID 0

**Debug 2024-06-13 19:25:46**Received Zigbee message from 'Volet parents', type 'readResponse', cluster 'genPowerCfg', data '{"batteryVoltage":29}' from endpoint 1 with groupID 0

**Info 2024-06-13 19:25:46**MQTT publish: topic 'zigbee2mqtt/Volet parents', payload '{"action":null,"battery":null,"linkquality":66,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null,"voltage":2900}'

And each times I have a trouble i have the same 2 infos :

  1. I do have the "received Zigbee message" with the correct type
  2. I have "MQTT publish" with "action: null"

I think the problem is the "action: null" whereas the right zigbee message seems received

pipolaq avatar Jun 13 '24 17:06 pipolaq

Hi pipolaq,

im new on Z2M, did you have this issue previously ? i have 11 swith, a nightmare, thinking moving back on deconz

regards

cocapic avatar Jun 14 '24 07:06 cocapic

Hi @cacapic, I just received these legrand shutter switch a few days ago, so first time I linked them to Z2M. I added some legrand wired shutter switch, everything went well (including OTA) and they work perfectly with Z2M. But I have troubles with my wireless switch. I should receive 4 new wired shutter switch next week, I'll see how it goes !

Does someone understand why Z2M seems to receive the right order, but doen't send it to MQTT ?

Thanks !

pipolaq avatar Jun 14 '24 09:06 pipolaq

Hi,

if you need more shutter wireless switch, dont hesitate to come back to me, I sell them :)

regards

cocapic avatar Jun 21 '24 06:06 cocapic

same issue in 1.39.0

but i noticed something strange, i came home 2 hours after upgrade and tested all switchs and all was working fine, then this morning all dead again Is it something reset during the update or else that will having all of them working correctly?

regards

cocapic avatar Jul 05 '24 14:07 cocapic

Hello @cocapic

I have the same issue with this Legrand device. In Jeedom, with JeeZigbee, I've receive 99% of the time only "stopped", and some time "Open" then "Stopped" (or "Close" then "Stopped").

I've just discover that in the Zigbee2MQTT local webpage, on the device, I can clearly see, each time I press one button "Open" then "Stopped" (or "Close" then "Stopped").

So for me there is a bug, or a wrong configuration, between Zigbee2MQTT and JeeZigbee. I'm searching now in that way... and I will post any solution if I found it.

Regards

collicalex avatar Jul 24 '24 08:07 collicalex

Hi @collicalex,

You think about something between z2m and jeedom like action too short in duration to trigger in jeedom ?

hum yes something is happening but right action before stopped 100% not sure

++

cocapic avatar Jul 24 '24 10:07 cocapic

I see that @pipolaq has the same behavior using Home Assistant, so i think this may not be related to jeedom or home assistant but to z2m

hlehoux2021 avatar Jul 24 '24 13:07 hlehoux2021

Hello,

So, after some help of Jeedom staff, Zigbee2MQTT have a default parameter of 0.3s to temporary send back data. I've put it to 0 (re-launch deamon) and now it's working fine at 99% of time. Some time it's still sending only "stopped", but I can also see this in Zigbee2MQTT interface...

collicalex avatar Jul 24 '24 15:07 collicalex

hi,

where is this parameter ?

ty

cocapic avatar Jul 25 '24 08:07 cocapic

In Jeedom, you have to go in menu Plugins > Programmation > MQTT Manager Then go to Configuration. And you have a parameter named Cycle with value 0.3

I've put 0, Save, and restart the deamon.

I've also gone back to Plugins > Protocol Domotique > JeeZigBee and restart the daemon.

collicalex avatar Jul 25 '24 09:07 collicalex

Hum MQTT Manager is used by other things, hope will not have other impact

will try, many thanks

cocapic avatar Jul 25 '24 09:07 cocapic

Also it's better in Jeedom...

But the Legrand shutter is still do some incomprehensible message sending... Sometime push the up or down button send Open/Stopped or Close/Stopped very well. Sometime it's sending only Stopped...

I do not understand what's Legrand done with this shutter :/ They just have to send 1 command per button : Open / Close or Stop (central button); that's all. Here they try to complicate everything sending muti states per button.

collicalex avatar Jul 25 '24 09:07 collicalex

it's not device or legrand fault

those 067646 switch and globally legrand devices was perfectly working with deconz on jeedom

thats why im asking to remove 067646 as a suported z2m device

im moved deconz to z2m and now need to move back

cocapic avatar Jul 25 '24 10:07 cocapic

Deconz work only with a conbee key? I have a sonoff zdongle-e

collicalex avatar Jul 25 '24 10:07 collicalex

Also with Deconz, do you see Open then Stopped / Close then Stopped messages?

collicalex avatar Jul 25 '24 10:07 collicalex

dont remembrer key, will check once back from vacation :)

code received from switch in deconz Montée : 1002 / Montée puis relâché : 1002/3002 Descente : 2002 / Descente puis relâché : 2002/3003 Les deux en même temps : 3003

cocapic avatar Jul 25 '24 12:07 cocapic

Also, I just use a Conbee II usb receiver instead of the Sonoff ZDongle-E. I've also some troubles with received message. I think the device send the 2 messages too fast and some are just not seen.

In the device page, Expose page. In the Action we can see the value. It's really really quick but 2 values are displayed Open then Stopped (or Close then Stopped), when it's working. When it's not.. we can see only Stopped value (no quick change).

Also when the message is sent to Jeedom (via MQTT) I can see that sometime it sent Stopped then Open values (i.e. not the correct order) even if that the last message displayed in Device page > Expose > Action is "Stopped".

collicalex avatar Jul 26 '24 12:07 collicalex

Hello,

So I've made some search...

The decoding of zigbee messages from Legrand device (and this one 67646) is done via https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/legrand.ts

For our device (search for the id 67646), lines 110-137, there is a fz.legrand_binary_input_moving line 122.

As per a comment on this post https://github.com/Koenkk/zigbee2mqtt/issues/15101 this if for "support binary report on moving state (supposed)".

But the device 67646 is a wireless buttons for shutter. How can the device know if the shutter is moving or stopped? It's impossible. It must only expose the 3 commands: open, close, stop.

I think the problem come from here, it try to decode something for nothing and add / put some wrong messages...

@Koenkk is it possible to patch this file locally to test? How?

Regards

collicalex avatar Jul 29 '24 08:07 collicalex

Hello,

I've successfully make it usable!

The solution / hack is to edit the file /var/www/html/plugins/z2m/resources/zigbee2mqtt/node_modules/zigbee-herdsman-converters/devices/legrand.js and remove all binary stuff for our 67646 device.

Here for the step by step :

  1. Firstly stop Z2M In Jeedom, go to Plugins > Gestion des Plugins > JeeZigbee Stop the deamon

  2. Go to Jeedom machine (VNC, SSH,...) Go to the directory cd /var/www/html/plugins/z2m/resources/zigbee2mqtt/node_modules/zigbee-herdsman-converters/devices/

    Find the line where the Legrand Shutter model number 067646 is configured: cat legrand.js | grep -n 067646

    It display something like: 137: model: '067646', --> The line, for my file, is 137

    Edit the file (as root) sudo vi legrand.js

    Scroll down until the line 137

    Remove the line 148 which contains fromZigbee_1.default.legrand_binary_input_moving

    In line 150, which contains : expose:[e.battery(), e.action(['identify', 'open', 'close', 'stop', 'moving', 'stopped']) Remove ,'moving', 'stopped' (it must not end with coma)

    In line 160, which contains await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg', 'genBinaryInput', 'closuresWindowConvering', 'genIdentify']); Remove 'genBinaryInput',

    It must look like this: image

  3. Restart Z2M In Jeedom, Go to Plugins > Gestion des Plugins > JeeZigbee Start the deamon

When going back to Z2M, and to the page of the device, and in Expose view, when using the Legrand device, we see only open (top button) or close (bottom button) or stop (middle button), and no more Open/Stopped or Close/Stopped...

image

In Jeedom it's working very well.

@Koenkk How can we add this to the official release?

Regards

collicalex avatar Jul 30 '24 15:07 collicalex

Hello,

We can simplify a little bit more the legrand.js for this device. Here is what I have, and it's still working (but still no battery display).

image

Hope it will be put in an official release soon?

Regards,

Alex

collicalex avatar Jul 31 '24 15:07 collicalex

Finally... When adding a second shutter... this second one is not working (no action). When adding a third shutter.. all sutters (first, second and this third) are not working (no action).

I've tried to put back the config I've posted 2 messages above... Restart all. The same.

I'me migrating back to Deconz / Phoscon.

collicalex avatar Aug 01 '24 13:08 collicalex

Hope it will be put in an official release soon?

@collicalex you can submit a pull request by clicking here

Koenkk avatar Aug 03 '24 09:08 Koenkk

I have the same problem with zigbee2mqtt. The command has never worked correctly and when buying a second the same thing happened to me.

I hope you solve the problem soon!

pikatoste81 avatar Aug 04 '24 20:08 pikatoste81

Hello, I've been addressing the issues with the converter for both battery and incorrect/missed actions. I experienced the same problem as you all. I have 3 Legrand 067646 devices, and they've been operating flawlessly for 48 hours now. Could you test this code as well and let me know if it resolves the issue? If it does, I'll submit a PR.

const {fzLegrand, tzLegrand, readInitialBatteryState, legrandOptions} = require('zigbee-herdsman-converters/lib/legrand');
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 ota = require('zigbee-herdsman-converters/lib/ota');
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 device = {
        zigbeeModel: [' Shutters central remote switch'],
        model: '067646',
        vendor: 'Legrand',
        description: 'Wireless shutter switch (WIP)',
        ota: ota.zigbeeOTA,
        meta: {multiEndpoint: true, battery: {voltageToPercentage: {min: 2500, max: 3000}}, publishDuplicateTransaction: true},
        fromZigbee: [
            fz.identify,
            fz.ignore_basic_report,
            fz.command_cover_open,
            fz.command_cover_close,
            fz.command_cover_stop,
            fz.battery,
        ],
        toZigbee: [],
        exposes: [e.battery(), e.action(['identify', 'open', 'close', 'stop'])],
        onEvent: async (type, data, device, options, state) => {
            await readInitialBatteryState(type, data, device, options, state);
            if (data.type === 'commandCheckin' && data.cluster === 'genPollCtrl') {
                const endpoint = device.getEndpoint(1);
                await endpoint.command('genPollCtrl', 'fastPollStop', {}, legrandOptions);
            }
        },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg', 'closuresWindowCovering', 'genIdentify']);
        },
    };

module.exports = device;

CodeForLove83 avatar Aug 23 '24 16:08 CodeForLove83

Hi @CodeForLove83 ,

still working for you ? also where/how to apply your code ?

ty

cocapic avatar Aug 26 '24 08:08 cocapic

Hi,

The previous code didn't work as expected; sometimes multiple and spurious actions were received.

By sniffing the communication with the Legrand Gateway, I discovered that Legrand devices are added to a group and the group is then bound to the endpoint Wireless Legrand device.

It seems that binding to a group enables the Legrand devices to handle multiple actions properly, likely discarding them through the firmware of the Legrand devices within the group.

I have also examined issues reported with other Wireless Legrand devices, such as shutters and switches, to validate my assumption that the problem we are experiencing with 067646 is similar to those affecting other wireless endpoints.

In summary, the remedy is to create a group with the Legrand devices you wish to manage using the endpoint Wireless Legrand device (067646). This group needs to be bound to the endpoint Legrand Wireless device.

Please, let me know if it works for you guys.

Currently, my wife has no complaints :-)

image image image

Be aware that the endpoint Legrand Wireless device couldn't be awake, press any device button and the click on bind button to success with binding.

If you want to test also my code please read the following paragraph. To support new devices or modify an existing one, please visit this link.

A quick process walkthroughs is illustrated in the following screenshots.

image

You need to add to /homeassistant/zigbee2mqtt/configuration.yaml (or at the path where you saved the configuration.yaml for your z2m installation) the following code snippet:

external_converters:
  - 067646.js
image

The file with the external definition 067646.js must be created at the path /homeassistant/zigbee2mqtt/ where the configuration.yaml is stored.

The last step is to restart zigbee2mqtt process.

const {fzLegrand, tzLegrand, readInitialBatteryState, legrandOptions} = require('zigbee-herdsman-converters/lib/legrand');
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 ota = require('zigbee-herdsman-converters/lib/ota');
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 device = {
        zigbeeModel: [' Shutters central remote switch'],
        model: '067646',
        vendor: 'Legrand',
        description: 'Wireless shutter switch (WIP)',
        ota: ota.zigbeeOTA,
        meta: {multiEndpoint: true, battery: {voltageToPercentage: {min: 2500, max: 3000}}, publishDuplicateTransaction: true},
        fromZigbee: [
            fz.identify,
            fz.ignore_basic_report,
            fz.command_cover_open,
            fz.command_cover_close,
            fz.command_cover_stop,
            fz.battery,
            fz.legrand_binary_input_moving,
        ],
        toZigbee: [],
        exposes: [e.battery(), e.action(['identify', 'open', 'close', 'stop', 'moving', 'stopped'])],
        onEvent: async (type, data, device, options, state) => {
            await readInitialBatteryState(type, data, device, options, state);
            if (data.type === 'commandCheckin' && data.cluster === 'genPollCtrl') {
                const endpoint = device.getEndpoint(1);
                await endpoint.command('genPollCtrl', 'fastPollStop', {}, legrandOptions);
            }
        },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg', 'genBinaryInput', 'closuresWindowCovering', 'genIdentify']);
        },
    };

module.exports = device;

CodeForLove83 avatar Aug 26 '24 17:08 CodeForLove83

Hi @CodeForLove83

many thanks for your time

Im not sure that binding is the solution, i was previously on deconz and all legrand stuff was working fine without any setup (i ddnt saw something so reliable that legrand/deconz :) ) ...

Also in my case, endpoint are not zigbee and not in Z2m i cannot create an endpoint ...

Ive set your code in prod, will see at the end of the day

hope it will work ;)

ty

cocapic avatar Aug 27 '24 09:08 cocapic