Skip to content

_T% manufacturer exclusion is an unescaped LIKE wildcard, dropping every manufacturer whose second character is T #190

Description

@gbroeckling

pattern.manufacturer in project/server/src/service/derive/derivable/device/rules.ts contains:

"_T%", // tuya whitelabel devices (insufficient data quality)

Tuya whitelabel manufacturers arrive as _TZ3000_... / _TZE200_..., so the intent is a literal underscore followed by T. But the rule is applied in device-insert.sql as a bare LIKE with no ESCAPE clause:

ssd1.manufacturer like r.value

In SQLite, _ is a single-character LIKE wildcard, and LIKE is case-insensitive for ASCII. So _T% matches any manufacturer whose second character is T — not just the Tuya prefixes.

Confirmed in production

GET /api/unstable/dimensions returns 1258 manufacturers. Not one of them has T as its second character.

Names that should be there and are not: Athom, ITEAD, Etekcity, Stelpro, Steinel, STMicroelectronics, Atlantic, Otio.

The S block of the live list is the clearest tell — Samsung, Signify, Siemens, Shelly, Synology, Seagate, Somfy, SONOFF, Sonos, Sunricher, Schneider Electric, SMLIGHT, Sagemcom, sengled — and not a single St... brand anywhere in 1258 manufacturers.

Athom is likely the most costly single loss, being a fairly common ESPHome hardware vendor.

Fix

Both halves are needed, or the pattern still doesn't mean what it says.

device-insert.sql (the manufacturer join, and the model join below it for consistency):

ssd1.manufacturer like r.value escape '\'

rules.ts:

"\_T%", // tuya whitelabel devices (insufficient data quality)

The other patterns are unaffected: 0x%, TUYA%, %ONVIF% and %???% contain no underscore, and ? is not a LIKE metacharacter.

Happy to open the PR if that's useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions