فهرست منبع

feat(devices): smart-home icon overrides and vacuum vendor tier

More icon overrides for smart-home devices, taken from the set the library already ships, with localized tooltips and a scrollable grid in the edit sheet.

Adds a vacuum vendor tier (roborock, irobot, ecovacs, dreame) checked between camera and iot, plus the `rock-robo` hostname variant, so a robot vacuum with an opaque hostname stops falling into generic iot. Tests cover the opaque hostname, the vendor-only path, and that camera and generic iot vendors are unaffected.

Co-authored-by: Bann-DEV <hef.fangyuan@gmail.com>
Bann-DEV 2 هفته پیش
والد
کامیت
afdce0eac5

+ 92 - 0
app/public/locales/en/translation.json

@@ -480,6 +480,98 @@
       "nameHint": "Empty = automatic name (DHCP hostname)",
       "type": "Type",
       "icon": "Icon",
+      "iconNames": {
+        "monitor": "Monitor",
+        "laptop": "Laptop",
+        "smartphone": "Smartphone",
+        "tablet": "Tablet",
+        "tv": "TV",
+        "gamepad": "Game console",
+        "camera": "Camera",
+        "cctv": "CCTV",
+        "vacuum": "Robot vacuum",
+        "doorbell": "Video doorbell",
+        "air-vent": "Air conditioning",
+        "heater": "Heater",
+        "circuit-board": "Dev board",
+        "speaker": "Speaker",
+        "router": "Router",
+        "server": "Server",
+        "watch": "Watch",
+        "car": "Car",
+        "home": "Home",
+        "printer": "Printer",
+        "plug": "Plug",
+        "shield": "Security",
+        "help-circle": "Unknown",
+        "wifi": "Wi-Fi",
+        "ethernet": "Ethernet",
+        "refrigerator": "Fridge",
+        "washing-machine": "Washer / dishwasher",
+        "microwave": "Microwave",
+        "cooking-pot": "Cooker",
+        "chef-hat": "Kitchen appliance",
+        "coffee": "Coffee maker",
+        "utensils-crossed": "Kitchenware",
+        "glass-water": "Water dispenser",
+        "shower-head": "Water heater",
+        "bath": "Bathroom heater",
+        "toilet": "Smart toilet",
+        "droplets": "Water purifier",
+        "flame": "Boiler / gas",
+        "flame-kindling": "Fireplace",
+        "thermometer": "Thermostat",
+        "fan": "Fan",
+        "snowflake": "Cooling",
+        "plug-zap": "Smart plug",
+        "battery-charging": "Charger / battery",
+        "solar-panel": "Solar panel",
+        "power": "Switch",
+        "lightbulb": "Bulb",
+        "lamp": "Lamp",
+        "lamp-desk": "Desk lamp",
+        "lamp-ceiling": "Ceiling light",
+        "lock-keyhole": "Smart lock",
+        "key-round": "Key",
+        "door-closed": "Door sensor",
+        "scan-face": "Face access",
+        "fingerprint": "Fingerprint",
+        "shield-check": "Security hub",
+        "webcam": "Webcam",
+        "siren": "Siren",
+        "paw-print": "Pet feeder",
+        "cat": "Cat",
+        "dog": "Dog",
+        "fish": "Aquarium",
+        "baby": "Baby care",
+        "scale": "Scale",
+        "heart-pulse": "Health device",
+        "projector": "Projector",
+        "cast": "Cast / screen",
+        "headphones": "Headphones",
+        "headset": "Headset",
+        "radio": "Radio",
+        "joystick": "Joystick",
+        "hard-drive": "Storage",
+        "database": "Database",
+        "cloud": "Cloud",
+        "cpu": "Compute",
+        "brain-circuit": "AI box",
+        "bot": "Robot",
+        "antenna": "Antenna",
+        "satellite-dish": "Satellite dish",
+        "blinds": "Blinds / screen",
+        "armchair": "Armchair",
+        "sofa": "Sofa",
+        "bed-double": "Bed",
+        "sprout": "Garden",
+        "flower-2": "Plants",
+        "wrench": "Tools",
+        "cog": "Machine",
+        "package": "Package",
+        "shirt": "Garment care",
+        "gauge": "Gauge"
+      },
       "notifyOffline": "Notify when offline",
       "auto": "Auto",
       "save": "Save",

