Skip to main content

Custom & Standard Types

about

Custom vs Standard Pre-defined Types

In ESP RainMaker firmware development, types refer to predefined schemas that describe the nature of a device and its attributes like paramter, or UI element (Displayed in the phone app).

When you use custom types, you manually define every aspect of the device—such as name, parameters like power and brightness, their data types, UI hints, and bounds, etc—giving you full flexibility to model any device.

On the other hand, standard types (like esp_rmaker_lightbulb_device_create) are simplified helper APIs provided for common devices like light bulbs, fans, or temperature sensors, etc. These automatically handle parameter setup, assign standard UI elements, and enable better compatibility with RainMaker phone apps and third-party services like Alexa or Google Assistant. Standard types are ideal for common use cases and enable smoother integrations with minimal code.


Example Usage

Creating a custom device

Creating a Device generally requires multiple calls. For example, creating a Lightbulb with name, power, and brightness would need:

esp_rmaker_device_t *device = esp_rmaker_device_create("Light", NULL, NULL);

esp_rmaker_device_add_param(device, esp_rmaker_param_create("name", NULL, esp_rmaker_str("Light"),
PROP_FLAG_READ | PROP_FLAG_WRITE | PROP_FLAG_PERSIST));

esp_rmaker_param_t *power_param = esp_rmaker_param_create("power", NULL, esp_rmaker_bool(true), PROP_FLAG_READ | PROP_FLAG_WRITE);
esp_rmaker_param_add_ui_type(power_param, ESP_RMAKER_UI_TOGGLE);
esp_rmaker_device_add_param(device, power_param);
esp_rmaker_device_assign_primary_param(device, power_param);

esp_rmaker_param_t *brightness_param = esp_rmaker_param_create("brightness", NULL, esp_rmaker_int(100), PROP_FLAG_READ | PROP_FLAG_WRITE);
esp_rmaker_param_add_ui_type(brightness_param, ESP_RMAKER_UI_SLIDER);
esp_rmaker_param_add_bounds(brightness_param, esp_rmaker_int(0), esp_rmaker_int(100), esp_rmaker_int(1));
esp_rmaker_device_add_param(device, brightness_param);

This flexibility is useful as it lets you define any type of device. However, to simplify some common use cases, we have defined some standard types and have added helper APIs for them.


Creating a standard device

Using standard types, the above code will get reduced to this:

light_device = esp_rmaker_lightbulb_device_create("Light", NULL, true);
esp_rmaker_device_add_cb(light_device, write_cb, NULL);

esp_rmaker_device_add_param(light_device, esp_rmaker_brightness_param_create("brightness", 100));

These standard types are also useful for defining some special handling in phone apps or other third party applications like Alexa or Google Voice Assistants.


Standard Types

Below is a list of standard devices, services, parameters, and UI elements. This list will keep updating as we add new types.

Devices

caution

Parameters in Bold are mandatory. *indicates primary parameter.

C APIs to implement some of these can be found here. Others can be built using the raw APIs. They have been included here just to indicate that they have special handling in clients like the Alexa/GVA.

NameTypeParamsGVAAlexaImage
Switchesp.device.switchName, Power*SWITCHSWITCH
Lightbulbesp.device.lightbulbName, Power*, Brightness, Color Temperature, Hue, Saturation, Intensity, Light ModeLIGHTLIGHT
Lightesp.device.lightName, Power*, Brightness, Color Temperature, Hue, Saturation, Intensity, Light ModeLIGHTLIGHT
Fanesp.device.fanName, Power*, Speed, DirectionFANFAN
Temperature Sensoresp.device.temperature-sensorName, Temperature*XTEMPERATURE
_SENSOR
Outletesp.device.outletName, Power*OUTLETSMARTPLUG
Plugesp.device.plugName, Power*OUTLETSMARTPLUG
Socketesp.device.socketName, Power*OUTLETSMARTPLUG
Lockesp.device.lockName,
Lock State*
LOCKSMARTLOCK
Internal Blindsesp.device.blinds-internalName,
Blinds Position*
BLINDSINTERIOR_BLIND
External Blindsesp.device.blinds-externalName,
Blinds Position*
BLINDSEXTERIOR_BLIND
Garage Dooresp.device.garage-doorName,
Garage Position*, Lock State
GARAGEGARAGE_DOOR
Speakeresp.device.speakerName, Power*, Media State, Media Control, Volume, MuteSPEAKERSPEAKER
Air Conditioneresp.device.air-conditionerName, Power*, Setpoint Temperature, Temperature, Fan Speed, AC ModeAC_UNITAIR_CONDITIONER
Thermostatesp.device.thermostatName, Setpoint Temperature*, Temperature, AC Mode, PowerTHERMOSTATTHERMOSTAT
TVesp.device.tvName, Power*, Media State, Media Control App Selector, Input Selector, Volume, MuteTVTV
Washeresp.device.washerName, ModeWASHERWASHER
Contact Sensoresp.device.contact-sensorName,
Contact Detection State*
SENSORCONTACT_SENSOR
Motion Sensoresp.device.motion-sensorName,
Motion Detection State*
XMOTION_SENSOR
Door Bellesp.device.doorbellName,
Pressed State*
XDOORBELL
Security Panelesp.device.security-panelName, Arm State*,
Fire Alarm State,
Water Alarm State,
CO Alarm State,
Burglary Alarm State
XSECURITY_PANEL
Water Heateresp.device.water-heaterName, TemperatureWATERHEATERWATER_HEATERX
Otheresp.device.otherXOTHER

