Koenkk / zigbee2mqtt

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

Inconsistent State and Position Reporting for Smartwings WM25L-Z Roller Shade #22847

Open pruvi9019 opened 5 months ago

pruvi9019 commented 5 months ago

What happened?

When controlling the Smartwings WM25L-Z roller shade manually via the device's remote, Zigbee2MQTT and Home Assistant report conflicting states and positions. Reversing the motor direction aligns the reports with the actual position but inversely affects the remote control commands, leading to operational inconsistencies.

What did you expect to happen?

I expected the state and position in Zigbee2MQTT to consistently reflect the actual physical state of the roller shade, aligning correctly with manual controls and Home Assistant without needing to invert motor directions, which inversely affects the usability of the remote control.

How to reproduce it (minimal and precise)

  1. Without Reversing Motor Direction:
  1. With Reversed Motor Direction:

Zigbee2MQTT version

1.37.1 (commit: cda867a3)

Adapter firmware version

20240316

Adapter

SLZB-06p7

Setup

Raspberry Pi 5

Debug log

log1.log log.log

pruvi9019 commented 5 months ago

Below are the Datapoint I found for the device using Tuya

{"1":"Control", "2":"Curtain position setting", "3":"Current curtain position", "4":"Mode", "5":"Motor Direction", "11":"Situation_set", "12":"Fault", "16":"Border", "19":"Best Position", "20":"Click Control"}

ThrashinVictim commented 4 months ago

Same issue as I am having, but I also have the shades exposed to Alexa via HA and they are reversed as well.

There is a way to reverse the motor for Alexa by programming the controller using key combinations, but that changes the reporting in HA.

For example: HA shows blinds closed, Alexa shows them as opened, and vice versa.

LordSushiPhoenix commented 2 months ago

I just installed a Smartwings zigbee roller shade and had the same issue. With the motor in the default position (so the up button on the remote opens the shade), the shade would report CLOSED to Home Assistant.

I found this external converter that corrected the issue so that the remote works in the correct direction and Home Assistant reports OPEN 100% when the shade is fully open.

note that the end of the file in the reddit comment has a syntax error at the end, here is the correct syntax:

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 e = exposes.presets;

const utils = require('zigbee-herdsman-converters/lib/utils');

backwards_cover_state = {
        key: ['state'],
        convertSet: async (entity, key, value, meta) => {
            const lookup = {'open': 'downClose', 'close': 'upOpen', 'stop': 'stop', 'on': 'downClose', 'off': 'upOpen'};
            value = value.toLowerCase();
            utils.validateValue(value, Object.keys(lookup));
            await entity.command('closuresWindowCovering', lookup[value], {}, utils.getOptions(meta.mapped, entity));
        },
    };

module.exports = [
    {
        zigbeeModel: ['WM25/L-Z'],
        model: 'WM25L-Z',
        vendor: 'Smartwings',
        description: 'Roller shade',
        fromZigbee: [fz.cover_position_tilt, fz.battery],
        toZigbee: [backwards_cover_state, tz.cover_position_tilt],
        meta: {battery: {dontDividePercentage: true}, coverInverted: false},
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg', 'closuresWindowCovering']);
            await reporting.batteryPercentageRemaining(endpoint);
            await reporting.currentPositionLiftPercentage(endpoint);
        },
        exposes: [e.cover_position(), e.battery()],
    }
];
ThrashinVictim commented 1 month ago

I just installed a Smartwings zigbee roller shade and had the same issue. With the motor in the default position (so the up button on the remote opens the shade), the shade would report CLOSED to Home Assistant.

I found this external converter that corrected the issue so that the remote works in the correct direction and Home Assistant reports OPEN 100% when the shade is fully open.

note that the end of the file in the reddit comment has a syntax error at the end, here is the correct syntax:

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 e = exposes.presets;

const utils = require('zigbee-herdsman-converters/lib/utils');

backwards_cover_state = {
        key: ['state'],
        convertSet: async (entity, key, value, meta) => {
            const lookup = {'open': 'downClose', 'close': 'upOpen', 'stop': 'stop', 'on': 'downClose', 'off': 'upOpen'};
            value = value.toLowerCase();
            utils.validateValue(value, Object.keys(lookup));
            await entity.command('closuresWindowCovering', lookup[value], {}, utils.getOptions(meta.mapped, entity));
        },
    };

module.exports = [
    {
        zigbeeModel: ['WM25/L-Z'],
        model: 'WM25L-Z',
        vendor: 'Smartwings',
        description: 'Roller shade',
        fromZigbee: [fz.cover_position_tilt, fz.battery],
        toZigbee: [backwards_cover_state, tz.cover_position_tilt],
        meta: {battery: {dontDividePercentage: true}, coverInverted: false},
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg', 'closuresWindowCovering']);
            await reporting.batteryPercentageRemaining(endpoint);
            await reporting.currentPositionLiftPercentage(endpoint);
        },
        exposes: [e.cover_position(), e.battery()],
    }
];

Tried that but didn't work for me.

image

Stilll says open when it is closed.

LordSushiPhoenix commented 1 month ago

What side of the shade is your charge port on? I'm wondering if that's related to the issue since the reported behaviour seems really inconsistent between owners. Mine is on the right. image image

ThrashinVictim commented 1 month ago

What side of the shade is your charge port on? I'm wondering if that's related to the issue since the reported behaviour seems really inconsistent between owners. Mine is on the right. image image

Mine is also on right. Are you using Alexa as well?

LordSushiPhoenix commented 1 month ago

No, I have it connected to Home Assistant through zigbee2mqtt only.