0x5e / homebridge-tuya-platform

Make homebridge-tuya-platform great again.
MIT License
217 stars 66 forks source link

Newly-Appearing "switch_inching" Causing Outlet Switch Control Issue #307

Open shanemcw opened 1 year ago

shanemcw commented 1 year ago

Prerequisite

Cache

Version

v1.7.0-beta.45

Device Infomation JSON File

{
    "active_time": 1684070943,
    "biz_type": 18,
    "category": "cz",
    "create_time": 1671631353,
    "icon": "smart/icon/ay1558333928396hf49I/64d318d772aa1a6c191f3ab821d09ed8.jpg",
    "id": "eb70d7c2644cedb9c5npeg",
    "ip": "",
    "lat": "",
    "local_key": "",
    "lon": "",
    "model": "YS115C",
    "name": "Dining Table",
    "online": true,
    "owner_id": "",
    "product_id": "co4q4x9nmekuw0cj",
    "product_name": "Smart Plug",
    "status": [
    {
        "code": "countdown_1",
        "value": 0
    },
    {
        "code": "cycle_time",
        "value": ""
    },
    {
        "code": "light_mode",
        "value": "relay"
    },
    {
        "code": "random_time",
        "value": ""
    },
    {
        "code": "relay_status",
        "value": "last"
    },
    {
        "code": "switch_1",
        "value": false
    },
    {
        "code": "switch_inching",
        "value": "AADy"
    }
    ],
    "sub": false,
    "time_zone": "",
    "uid": "",
    "update_time": 1684275512,
    "uuid": "f216c049e4e83cf1",
    "schema": [
    {
        "code": "countdown_1",
        "mode": "rw",
        "type": "Integer",
        "property": {
        "unit": "s",
        "min": 0,
        "max": 86400,
        "scale": 0,
        "step": 1
        }
    },
    {
        "code": "cycle_time",
        "mode": "rw",
        "type": "String",
        "property": {}
    },
    {
        "code": "light_mode",
        "mode": "rw",
        "type": "Enum",
        "property": {
        "range": [
            "relay",
            "pos",
            "none"
        ]
        }
    },
    {
        "code": "random_time",
        "mode": "rw",
        "type": "String",
        "property": {}
    },
    {
        "code": "relay_status",
        "mode": "rw",
        "type": "Enum",
        "property": {
        "range": [
            "power_off",
            "power_on",
            "last"
        ]
        }
    },
    {
        "code": "switch_1",
        "mode": "rw",
        "type": "Boolean",
        "property": {}
    },
    {
        "code": "switch_inching",
        "mode": "rw",
        "type": "String",
        "property": {}
    }
    ]
  },

Device Control Mode

Standard Instruction

Logs

No response

Other Infomations

Note the typo in this Github's bug report's UI field label "Other Infomations"

As of a recent version of this plugin, there is now a second, new switch showing up in the Home app paired with this model's switch, named "switch_inching" that was not present in the Home app before, under a previous version with this same device model.

This new virtual "swiitch_inching" switch appearing in the Home app tends to be set to "on." When it is set to "on," the function of the "real" switch is "broken"—when the "real" switch is turned on it flashes on for less than second and turns itself back off. When the virtual paired switch named "switch_inching" is turned off, the "real" switch functions correctly. However turning switch_inching off is not a longer term solution, as it tends to turn itself back on somehow.

Other similar smart outlet switches controlled by the same plugin but different models/ manufacturers do not now show this new "switch_inching."

shanemcw commented 1 year ago

In the Home app, switch_inching is being expressed as a switch (i.e. boolean). In the device information JSON, switch_inching is a string with its current value of "AADy"

IMG_1243

0x5e commented 1 year ago

78 It is a feature, sounds like a timer. It's a problem that someone want this and someone don't, for now if anyone doesn't want it, we can use advanced config to hide switch_inching: https://github.com/0x5e/homebridge-tuya-platform/blob/develop_1.7.0/ADVANCED_OPTIONS.md#configuration

shanemcw commented 1 year ago

Thanks for the thoughts! Am I correct there's a bug in the plugin that the string object "switch_inching" with string value "AADy" (see the device JSON) is incorrectly being interpreted and exposed as a boolean switch device?

shanemcw commented 1 year ago

The following does not hide this extra switch. Any detail I am missing? Thanks for any thoughts!

                     {
            "name": "Tuya",
            "options": {
                "projectType": "2",
                "accessId": "***",
                "accessKey": "***",
                "countryCode": 1,
                "username": "***",
                "password": "***",
                "appSchema": "smartlife",
                "deviceOverrides": [
                    {
                        "id": "global",
                        "schema": [
                            {
                                "code": "switch_inching",
                                "hidden": true
                            }
                        ]
                    }
                ]
            },
            "platform": "TuyaPlatform"
        }
0x5e commented 1 year ago