Services

caution

Parameters in Bold are mandatory.

C APIs to implement these can be found here.

NameTypeParams
OTAesp.service.otaOTA URL, OTA Status, OTA Info
Scheduleesp.service.schedulesSchedules
Timeesp.service.timeTZ, TZ-POSIX
Systemesp.service.systemReboot, Factory-Reset, Wi-Fi-Reset

Parameters

C APIs to implement some of these can be found here. Others can be built using the raw APIs. They have been included here just to indicate that they have special handling in clients like the Alexa/GVA.

NameTypeData TypeUI TypeProp-
erties
Min, Max, Step
Nameesp.param.nameStringRead, Write1, 32, -
Poweresp.param.powerBoolesp.ui.toggleRead, WriteN/A
Brightnessesp.param.brightnessIntesp.ui.sliderRead, Write0, 100, 1
CCTesp.param.cctIntesp.ui.sliderRead, Write2700, 6500, 100
Hueesp.param.hueIntesp.ui.sliderRead, Write0, 360, 1
Saturationesp.param.saturationIntesp.ui.sliderRead, Write0, 100, 1
Intensityesp.param.intensityIntesp.ui.sliderRead, Write0, 100, 1
Speedesp.param.speedIntesp.ui.sliderRead, Write0, 5, 1
Directionesp.param.directionIntesp.ui.dropdownRead, Write0, 1, 1
Ambient Temperatureesp.param.temperatureFloatReadN/A
Target temperatureesp.param.setpoint-temperatureInt/Floatesp.ui.sliderRead/WriteN/A
Ambient Humidityesp.param.humidityFloatReadN/A
OTA URLesp.param.ota_urlStringN/AWriteN/A
OTA Statusesp.param.ota_statusStringN/AReadN/A
OTA Infoesp.param.ota_infoStringN/AReadN/A
Timezoneesp.param.tzStringN/ARead, WriteN/A
Timezone POSIXesp.param.tz_posixStringN/ARead, WriteN/A
Schedulesesp.param.schedulesArrayN/ARead, Write, PersistN/A
Rebootesp.param.rebootBoolN/ARead, WriteN/A
Factory-Resetesp.param.factory-resetBoolN/ARead, WriteN/A
Wi-Fi-Resetesp.param.wifi-resetBoolN/ARead, WriteN/A
Toggle Controlleresp.param.toggleBoolAny type
applicable
Read, WriteN/A
Range Controlleresp.param.rangeInt/FloatAny type
applicable
Read, WriteApp specific
Mode Controlleresp.param.modeStringesp.ui.dropdownRead, WriteN/A
Lock Stateesp.param.lockstateIntesp.ui.toggleRead, Write0, 2, 1
0:Unlocked
1:Locked
2:Jammed
Blinds Positionesp.param.blinds-positionIntesp.ui.sliderRead/Write0, 100, 1
Garage Positionesp.param.garage-positionIntesp.ui.sliderRead/Write0, 100, 1
Light Modeesp.param.light-modeIntesp.ui.dropdown/
esp.ui.hidden
Read/Write0, 2, 1
0:invalid
1:HSV
2:CCT
AC Modeesp.paran.ac-modeStringesp.ui.dropdownRead/WriteN/A
Media Stateesp.param.media-activity-stateStringesp.ui.dropdownRead/WriteN/A
Media Controlesp.param.media-activity-controlStringesp.ui.dropdownRead/WriteN/A
Volumeesp.param.volumeFloatesp.ui.sliderRead/Write0, 20, 1
Muteesp.param.muteBoolesp.ui.toggleRead/WriteN/A
App Selectoresp.param.app-selectorStringesp.ui.dropdownRead/WriteN/A
Input Selectoresp.param.input-selectorStringesp.ui.dropdownRead/WriteN/A
Contact Detection Stateesp.param.contact-detection-stateboolesp.ui.toggleReadN/A
Motion Detection Stateesp.param.motion-detection-stateboolesp.ui.toggleReadN/A
Arm Stateesp.param.arm-stateboolesp.ui.toggleRead/WriteN/A
Fire Alarm Stateesp.param.fire-alarmboolesp.ui.toggleReadN/A
Water Alarm Stateesp.param.water-alarmboolesp.ui.toggleReadN/A
CO Detection Stateesp.param.carbon-monoxide-alarmboolesp.ui.toggleReadN/A
Burglary Alarm Stateesp.param.burglary-alarmboolesp.ui.toggleReadN/A

UI Elements

These define how the parameters should be rendered in the phone apps.

NameTypeData TypesRequirementsSample
Text (Default)esp.ui.textAllN/A
Toggle Switchesp.ui.toggleBoolN/A
Slideresp.ui.sliderInt, FloatBounds (min, max)
Brightness Slideresp.ui.sliderIntParam type =
esp.param.brightness
CCT Slideresp.ui.sliderIntParam type = esp.param.cct
Saturation Slideresp.ui.sliderIntParam type =
esp.param.saturation
Hue Slideresp.ui.hue-sliderIntParam type =
esp.param.hue
Hue Circleesp.ui.hue-circleIntParam type =
esp.param.hue
Push button (Big)esp.ui.push-btn-bigBoolN/A
Dropdownesp.ui.dropdownInt/StringBounds (min/max) for Int
Valid strs for String
Trigger
(Android only)
esp.ui.triggerBoolN/A
Hidden
(Android only)
esp.ui.hiddenBoolN/AParam will be hidden

On this page