Color Temperature Selector
The ColorTemp selector provides an input for color temperature values (typically used for lights).
Options
All color temperature selectors accept these common metadata options:
default?: number- Default color temperature valuedescription?: string- Human-readable description shown in the UIrequired?: boolean- Whether the field must be provided
ColorTemp-specific options (from ServiceListSelector["color_temp"]):
unit?: "kelvin" | "mired"- The unit of measurement for color temperaturemin?: number- Minimum color temperature valuemax?: number- Maximum color temperature valuemax_mireds?: number- Maximum color temperature in miredsmin_mireds?: number- Minimum color temperature in mireds
Return Type
The return type is always number (color temperature in mireds or kelvins, depending on configuration).
Example
import { TServiceParams } from "@digital-alchemy/core";
import { ServiceField } from "@digital-alchemy/synapse";
export function SynapseServiceCreate({
synapse,
context,
logger,
}: TServiceParams) {
synapse.service.create(
{
context,
description: "Set light color temperature",
fields: {
// Color temperature selector
color_temp: ServiceField.ColorTemp({
default: 370,
description: "Color temperature in mireds",
required: true,
}),
},
},
async data => {
// data.color_temp is typed as: number
logger.info(`Color temperature set to: ${data.color_temp}`);
}
);
}