Thanks for the thoughts! Am I correct there's a bug in the plugin that the string object "switch_inching" with string value "AADy" (see the device JSON) is incorrectly being interpreted and exposed as a boolean switch device?

Yes, it's a base64 string, decode to 3 bytes, first byte means on/off, 2-3 means the timer seconds. https://github.com/0x5e/homebridge-tuya-platform/issues/78#issuecomment-1540115378

Have you clear accessory cache after config?

shanemcw commented 1 year ago

Thanks—that did it.

shanemcw commented 1 year ago

Re #78 the "broken" behavior I see may be Switch Inching turning on via HomeKit but the seconds may be zero from Smart Life. The UI in Smart Life for the Inching setting on this device looks buggy, e.g. setting the seconds is enabled when Inching is off but disabled when Inching is on (you would think the other way around) and when the time is set by the user in the UI, the time changes back to what it was (the UI for changing the time seems to not work yet).

Thanks again!

ahmadnazirafiq commented 1 year ago

Careful not to use “global” in the Device ID as it can affect other outlets/sockets that didn’t have this switch_inching feature. By adding device-specific ID instead works for me.

githubnavigator commented 1 year ago

This was an interesting surprise today after upgrading. I was glad to find this thread. Thank you everyone.

veerachen commented 1 year ago

This was an interesting surprise today after upgrading. I was glad to find this thread. Thank you everyone.

I am new to home bridge. Can you help summarize what is the fix? Will there be an updated plugin which solve this issue (remove the switch_inching)? Thank you for your advice.

shanemcw commented 1 year ago

This was an interesting surprise today after upgrading. I was glad to find this thread. Thank you everyone.

I am new to home bridge. Can you help summarize what is the fix? Will there be an updated plugin which solve this issue (remove the switch_inching)? Thank you for your advice.

Thanks, @veerachen for the question, and welcome to Homebridge and the Tuya plugin support!

To summarize this thread, switch_inching is a new feature of IoT devices—a little buggy in its early life—but a valid feature.

For devices where this is an issue, the correct fix (at this time until this feature gets more mature) is to hide it via the plugin's settings, e.g.

                     {
            "name": "Tuya",
            "options": {
                "projectType": "2",
                "accessId": "(your data)",
                "accessKey": "(your data)",
                "countryCode": (your data),
                "username": "(your data)",
                "password": "(your data)",
                "appSchema": "smartlife",
                "deviceOverrides": [
                    {
                        "id": "(your device ID 1)",
                        "schema": [
                            {
                                "code": "switch_inching",
                                "hidden": true
                            }
                        ]
                    },
                   {
                        "id": "(your device ID 2)",
                        "schema": [
                            {
                                "code": "switch_inching",
                                "hidden": true
                            }
                        ]
                    }
                ]
            },
            "platform": "TuyaPlatform"
        }

Thanks again!

veerachen commented 1 year ago

"deviceOverrides": [ { "id": "global", "schema": [ { "code": "switch_inching", "hidden": true } ] } ]

Hello,

I have tried both id = global and id = specific ID. The switch_inching are still showing in both homebridge and homekit. I have also remove the accessory cache and restart. Does not seems to work.

Any further hints and tips will be appreciated. Thanks.

image

githubnavigator commented 1 year ago

I took the device-specific approach, repeating the code below for each of my devices (screenshot included below for others coming to this thread and new to Homebridge).

               {
                    "id": "(your device ID 1)",
                    "schema": [
                        {
                            "code": "switch_inching",
                            "hidden": true
                        }
                    ]
                },

I had to clear my accessory cache in order to get them to go away. That meant having to redo my settings in my Apple Home, but that's okay. It didn't take that long.

I can see why some people would want this feature. For instance, someone might want to be sure the iron shuts off after 20 minutes in the morning.

image

veerachen commented 1 year ago

@githubnavigator May I check my understanding on the device ID? Shall I use the serial number?

image

shanemcw commented 1 year ago

@veerachen Thanks for the question!

The "device ID" can be found at https://iot.tuya.com/cloud/ under your project, then Devices. Your devices will be listed with the device ID.

The device ID is also under the "Device Information" of that device in your Smart Life app.

caarlos0 commented 9 months ago

it seems like adding that option affects new devices added to the tuya account, but not previously existing ones... I guess there's some sort of cache file somewhere... how can I clean it up?

uninstall/install the plugin again did not work

githubnavigator commented 9 months ago

Homebridge Settings > Manage Cached Accessories > Remove All Cached Accessories

tamasfodor1988 commented 4 months ago

To work this feature. Is it not enough to remove single cached accessory?

markywarky commented 4 months ago

To work this feature. Is it not enough to remove single cached accessory?

Yes, removing a single accessory from the cache removes the second 'inching' switch for that accessory, when the steps above are also carried out for the accessory.