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 parameter, 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
Dimmeresp.device.dimmerName, 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, Mute, Channel, Channel RelativeTVTV
Washeresp.device.washerName, Running State*, Paused State*, Mode, Run CycleWASHERWASHER
Contact Sensoresp.device.contact-sensorName,
Contact Detection State*
SENSORCONTACT_SENSOR
Motion Sensoresp.device.motion-sensorName,
Motion Detection State*
XMOTION_SENSOR
Door Bellesp.device.doorbellName,
Bell 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
Set Top Boxesp.device.set-topName, Power, Media State, Media Control, App Selector, Input Selector, Volume, MuteSETTOPOTHERX
Remoteesp.device.remoteName, Power, Media State, Media Control, App Selector, Input Selector, Volume, MuteREMOTEOTHERX
Refrigeratoresp.device.refrigeratorName, Power, SetPointTempCelsiusREFRIGERATOROTHERX
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, StepDescription
Nameesp.param.nameStringRead, Write1, 32, -Name of the device
Poweresp.param.powerBoolesp.ui.toggleRead, WriteN/AUsed to turn on/off the device
Brightnessesp.param.brightnessIntesp.ui.sliderRead, Write0, 100, 1Brightness level of the device
Dimesp.param.dimIntesp.ui.sliderRead/Write0, 100, 1Alias to Brightness
CCTesp.param.cctIntesp.ui.sliderRead, Write2700, 6500, 100Color correlated temperature
Hueesp.param.hueIntesp.ui.sliderRead, Write0, 360, 1Hue of the light
Saturationesp.param.saturationIntesp.ui.sliderRead, Write0, 100, 1Saturation of the light
Intensityesp.param.intensityIntesp.ui.sliderRead, Write0, 100, 1Intensity of the light
Speedesp.param.speedIntesp.ui.sliderRead, Write0, 5, 1Speed of the fan
Directionesp.param.directionIntesp.ui.dropdownRead, Write0, 1, 1Direction of the fan (0: Forward, 1: Reverse)
Ambient Temperatureesp.param.temperatureFloatReadN/ACurrent ambient temperature
Target temperatureesp.param.setpoint-temperatureInt/Floatesp.ui.sliderRead/WriteN/Asingle target temperature
Lower Bound Target temperatureesp.param.setpoint-low-temperatureInt/Floatesp.ui.sliderRead/WriteN/AUsed in conjunction with Upper Bound Target temperature. Lower bound of the temperature range.
Upper Bound Target temperatureesp.param.setpoint-high-temperatureInt/Floatesp.ui.sliderRead/WriteN/AUsed in conjunction with Lower Bound Target temperature. Upper bound of the temperature range.
Ambient Humidityesp.param.humidityFloatReadN/ACurrent ambient humidity
Toggle Controlleresp.param.toggleBoolAny type
applicable
Read, WriteN/AGeneric toggle parameter
Range Controlleresp.param.rangeInt/FloatAny type
applicable
Read, WriteApp specificGeneric range parameter
Mode Controlleresp.param.modeStringesp.ui.dropdownRead, WriteN/AThe valid strings for this can be different, depending on device type
Lock Stateesp.param.lockstateIntesp.ui.toggleRead, Write0, 2, 1
0:Unlocked
1:Locked
2:Jammed
Used for Lock device
Blinds Positionesp.param.blinds-positionIntesp.ui.sliderRead/Write0, 100, 1Used for Blinds device, indicates the open percentage
Garage Positionesp.param.garage-positionIntesp.ui.sliderRead/Write0, 100, 1Used for Garage door device, indicates the open percentage
Light Modeesp.param.light-modeIntesp.ui.dropdown/
esp.ui.hidden
Read/Write0, 2, 1
0:Default(both HSV, CCT)
1:HSV
2:CCT
Used to set the light mode to HSV/CCT
AC Modeesp.paran.ac-modeStringesp.ui.dropdownRead/WriteN/ACurrent operating mode of the AC unit
Media Stateesp.param.media-activity-stateStringesp.ui.dropdownRead/WriteN/AIndicates whether Entertainment device is active
Playback Stateesp.param.media-playback-stateStringesp.ui.dropdownRead/WriteN/AIndicate the current state when playing media.
Media Controlesp.param.media-activity-controlStringesp.ui.dropdownRead/WriteN/AControls media playback (e.g., play, pause, stop)
Volumeesp.param.volumeFloatesp.ui.sliderRead/Write0, 20, 1Current volume level
Muteesp.param.muteBoolesp.ui.toggleRead/WriteN/AMute state of the device
App Selectoresp.param.app-selectorStringesp.ui.dropdownRead/WriteN/AUsed to select the app on entertainment device
Input Selectoresp.param.input-selectorStringesp.ui.dropdownRead/WriteN/AUsed to select the input on entertainment device
Contact Detection Stateesp.param.contact-detection-stateboolesp.ui.toggleReadN/AIndicates if contact is detected
Motion Detection Stateesp.param.motion-detection-stateboolesp.ui.toggleReadN/AIndicates if motion is detected
Arm Stateesp.param.arm-stateboolesp.ui.toggleRead/WriteN/ACurrent arm state of the security panel
Fire Alarm Stateesp.param.fire-alarmboolesp.ui.toggleReadN/AIndicates if fire alarm is triggered
Water Alarm Stateesp.param.water-alarmboolesp.ui.toggleReadN/AIndicates if water alarm is triggered
CO Detection Stateesp.param.carbon-monoxide-alarmboolesp.ui.toggleReadN/AIndicates if carbon monoxide alarm is triggered
Burglary Alarm Stateesp.param.burglary-alarmboolesp.ui.toggleReadN/AIndicates if burglary alarm is triggered
Bell Pressed Stateesp.param.bell-pressedboolesp.ui.triggerWriteN/AUsed to trigger bell press event
Run Cycleesp.param.run-cyclestringesp.ui.dropdownReadN/AIndicates current run cycle of the device
Running Stateesp.param.running-stateboolesp.ui.toggleRead/WriteN/ADevice can be started and stopped with this parameter
Paused stateesp.param.paused-stateboolesp.ui.toggleRead/WriteN/ADevice can be paused and unpaused with this parameter
Channelesp.param.channelstringesp.ui.textRead/WriteN/AUsed to set channel by channel code on entertainment device
Channel Relativeesp.param.channel-relativestringesp.ui.textRead/WriteN/AUsed to change channel on entertainment device
Media Playback Stateesp.param.media-playback-statestringesp.ui.textRead/WriteN/AIndicates the current state when playing media.
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

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