Hi, @dcabot25
That second argument that the caps_switch_initialize
or any capability initializer function needs is the name of the component referred at the device profile you created at the Developer Workspace, hence, if you’re trying to integrate the Switch for every component of your pool, you should specify them at your device porfile, e.g.:
{
"name": "{ Your Pool Profile }",
"components": [
{
"label": "main",
"id": "main",
"capabilities": [ ... ],
"categories": []
},
{
"label": "heater",
"id": "heater",
"capabilities": [ ... ],
"categories": []
},
{
"label": "blower",
"id": "blower",
"capabilities": [ ... ],
"categories": []
},
{
"label": "pump",
"id": "pump",
"capabilities": [ ... ],
"categories": []
}
],
"metadata": { ... }
}
Then you can initialize these components and its capabilities at the capability_init
handler, e.g.:
static void capability_init()
{
main_switch = caps_switch_initialize(ctx, "main", NULL, NULL);
heater_switch = caps_switch_initialize(ctx, "heater", NULL, NULL);
blower_switch = caps_switch_initialize(ctx, "blower", NULL, NULL);
pump_switch = caps_switch_initialize(ctx, "pump", NULL, NULL);
// default state: switch - off
main_switch->set_switch_value(main_switch, "off")
heater_switch->set_switch_value(heater_switch, "off")
blower_switch->set_switch_value(blower_switch, "off")
pump_switch->set_switch_value(pump_switch, "off")
}
This way you’ll handle different switch states for each component under the same context.