Luces
Las luces representan las luminarias utilizadas en los espacios de cultivo. Esta API permite gestionar diferentes tipos de luces, sus horarios y configuraciones de espectro.
La API de Luces es actualmente una implementacion mocked.
El modelo de Luz
- Name
id- Type
- string
- Description
Identificador unico de la luz.
- Name
name- Type
- string
- Description
Nombre descriptivo.
- Name
type- Type
- LightType
- Description
Tipo de luminaria.
- Name
wattage- Type
- number
- Description
Potencia en watts.
- Name
voltage- Type
- number
- Description
Voltaje de operacion.
- Name
isActive- Type
- boolean
- Description
Estado de activacion.
- Name
schedule- Type
- LightSchedule
- Description
Horario de encendido/apagado.
- Name
on- Type
- string
- Description
Hora de encendido (HH:mm).
- Name
off- Type
- string
- Description
Hora de apagado (HH:mm).
- Name
spectrum- Type
- array
- Description
Espectros de luz disponibles.
Ejemplo de luz
{
"id": "light-001",
"name": "LED Samsung LM301H 600W",
"type": "LED",
"wattage": 600,
"voltage": 220,
"isActive": true,
"schedule": {
"on": "06:00",
"off": "18:00"
},
"spectrum": ["full", "bloom", "veg"]
}
Tipos de Luz (LightType)
| Tipo | Descripcion | Uso Tipico |
|---|---|---|
LED | Diodos emisores de luz | Ciclo completo, eficiente |
SODIUM | Sodio alta presion (HPS) | Floracion |
METAL_HALIDE | Halogenuros metalicos (MH) | Vegetativo |
FLUORESCENT | Tubos fluorescentes | Plantulas, esquejes |
CFL | Fluorescente compacta | Espacios pequenos |
HALOGEN | Halogeno | No recomendado |
INCANDESCENT | Incandescente | No recomendado |
OTHER | Otros tipos | - |
Listar luces
Parametros de Consulta
- Name
type- Type
- LightType
- Description
Filtrar por tipo.
- Name
isActive- Type
- boolean
- Description
Filtrar por estado.
- Name
search- Type
- string
- Description
Busqueda por nombre.
Request
curl -G https://api.cannahub.tech/api/lights \
-H "Authorization: Bearer {token}" \
-d type=LED \
-d isActive=true
Response
{
"lights": [
{
"id": "light-001",
"name": "LED Samsung 600W",
"type": "LED",
"wattage": 600,
"isActive": true
}
],
"count": 5,
"filters": { "type": "LED", "isActive": "true" }
}
Crear luz
Campos Requeridos
- Name
name- Type
- string
- Description
Nombre de la luz.
- Name
type- Type
- LightType
- Description
Tipo de luminaria.
- Name
wattage- Type
- number
- Description
Potencia en watts.
Campos Opcionales
- Name
voltage- Type
- number
- Description
Voltaje (default: 220).
- Name
isActive- Type
- boolean
- Description
Estado inicial (default: true).
- Name
schedule- Type
- LightSchedule
- Description
Horario de operacion.
- Name
spectrum- Type
- array
- Description
Espectros disponibles.
Request
curl -X POST https://api.cannahub.tech/api/lights \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"name": "HPS 1000W Floracion",
"type": "SODIUM",
"wattage": 1000,
"schedule": {
"on": "18:00",
"off": "06:00"
}
}'
Response (201)
{
"light": {
"id": "light-1698765432100",
"name": "HPS 1000W Floracion",
"type": "SODIUM",
"wattage": 1000,
"voltage": 220,
"isActive": true,
"schedule": { "on": "18:00", "off": "06:00" }
}
}
Obtener luz
Retorna los detalles de una luz especifica.
Request
curl https://api.cannahub.tech/api/lights/light-001 \
-H "Authorization: Bearer {token}"
Actualizar luz
Actualiza la configuracion de una luz.
Request
curl -X PATCH https://api.cannahub.tech/api/lights/light-001 \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"schedule": { "on": "06:00", "off": "00:00" },
"isActive": true
}'
Eliminar luz
Elimina una luz del sistema.
Request
curl -X DELETE https://api.cannahub.tech/api/lights/light-001 \
-H "Authorization: Bearer {token}"
Horarios por Etapa
Recomendaciones de fotoperiodo segun etapa del cultivo.
| Etapa | Horas Luz | Horas Oscuridad | Ratio |
|---|---|---|---|
| Germinacion | 18-24 | 0-6 | 18/6 o 24/0 |
| Plantula | 18 | 6 | 18/6 |
| Vegetativo | 18 | 6 | 18/6 |
| Pre-floracion | 12-18 | 6-12 | Transicion |
| Floracion | 12 | 12 | 12/12 |
React Query Hooks
Uso de hooks
import {
useLightsQuery,
useLightQuery,
useCreateLightMutation,
useUpdateLightMutation,
useDeleteLightMutation
} from '@/features/Club/Lights/hooks'
// Listar luces con filtros
const { data: lights, isLoading } = useLightsQuery({
type: 'LED',
isActive: true
})
// Obtener una luz
const { data: light } = useLightQuery('light-001')
// Crear luz
const createMutation = useCreateLightMutation()
await createMutation.mutateAsync({
name: 'LED Samsung 480W',
type: 'LED',
wattage: 480
})
// Actualizar luz
const updateMutation = useUpdateLightMutation()
await updateMutation.mutateAsync({
id: 'light-001',
data: { isActive: false }
})
// Eliminar luz
const deleteMutation = useDeleteLightMutation()
await deleteMutation.mutateAsync('light-001')
Query Keys
lightKeys = {
all: ['lights'],
lists: () => ['lights', 'list'],
list: (filters) => ['lights', 'list', filters],
details: () => ['lights', 'detail'],
detail: (id) => ['lights', 'detail', id]
}