Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for SSWD01 device #3004

Merged
merged 12 commits into from
Sep 12, 2021
Merged

Conversation

Asleep-at-the-wheel
Copy link
Contributor

@Asleep-at-the-wheel Asleep-at-the-wheel commented Sep 8, 2021

I would like to preface this by stating that I have almost no clue what I am doing, I don't normally code and/or use git (I did most of this in vi and bash but it all seems to work). I essentially Benny Hill'd my way through everything here, so please double check.

I am attempting to fix this issue here:
Koenkk/zigbee2mqtt#8556

The issue appears that the original lumping in of the device with a bunch of other tuya dimmers was causing issues with the unique data points this device uses. The set zigbee is fine but not the read. This device also has two new data points (minimum brightness and countdown off timers) that I have no idea how to code for but could identify. I plan to learn this over time and make the change. At this time I just want to get the devices working correctly.

I plan to submit a jpeg for this device too in the documentation.

Any feedback would be appreciated, I am a network security person in way over my head here...

converters/fromZigbee.js Outdated Show resolved Hide resolved
@Asleep-at-the-wheel
Copy link
Contributor Author

Asleep-at-the-wheel commented Sep 11, 2021

Some questions.

  1. Removing this value left the state in my Zigbee2MQTT front end. When this change eventually makes its way into my production system, how can I cleanly remove that state (in testing environment a repair fixed it, but that's not going to work easily in my real environment).
  2. Where should I add the new image of the device? It looks nothing like the other Tuya dimmers it is currently associated with.
  3. Do you have any suggestions on how to handle those other two data points (count down timer and minimum brightness). I want to eventually get around to sorting them but don't know really where to start and how to make them show up as exposed.

@Koenkk
Copy link
Owner

Koenkk commented Sep 11, 2021

  1. remove it from state.json
  2. Image has to be added here: https://github.com/Koenkk/zigbee2mqtt.io/tree/master/docs/images/devices
  3. Do they work already? If so I can help adding the expose. If it doesn't work yet then you need to sniff traffic with the original gateway to reverse engineer how it works.

devices/tuya.js Outdated
model: 'SSWD01',
vendor: 'Mercator ikuü',
description: 'Zigbee smart dimmer',
fromZigbee: [fz.ikuu_dimmer, fz.ignore_basic_report],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if a new definition is really needed, the only difference is fz. ikuu_dimmer vs fz.tuya_dimmer, I think it is better to just fix the fz.tuya_dimmer (add the datapoint for the brightness)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply don't know how the other Tuya dimmer devices work, if they all have the same data points or not. I don't know if the others devices have those count down timers and minimum brightness settings that I have yet to figure out.

If they are all the same, then yeah that makes more sense. I didn't want to take the risk of breaking other people's stuff, but we can do that if it's best.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try just changing:

tuya_dimmer: {
    cluster: 'manuSpecificTuya',
    type: ['commandGetData', 'commandSetDataResponse'],
    convert: (model, msg, publish, options, meta) => {
        const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
        if (msg.data.dp === tuya.dataPoints.state) {
            return {state: value ? 'ON': 'OFF'};
        } else if (meta.device.manufacturerName === '_TZE200_swaamsoy' && msg.data.dp === 3) {
            return {brightness: mapNumberRange(value, 10, 1000, 0, 254), level: value};
        } else { // TODO: Unknown dp, assumed value type
            return {brightness: mapNumberRange(value, 10, 1000, 0, 254), level: value};
        }
    },
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I didn't explain the issue too well.

Data point 2 is the actual dimmer brightness level.
Data point 3 is a minimum brightness level that is set. This is because the dimming switch has no neutral wire, going lower than the minimum setting in brightness results in the load LED turning off (this value can differ depending on the LED connected to the switch and that LED minimum wattage). I don't know if the other Tuya dimmers have this "minimum brightness" as they likely are not "non-neutral" versions?

So when we see data point 2, we get brightness ok. But when we see data point 3, that else assumes it's brightness and sets incorrect values. So that proposed change will result in the same issue if I am not mistaken?

Would need a couple more ifs there to say:
if ikuu and dp is 2 then set brightness
elif ikuu and dp is 3 then set min-brightness
elif ikuu and dp is 6 set timer
else assume brightness

Want me to do that? But seems super hacky.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, what about:

tuya_dimmer: {
    cluster: 'manuSpecificTuya',
    type: ['commandGetData', 'commandSetDataResponse'],
    convert: (model, msg, publish, options, meta) => {
        const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
        if (msg.data.dp === tuya.dataPoints.state) {
            return {state: value ? 'ON': 'OFF'};
        } else {
            if (meta.device.manufacturerName === '_TZE200_swaamsoy') {
                // https://github.com/Koenkk/zigbee-herdsman-converters/pull/3004
                if (msg.data.dp === 3) {
                    return {brightness: mapNumberRange(value, 10, 1000, 0, 254), level: value};
                }
            } else { // TODO: Unknown dp, assumed value type
                return {brightness: mapNumberRange(value, 10, 1000, 0, 254), level: value};
            }
        }
    },
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I have made that change with a minor adjustment. Does work in my testing.

Those other data points (3 and 6) I can't figure out yet, I will get to them when ever I can.

@Koenkk Koenkk merged commit 03fdeed into Koenkk:master Sep 12, 2021
@Koenkk
Copy link
Owner

Koenkk commented Sep 12, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants