Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 1.04 KB

README.md

File metadata and controls

56 lines (44 loc) · 1.04 KB

Setup

Allow execute your code at end of setup process.

Parameters:

  • depends: Optional string or list of strings. Component names required in config to generate lambda. You could also set alias for component to use in your code.
  • lambda: c++ code to execute

Examples

setup: |-
  // put your c++ code here
setup:
  lambda: |-
    // put your c++ code here

Example using depends:

setup:
  depends: mqtt
  lambda: |-
    // g_mqtt is defind with id in config
    ESP_LOGI("setup", "MQTT prefix is %s", id(g_mqtt).get_topic_prefix());

Example using depends with alias:

setup:
  depends: mqtt as my_mqtt
  lambda: |-
    // my_mqtt may not be defind with id in config
    ESP_LOGI("setup", "MQTT prefix is %s", my_mqtt->get_topic_prefix());

Complex example:

setup:
  - depends:
      - mqtt as my_mqtt
      - ota
    lambda: |-
      // do something when only mqtt and ota exists in config
  - depends: [api, ota]
    lambda: |-
      // do something when only api and ota exists in config