homebridge-tuya-platform icon indicating copy to clipboard operation
homebridge-tuya-platform copied to clipboard

Newly-Appearing "switch_inching" Causing Outlet Switch Control Issue

Open shanemcw opened this issue 2 years ago • 19 comments

Prerequisite

  • [X] Yes, I've read the readme completely.

Cache

  • [X] Yes, I've cleaned accessory cache and the issue still exists.

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 avatar May 17 '23 18:05 shanemcw

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

shanemcw avatar May 18 '23 14:05 shanemcw

#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

0x5e avatar May 23 '23 05:05 0x5e

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 avatar May 23 '23 12:05 shanemcw

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"
        }

shanemcw avatar May 23 '23 13:05 shanemcw

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?

0x5e avatar May 23 '23 15:05 0x5e

Thanks—that did it.

shanemcw avatar May 23 '23 15:05 shanemcw

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!

shanemcw avatar May 23 '23 15:05 shanemcw

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.

ahmadnazirafiq avatar Jun 19 '23 07:06 ahmadnazirafiq

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

githubnavigator avatar Jun 26 '23 00:06 githubnavigator

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.

veerachen avatar Aug 15 '23 16:08 veerachen

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!

shanemcw avatar Aug 15 '23 16:08 shanemcw

"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

veerachen avatar Aug 16 '23 03:08 veerachen

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

githubnavigator avatar Aug 16 '23 03:08 githubnavigator

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

image

veerachen avatar Aug 16 '23 05:08 veerachen

@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.

shanemcw avatar Aug 16 '23 13:08 shanemcw

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

caarlos0 avatar Dec 08 '23 12:12 caarlos0

Homebridge Settings > Manage Cached Accessories > Remove All Cached Accessories

githubnavigator avatar Dec 09 '23 20:12 githubnavigator

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

tamasfodor1988 avatar Apr 25 '24 19:04 tamasfodor1988

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.

markywarky avatar Apr 26 '24 06:04 markywarky