+ 92 - 0
app/public/locales/es/translation.json

@@ -480,6 +480,98 @@
       "nameHint": "Vacío = nombre automático (hostname DHCP)",
       "type": "Tipo",
       "icon": "Icono",
+      "iconNames": {
+        "monitor": "Monitor",
+        "laptop": "Portátil",
+        "smartphone": "Móvil",
+        "tablet": "Tablet",
+        "tv": "TV",
+        "gamepad": "Consola",
+        "camera": "Cámara",
+        "cctv": "Videovigilancia",
+        "vacuum": "Aspirador",
+        "doorbell": "Videoportero",
+        "air-vent": "Aire acondicionado",
+        "heater": "Calefactor",
+        "circuit-board": "Placa",
+        "speaker": "Altavoz",
+        "router": "Router",
+        "server": "Servidor",
+        "watch": "Reloj",
+        "car": "Coche",
+        "home": "Hogar",
+        "printer": "Impresora",
+        "plug": "Enchufe",
+        "shield": "Seguridad",
+        "help-circle": "Desconocido",
+        "wifi": "Wi-Fi",
+        "ethernet": "Ethernet",
+        "refrigerator": "Frigorífico",
+        "washing-machine": "Lavadora / lavavajillas",
+        "microwave": "Microondas",
+        "cooking-pot": "Cocina",
+        "chef-hat": "Electrodoméstico de cocina",
+        "coffee": "Cafetera",
+        "utensils-crossed": "Menaje",
+        "glass-water": "Dispensador de agua",
+        "shower-head": "Termo / calentador",
+        "bath": "Calentador de baño",
+        "toilet": "Inodoro inteligente",
+        "droplets": "Purificador de agua",
+        "flame": "Caldera / gas",
+        "flame-kindling": "Chimenea",
+        "thermometer": "Termostato",
+        "fan": "Ventilador",
+        "snowflake": "Refrigeración",
+        "plug-zap": "Enchufe inteligente",
+        "battery-charging": "Cargador / batería",
+        "solar-panel": "Panel solar",
+        "power": "Interruptor",
+        "lightbulb": "Bombilla",
+        "lamp": "Lámpara",
+        "lamp-desk": "Lámpara de escritorio",
+        "lamp-ceiling": "Luz de techo",
+        "lock-keyhole": "Cerradura inteligente",
+        "key-round": "Llave",
+        "door-closed": "Sensor de puerta",
+        "scan-face": "Acceso facial",
+        "fingerprint": "Huella",
+        "shield-check": "Central de seguridad",
+        "webcam": "Webcam",
+        "siren": "Sirena",
+        "paw-print": "Comedero",
+        "cat": "Gato",
+        "dog": "Perro",
+        "fish": "Acuario",
+        "baby": "Bebé",
+        "scale": "Báscula",
+        "heart-pulse": "Dispositivo de salud",
+        "projector": "Proyector",
+        "cast": "Cast / pantalla",
+        "headphones": "Auriculares",
+        "headset": "Auriculares con micro",
+        "radio": "Radio",
+        "joystick": "Joystick",
+        "hard-drive": "Almacenamiento",
+        "database": "Base de datos",
+        "cloud": "Nube",
+        "cpu": "Cómputo",
+        "brain-circuit": "Caja de IA",
+        "bot": "Robot",
+        "antenna": "Antena",
+        "satellite-dish": "Antena parabólica",
+        "blinds": "Persianas / pantalla",
+        "armchair": "Sillón",
+        "sofa": "Sofá",
+        "bed-double": "Cama",
+        "sprout": "Jardín",
+        "flower-2": "Plantas",
+        "wrench": "Herramientas",
+        "cog": "Máquina",
+        "package": "Paquete",
+        "shirt": "Cuidado de ropa",
+        "gauge": "Medidor"
+      },
       "notifyOffline": "Avisar si se desconecta",
       "auto": "Auto",
       "save": "Guardar",

