Перейти до основного вмісту

💡 Device Type Registry

Single source of truth: packages/shared/src/types/deviceTypeRegistry.ts. Backend syncs to DB on startup via syncFromRegistry().

Taxonomy

Concepts

TermMeaning
DeviceTypeIdUnique identifier (matches firmware device_type string)
Categorysensor (reads env) or actuator (controls)
CapabilitiesState keys the device publishes via MQTT (must match field name in {"state":{...}})
CommandsActions Backend sends to device (enum value matches firmware addCommandHandler())
EventsActions device publishes via MQTT /event topic — device_event (auto) or user_event (button press)
Periodictrue = device sends telemetry on interval; false = event-driven

Current Types

TypeCategoryCapabilitiesCommandsEvents
climatesensortemperature, humidity, pressure
pirsensormotionmotion_detected, motion_cleared
switch-pirsensormotion, buttonbutton_press, motion_detected, motion_cleared
lightactuatoron, brightnesstoggle, set_brightness, turn_on, turn_offturned_on, turned_off

Adding a New Type

Frontend Rendering

ElementComponentSource
Capabilities (read-only)CapabilityValuesDeviceWidget
Commands (button)CommandButtonsSLIDER_COMMANDS map
Commands (slider)CommandSliderSLIDER_COMMANDS map
user_event triggersUserEventButtonsvirtual buttons

Reference