private@homelab: ~/latest
local-first guides · privacy-aware · no noisy tracking
private@homelab:~$ cat guides/article.md
· ·
8–12 minutes
read

Tuya Local Key Stopped Working? It’s Not Expiration

Your Tuya local key worked, then stopped. It didn't expire on a timer — here's what actually changes it, and the look-alikes that aren't a key problem.

A local_key that worked for months and then suddenly stops is one of the more disorienting failures in a Tuya local setup, mostly because the natural assumption — that Tuya must expire keys on some kind of schedule — isn’t what any of the projects document. This piece works through what actually changes a device’s local_key, how to tell that apart from a cloud-account problem that only looks the same, and the situations where the key never changed at all and re-extracting it will waste your afternoon.

This assumes you already have a working local_key extraction workflow. If you haven’t gotten a key at all yet, How to Get a Tuya Local Key in 2026 covers that from scratch. This article picks up after that: the key worked, then stopped.

Does a Tuya local key actually expire?

Short answer: no, not on a timer. What the projects document is a key that changes on a specific triggering event, and the most common one is stated plainly in tuya-local’s own README — each time you pair the device, the local key changes. That’s a rotation tied to an action you took, not a clock running down.

The trackers back that up from the other direction. Reports titled some version of “key stopped working” resolve, when they resolve, to a device reset, a re-pair, or a network change. What no project documents, and what nobody has produced a case of, is a key that lapses purely from the passage of time. Tuya has made no public statement ruling scheduled rotation out, so treat that as the strongest explanation the evidence supports rather than a guarantee — but “when did I last re-pair this device” is a far better first question than “has it been a month.”

Note · scope

This applies to Wi-Fi Tuya devices using LocalTuya or tuya-local. Tuya-branded Zigbee devices running through Zigbee2MQTT or ZHA don’t use a local_key at all — see Tuya Zigbee Devices Don’t Need a Local Key if that’s your setup.

What actually changes a local_key: reset and re-pairing

The most common real trigger is exactly the one that sounds too obvious to be the answer: factory-resetting the physical device and reconnecting it through the Smart Life or Tuya app generates a new local_key. If you extracted a key once, then later reset the device — intentionally, or because it dropped off Wi-Fi and you power-cycled it into pairing mode to recover it — the key you extracted before is stale. That’s expected behavior, not a bug in the integration.

You may not have to re-extract it by hand

Before you go back to the developer portal, check whether your integration can do it for you. LocalTuya’s README describes the Cloud API account configuration as optional but strongly suggested, precisely because it handles retrieving local keys and updating them automatically after a device is re-paired, with cloud calls made only at startup and when a key update is actually needed. tuya-local offers a comparable cloud-assisted setup path that pre-fills the device ID and key from your Tuya account. Manual re-extraction is the fallback for when that link is broken or was never set up, not the default move.

The other trigger: a different Wi-Fi network

A less obvious trigger is the device ending up on a different Wi-Fi network or access point. The Tuya developer documentation referenced in Discussion #1112 describes some devices changing their device ID when reset — and moving a device to a new SSID generally means re-provisioning it through the app, which is the same act that rotates the key. So if you moved a device to a new router, renamed your SSID, or migrated to a new mesh system and had to re-add IoT devices, a previously-working key can stop validating even though you never consciously “factory reset” anything.

The look-alike problem: key changed, or can’t retrieve any key?

There’s a second failure mode that produces near-identical symptoms but has nothing to do with the device’s actual key. If the Tuya IoT Platform Cloud Development project’s subscription has lapsed, the API Explorer stops returning key data for any device, old or new. The device’s real key may not have changed at all; you’ve simply lost the ability to look it up.

That mechanism, including the specific error code it throws, is covered in our extraction guide. What matters here is telling the situations apart before you chase the wrong fix.

Symptom What actually happened Fix path
Device was reset or re-paired through the vendor app The device generated a new local_key Let cloud-assisted config refresh it, or re-extract and update manually
Device moved to a different Wi-Fi network/AP Re-provisioning regenerated the key, and possibly the device ID Same as above; if the device ID also changed, remove and re-add the device
API Explorer won’t return a key for any device Cloud Development subscription has lapsed, not a device-side change Renew/reactivate the Tuya IoT Platform subscription (see extraction guide)
Vendor app still works fine, integration alone can’t connect Device firmware may have moved to a protocol version your integration doesn’t speak Check protocol support — a new key won’t help
Correct new key entered, integration still says “unable to connect” Configure UI validating against the old cached key (known bug, see below) Retry after an integration update; manual config-entry edit as a last resort

When the key is fine and the protocol moved

