iRayanKhan / homebridge-tuya

A Homebridge plugin to control Tuya devices locally.
MIT License
405 stars 167 forks source link

Feit Dimmer switch, model BPDIM/WIFI/2 #171

Closed vascott1 closed 3 years ago

vascott1 commented 3 years ago

This is a WiFi Smart dimmer.

It appears to be working but the dimming function will not take it to 100% I have it set in the config as a "SimpleDimmer"

            {
                "name": "Bedroom lights",
                "type": "SimpleDimmer",
                "manufacturer": "Feit",
                "model": "BPDIM",
                "id": "xxxxxxx",
                "key": "xxxxxx",
                "dpPower": 1,
                "dpBrightness": 2
            }

I can supply any additional info that might be needed.

Thanks!

tbelcher commented 3 years ago

Edit: I thought the below was a fix, but it appears to only be a band-aid. The values are closer, and the Home app will allow you to get to full brightness, but the values don't match between the two apps (Home and Tuya)


I believe this is the same issue referenced on this thread:

https://github.com/AMoo-Miki/homebridge-tuya-lan/issues/126

If you want to get your hands dirty, you can change the files manually, per @chadjmorgan instructions:

Was able to look into this further and it looks like replacing the convertBrightnessFromTuyaToHomeKit function with below fixes the issue and the dimming percentage appears correct in the Apple Home app:

convertBrightnessFromTuyaToHomeKit(value) { const min = 150; const scale = 1000; return Math.round((99 (value || 0) - 100 min + scale) / (scale - min)); }

It looks like this.device.context.minBrightness || 27 and this.device.context.scaleBrightness || 255; in the convertBrightnessFromTuyaToHomeKit are not reading in the values from the config.json file, not sure if it is hardcoded in somewhere else for this function...

vascott1 commented 3 years ago

Thanks for the suggestion. I made the change in the BaseAccessory.js file as suggested and restarted homebridge. It didn't seem to make a difference. I can still turn the lights on/off and set the brightness but never higher than 50%. Any other suggestions are always welcomed of course :)

gdinh commented 3 years ago

Assuming you're speaking of the Feit-branded dimmers sold at Costco, I'm using the following configuration and I'm getting a perfect match between the dimmer percentages reported in HomeKit and the ones in the Tuya app:

        {
            "name": "Foyer Chandelier",
            "type": "SimpleDimmer",
            "manufacturer": "Feit Electric",
            "model": "Wi-Fi Smart Dimmer",
            "id": "[redacted]",
            "key": "[redacted]",
            "scaleBrightness": 1000,
            "minBrightness": 10
        }