+ 2 - 2
app/src/components/DeviceEditSheet.tsx

@@ -242,7 +242,7 @@ export function DeviceEditSheet({
             {/* Icono */}
             <div className="space-y-2">
               <label className="text-label uppercase text-text-muted">{t('devices.edit.icon')}</label>
-              <div className="grid grid-cols-5 gap-2">
+              <div className="grid max-h-64 grid-cols-5 gap-2 overflow-y-auto pr-1">
                 <button
                   type="button"
                   onClick={() => setIcon('')}
@@ -260,7 +260,7 @@ export function DeviceEditSheet({
                     <button
                       key={n}
                       type="button"
-                      title={n}
+                      title={t(`devices.edit.iconNames.${n}`, { defaultValue: n })}
                       onClick={() => setIcon(n)}
                       disabled={saving}
                       className={cn(

+ 142 - 3
app/src/components/DeviceRow.tsx

@@ -1,34 +1,98 @@
 import {
   AirVent,
+  Antenna,
+  Armchair,
+  Baby,
+  Bath,
+  BatteryCharging,
+  BedDouble,
   BellRing,
+  Blinds,
+  Bot,
+  BrainCircuit,
   BrushCleaning,
+  Cable,
   Camera,
   Car,
-  CircuitBoard,
+  Cast,
+  Cat,
   Cctv,
+  ChefHat,
+  CircuitBoard,
+  Cloud,
+  Coffee,
+  Cog,
+  CookingPot,
+  Cpu,
+  Database,
+  Dog,
+  DoorClosed,
+  Droplets,
+  Fan,
+  Fingerprint,
+  Fish,
+  Flame,
+  FlameKindling,
+  Flower2,
   Gamepad2,
+  Gauge,
+  GlassWater,
+  HardDrive,
+  Headphones,
+  Headset,
+  HeartPulse,
   Heater,
   Home,
+  Joystick,
+  KeyRound,
+  Lamp,
+  LampCeiling,
+  LampDesk,
   Laptop,
   Lightbulb,
+  LockKeyhole,
+  Microwave,
   Monitor,
   Network,
-  Router,
+  Package,
+  PawPrint,
   Plug,
+  PlugZap,
+  Power,
   Printer,
+  Projector,
+  Radio,
+  Refrigerator,
+  Router,
+  SatelliteDish,
+  Scale,
+  ScanFace,
   Server,
   Shield,
+  ShieldCheck,
+  Shirt,
+  ShowerHead,
   SignalHigh,
   SignalLow,
   SignalMedium,
   SignalZero,
+  Siren,
   Smartphone,
+  Snowflake,
+  Sofa,
+  SolarPanel,
   Speaker,
+  Sprout,
   Tablet,
+  Thermometer,
+  Toilet,
   Tv,
+  UtensilsCrossed,
+  WashingMachine,
   Watch,
+  Webcam,
   Wifi,
-  Cable,
+  Wrench,
 } from 'lucide-react'
 import type { LucideIcon } from 'lucide-react'
 import { useTranslation } from 'react-i18next'
@@ -86,6 +150,81 @@ export const ICON_OVERRIDES: Record<string, LucideIcon> = {
   'help-circle': CircuitBoard,
   wifi: Wifi,
   ethernet: Cable,
+  // Cocina y electrodomésticos: el cajón "iot" los escondía todos bajo una
+  // bombilla. Mismo lucide, mismo trazo, solo que ahora se pueden elegir.
+  refrigerator: Refrigerator,
+  'washing-machine': WashingMachine,
+  microwave: Microwave,
+  'cooking-pot': CookingPot,
+  'chef-hat': ChefHat,
+  coffee: Coffee,
+  'utensils-crossed': UtensilsCrossed,
+  'glass-water': GlassWater,
+  // Agua, calefacción y baño
+  'shower-head': ShowerHead,
+  bath: Bath,
+  toilet: Toilet,
+  droplets: Droplets,
+  flame: Flame,
+  'flame-kindling': FlameKindling,
+  thermometer: Thermometer,
+  fan: Fan,
+  snowflake: Snowflake,
+  // Energía
+  'plug-zap': PlugZap,
+  'battery-charging': BatteryCharging,
+  'solar-panel': SolarPanel,
+  power: Power,
+  // Iluminación
+  lightbulb: Lightbulb,
+  lamp: Lamp,
+  'lamp-desk': LampDesk,
+  'lamp-ceiling': LampCeiling,
+  // Acceso y seguridad
+  'lock-keyhole': LockKeyhole,
+  'key-round': KeyRound,
+  'door-closed': DoorClosed,
+  'scan-face': ScanFace,
+  fingerprint: Fingerprint,
+  'shield-check': ShieldCheck,
+  webcam: Webcam,
+  siren: Siren,
+  // Mascotas, familia y salud
+  'paw-print': PawPrint,
+  cat: Cat,
+  dog: Dog,
+  fish: Fish,
+  baby: Baby,
+  scale: Scale,
+  'heart-pulse': HeartPulse,
+  // Ocio
+  projector: Projector,
+  cast: Cast,
+  headphones: Headphones,
+  headset: Headset,
+  radio: Radio,
+  joystick: Joystick,
+  // Cómputo y red
+  'hard-drive': HardDrive,
+  database: Database,
+  cloud: Cloud,
+  cpu: Cpu,
+  'brain-circuit': BrainCircuit,
+  bot: Bot,
+  antenna: Antenna,
+  'satellite-dish': SatelliteDish,
+  // Hogar y varios
+  blinds: Blinds,
+  armchair: Armchair,
+  sofa: Sofa,
+  'bed-double': BedDouble,
+  sprout: Sprout,
+  'flower-2': Flower2,
+  wrench: Wrench,
+  cog: Cog,
+  package: Package,
+  shirt: Shirt,
+  gauge: Gauge,
 }
 
 export const ALLOWED_ICONS = Object.keys(ICON_OVERRIDES) as string[]

+ 2 - 2
app/src/components/OnboardingIntake.tsx

@@ -187,7 +187,7 @@ export function OnboardingIntake({ open, device, isDemo, onClose, onSaved }: Onb
           {/* Icono */}
           <div className="space-y-2">
             <label className="text-label uppercase text-text-muted">{t('devices.onboarding.iconLabel')}</label>
-            <div className="grid grid-cols-6 gap-2">
+            <div className="grid max-h-64 grid-cols-6 gap-2 overflow-y-auto pr-1">
               <button
                 type="button"
                 onClick={() => setIcon('')}
@@ -205,7 +205,7 @@ export function OnboardingIntake({ open, device, isDemo, onClose, onSaved }: Onb
                   <button
                     key={n}
                     type="button"
-                    title={n}
+                    title={t(`devices.edit.iconNames.${n}`, { defaultValue: n })}
                     onClick={() => setIcon(n)}
                     disabled={busy}
                     className={cn(

+ 7 - 2
server-go/internal/adapters/classify.go

@@ -36,7 +36,7 @@ var typeRules = []struct {
 	// Camara antes que tv: "cctv-..." contiene "tv-" y caeria en TV (#1327).
 	{"camara", []string{"camara", "camera", "cctv", "nvr", "reolink", "ezviz", "tapo-c", "-cam", "cam-"}},
 	{"tv", []string{"appletv", "apple-tv", "bravia", "webos", "firetv", "fire-tv", "chromecast", "mibox", "mi-box", "shield", "television", "smart-tv", "smarttv", "-tv", "tv-"}},
-	{"aspirador", []string{"roomba", "irobot", "roborock", "aspirador", "vacuum", "deebot", "ecovacs", "dreame", "qrevo", "s8-max", "s8-pro", "k10"}},
+	{"aspirador", []string{"roomba", "irobot", "roborock", "rock-robo", "aspirador", "vacuum", "deebot", "ecovacs", "dreame", "qrevo", "s8-max", "s8-pro", "k10"}},
 	// Caldera: calefaccion/boiler/radiador eran 'desconocido' o caian mal;
 	// #1340 les da tipo propio. ADITIVO: "caldera" se QUEDA en iot (regla
 	// antigua), no se roba: una caldera ya clasificada no cambia de icono.
@@ -111,10 +111,15 @@ func GuessDeviceType(hostname, manufacturer, dhcpVendorClass, dhcpClientID, lldp
 	}
 	// Fabricante como refuerzo cuando el hostname no dice nada (OUI DB).
 	// Cámaras primero: un fabricante de videovigilancia es más específico
-	// que "iot", y hay un tipo propio para ello.
+	// que "iot", y hay un tipo propio para ello. Aspiradores igual: un
+	// Roborock llamado "ROCK-ROBO" no casa ninguna regla de hostname, pero
+	// el fabricante sí dice qué es.
 	if oui.IsCameraVendor(m) {
 		return "camara"
 	}
+	if oui.IsVacuumVendor(m) {
+		return "aspirador"
+	}
 	if oui.IsIoTVendor(m) {
 		return "iot"
 	}

+ 18 - 0
server-go/internal/adapters/classify_test.go

@@ -123,3 +123,21 @@ func TestGuessDeviceTypeModem(t *testing.T) {
 		}
 	}
 }
+
+// Un aspirador con hostname opaco: "ROCK-ROBO" (Roborock real) no casa
+// "roborock" y caía en iot por el OUI. La marca de aspirador decide.
+func TestGuessDeviceTypeVacuumVendor(t *testing.T) {
+	for _, tc := range []struct{ name, hostname, manufacturer, want string }{
+		{"roborock with opaque name", "ROCK-ROBO", "Beijing Roborock Technology Co., Ltd.", "aspirador"},
+		{"roborock by vendor alone", "", "Beijing Roborock Technology Co., Ltd.", "aspirador"},
+		{"irobot by vendor alone", "", "iRobot Corporation", "aspirador"},
+		{"ecovacs by vendor alone", "", "Ecovacs Robotics Co., Ltd.", "aspirador"},
+		{"hostname still wins", "roborock-s8-max", "", "aspirador"},
+		{"camera vendor is not a vacuum", "", "Reolink Innovation Limited", "camara"},
+		{"generic iot vendor stays iot", "", "Tuya Smart Inc.", "iot"},
+	} {
+		if got := GuessDeviceType(tc.hostname, tc.manufacturer, "", "", ""); got != tc.want {
+			t.Errorf("%s: got %q, want %q", tc.name, got, tc.want)
+		}
+	}
+}

+ 21 - 0
server-go/internal/httpapi/device_overrides.go

@@ -54,6 +54,27 @@ func validateIcon(icon string) bool {
 		"router": true, "server": true, "watch": true, "car": true,
 		"home": true, "printer": true, "plug": true, "shield": true,
 		"help-circle": true, "wifi": true, "ethernet": true,
+		// Smart-home overrides (must stay in sync with ICON_OVERRIDES).
+		"refrigerator": true, "washing-machine": true, "microwave": true,
+		"cooking-pot": true, "chef-hat": true, "coffee": true,
+		"utensils-crossed": true, "glass-water": true,
+		"shower-head": true, "bath": true, "toilet": true, "droplets": true,
+		"flame": true, "flame-kindling": true, "thermometer": true,
+		"fan": true, "snowflake": true,
+		"plug-zap": true, "battery-charging": true, "solar-panel": true, "power": true,
+		"lightbulb": true, "lamp": true, "lamp-desk": true, "lamp-ceiling": true,
+		"lock-keyhole": true, "key-round": true, "door-closed": true,
+		"scan-face": true, "fingerprint": true, "shield-check": true,
+		"webcam": true, "siren": true,
+		"paw-print": true, "cat": true, "dog": true, "fish": true,
+		"baby": true, "scale": true, "heart-pulse": true,
+		"projector": true, "cast": true, "headphones": true, "headset": true,
+		"radio": true, "joystick": true,
+		"hard-drive": true, "database": true, "cloud": true, "cpu": true,
+		"brain-circuit": true, "bot": true, "antenna": true, "satellite-dish": true,
+		"blinds": true, "armchair": true, "sofa": true, "bed-double": true,
+		"sprout": true, "flower-2": true, "wrench": true, "cog": true,
+		"package": true, "shirt": true, "gauge": true,
 	}
 	return allowed[icon]
 }

+ 7 - 0
server-go/internal/httpapi/device_overrides_test.go

@@ -155,6 +155,13 @@ func TestDeviceOverrideValidation(t *testing.T) {
 	if rec := doOverridePut(t, s, mac, `{"type":"movil"}`); rec.Code != 200 {
 		t.Errorf("tipo válil debió dar 200, dio %d", rec.Code)
 	}
+	// Iconos smart-home nuevos: aceptados (la lista cerrada del server debe
+	// seguir a ICON_OVERRIDES del frontend).
+	for _, icon := range []string{"microwave", "refrigerator", "cooking-pot", "paw-print", "lock-keyhole", "projector"} {
+		if rec := doOverridePut(t, s, mac, `{"icon":"`+icon+`"}`); rec.Code != 200 {
+			t.Errorf("icon %q debió dar 200, dio %d", icon, rec.Code)
+		}
+	}
 }
 
 // #1145: DELETE /api/devices/{mac} borra la fila del registro y 404 si no

+ 17 - 0
server-go/internal/oui/oui.go

@@ -109,6 +109,23 @@ var cameraVendors = []string{
 	"annke",
 }
 
+// vacuumVendors: marcas de aspiradores robots, las mismas que ya asume la
+// regla de hostname. Roborock e iRobot solo hacen aspiradores; Ecovacs y
+// Dreame son marcas de aspirador primero (igual que la regla de hostname
+// los trata). Un OUI suyo con hostname opaco ("ROCK-ROBO") es un aspirador,
+// no un cacharro genérico.
+var vacuumVendors = []string{
+	"roborock",
+	"irobot",
+	"ecovacs",
+	"dreame",
+}
+
+// IsVacuumVendor reports whether a manufacturer is a robot vacuum brand.
+func IsVacuumVendor(manufacturer string) bool {
+	return vendorMatches(manufacturer, vacuumVendors)
+}
+
 // IsCameraVendor reports whether a manufacturer only makes surveillance gear.
 func IsCameraVendor(manufacturer string) bool {
 	return vendorMatches(manufacturer, cameraVendors)

+ 14 - 0
server-go/internal/oui/oui_test.go

@@ -99,3 +99,17 @@ func TestCameraVendors(t *testing.T) {
 		}
 	}
 }
+
+// Robot vacuum brands get the vacuum type, which is more than "iot".
+func TestVacuumVendors(t *testing.T) {
+	for _, m := range []string{"Beijing Roborock Technology Co., Ltd.", "iRobot Corporation", "Ecovacs Robotics Co., Ltd.", "Dreame Technology"} {
+		if !IsVacuumVendor(m) {
+			t.Errorf("IsVacuumVendor(%q) = false", m)
+		}
+	}
+	for _, m := range []string{"Espressif Inc.", "Tuya Smart Inc.", "Reolink Innovation Limited", "Intel Corporate", ""} {
+		if IsVacuumVendor(m) {
+			t.Errorf("IsVacuumVendor(%q) = true", m)
+		}
+	}
+}