This is the branch most “my key stopped working” threads never reach, and it’s the one that manufactures believers in monthly expiry. Tuya devices speak a versioned local protocol, and a firmware update can move a device to a newer version than your integration supports. The rospogrigio/localtuya README documents support for protocols 3.1 through 3.4; devices that ship or update to 3.5 aren’t covered, and the connection fails during session-key negotiation rather than with anything that says “wrong version.” Issue #2189, “Recent Tuya firmware or protocol change broke LocalTuya”, and Issue #1919, “Protocol 3.5 devices”, are where this gets discussed.

The diagnostic that separates it from a key problem is free: if the Smart Life or Tuya app still controls the device normally and only your local integration is broken, the device is healthy and reachable, and the thing that changed is on the software side. Re-extracting a key in that state returns the same key you already had, which is exactly how someone concludes their key must be rotating on its own.

The fix is an integration that speaks the newer protocol, and which repository you’re running matters — LocalTuya vs Tuya-Local covers that lineage question, including which fork is actually maintained.

The Configure UI bug that makes a correct new key look wrong

There’s a specific, documented bug in tuya-local (Issue #3058, “Updating local key in configure UI does not work”, closed March 2025) worth knowing about before you assume you’ve mistyped something. Entering a new local_key into the integration’s Configure dialog could fail with an “unable to connect to your device” error even when the new key was correct, because the connection-test step was validating against the old, cached key instead of the one just typed in.

Because that issue is closed, a current install may not exhibit it — update the integration before assuming you’re hitting it. If Configure genuinely keeps rejecting a key you’ve confirmed against a fresh extraction, the workaround reported by the person who ran into it was to edit the new local_key directly into Home Assistant’s .storage/core.config_entries file, in both the data and options sections for that device’s entry, then restart Home Assistant.

Note · last resort

That means hand-editing Home Assistant internals, which is not a supported configuration step. Back .storage up first.

Why the API Explorer might show a blank key for a sub-device

One more source of false alarms: per Discussion #823, querying “Query Device Details in Bulk” in the Tuya IoT Platform’s API Explorer no longer returns a local_key value for non-gateway sub-devices — the field comes back empty. Tuya has framed this as a security measure. It’s a visibility restriction rather than any change to the actual key, so if you’re re-checking a key that’s still perfectly valid and the API Explorer shows nothing, that’s very plausibly what you’re looking at.

Tuya’s developer-portal UI shifts without notice, so confirm which fields are hidden in your own API Explorer session rather than assuming that report still holds exactly. The tuya-cli wizard command-line tool is the workaround mentioned alongside it.

FAQ

Does a Tuya local key expire over time?

No documented case of pure time-based expiry exists across the tuya-local and LocalTuya trackers, and neither project documents a schedule. What is documented is rotation on a specific event — a reset, a re-pair, or a network change. That’s the strongest evidence-backed answer available, not a vendor confirmation that expiry can never happen.

Why did my Tuya device stop connecting after working fine?

Most likely one of four things: the device was reset or re-paired (new key generated), it moved to a different Wi-Fi network and was re-provisioned, your Tuya IoT Platform subscription lapsed so you can’t currently retrieve any key, or the device’s firmware moved to a local protocol version your integration doesn’t support.

Does resetting a Tuya device change its local key?

Yes — tuya-local’s README states that pairing the device changes the local key, so a factory reset followed by re-pairing through the Smart Life or Tuya app leaves your extracted key stale. This is expected behavior, not an integration bug.

Why won’t the Configure UI accept my new Tuya local key?

A known, now-closed tuya-local bug (Issue #3058) had the Configure dialog validating new keys against a stale cached copy, producing a false connection error. Update the integration first; the manual .storage/core.config_entries edit described above is the last-resort workaround.

Is a Tuya local key issue the same as a Tuya cloud subscription expiring?

No, and mixing these up is the most common misdiagnosis here. A subscription lapse blocks you from looking up any key via the API Explorer; it doesn’t mean the device’s key actually changed. See the comparison table above, and the extraction guide for the subscription-wall mechanics specifically.

What to check yourself

What’s genuinely badly handled here isn’t that keys rotate — rotating a credential when a device is re-provisioned is the correct design. It’s that the rotation is silent on the consumer side, and the error you eventually see points at your network rather than at the reset you performed a week earlier. A one-line “this device was re-paired, its local key changed” notice in the developer portal would end most of these threads.

None of this troubleshooting path requires routing control through the Smart Life app’s cloud; it stays inside your own Home Assistant instance and your own Tuya account. If you work through all of it and still can’t reconnect a device, the remaining possibility is that it generated a new device ID as well as a new key, which the Configure flow in most integrations won’t handle as an update. That’s a remove-and-re-add situation, not a key-update one.

local-firstHome Assistantno-cloud