Skip to main content

Overview

Settings models define parameter threshold configurations for greenhouse sectors. They work in conjunction with periods (DAY, NIGHT, ALL) to control automation behavior.

Setting

Domain model representing a parameter threshold configuration for a sector.
data class Setting(
    val id: Long,
    val code: String,
    val sectorId: Long,
    val sectorCode: String? = null,
    val tenantId: Long,
    val parameterId: Short,
    val parameterName: String?,
    val actuatorStateId: Short?,
    val actuatorStateName: String?,
    val value: String?,
    val description: String?,
    val isActive: Boolean,
    val createdAt: String
)

Fields

id
Long
Unique setting identifier
code
String
Auto-generated setting code
sectorId
Long
ID of the sector this setting applies to
tenantId
Long
ID of the owning tenant/client
parameterId
Short
ID of the parameter (references device_types, e.g., TEMPERATURE, HUMIDITY)
parameterName
String
Human-readable name of the parameter
actuatorStateId
Short
Optional actuator state to trigger (e.g., ON, OFF)
actuatorStateName
String
Human-readable name of the actuator state
value
String
Threshold value for the setting
description
String
Optional description of the setting
isActive
Boolean
Whether this setting is currently active

Computed Properties

initials
String
First two letters of parameter name in uppercase (or “SE” as fallback)
displayName
String
Parameter name or “Parameter ” as fallback
valueDisplay
String
Formatted value or ”-” if null
actuatorStateDisplayName
String
Actuator state name or “State ” or ”-“

Period

Domain model for period catalog entry. Periods define when a setting applies: DAY, NIGHT, or ALL (24h).
data class Period(
    val id: Short,
    val name: String
) {
    val displayName: String
        get() = when (name.uppercase()) {
            "DAY" -> "Day"
            "NIGHT" -> "Night"
            "ALL" -> "All Day"
            else -> name
        }
}

Fields

id
Short
Unique period identifier
name
String
Period name (DAY, NIGHT, ALL)

Computed Properties

displayName
String
User-friendly display name for the period

API DTOs

SettingResponse

API response DTO for settings from the backend.
@Serializable
data class SettingResponse(
    val id: Long,
    val code: String,
    val sectorId: Long,
    val sectorCode: String? = null,
    val tenantId: Long,
    val parameterId: Short,
    val parameterName: String? = null,
    val actuatorStateId: Short? = null,
    val actuatorStateName: String? = null,
    val value: String? = null,
    val description: String? = null,
    val isActive: Boolean = true,
    val createdAt: String,
    val updatedAt: String
)

SettingCreateRequest

Request DTO for creating a new setting.
@Serializable
data class SettingCreateRequest(
    val sectorId: Long,
    val parameterId: Short,
    val actuatorStateId: Short? = null,
    val value: String? = null,
    val description: String? = null,
    val isActive: Boolean = true
)

SettingUpdateRequest

Request DTO for updating an existing setting. All fields are optional for partial updates.
@Serializable
data class SettingUpdateRequest(
    val sectorId: Long? = null,
    val parameterId: Short? = null,
    val actuatorStateId: Short? = null,
    val value: String? = null,
    val description: String? = null,
    val isActive: Boolean? = null
)

Extension Functions

toDomain()

Converts API DTOs to domain models:
fun PeriodResponse.toDomain() = Period(id = id, name = name)

fun SettingResponse.toDomain() = Setting(
    id = id,
    code = code,
    sectorId = sectorId,
    sectorCode = sectorCode,
    // ... other fields
)

SettingsRepository

Repository for settings CRUD operations

CatalogRepository

Manage periods and other catalog data

Sector Models

Sector data models

Device Models

Device and actuator state models

Build docs developers (and LLMs) love