Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change datetime id names in examples #3777

Merged
merged 5 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions components/datetime/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@ The ``date`` provided can be in one of 3 formats:

# String date
- datetime.date.set:
id: my_date
id: my_datetime_date
date: "2023-12-04"

# Individual date parts
- datetime.date.set:
id: my_date
id: my_datetime_date
date:
year: 2023
month: 12
day: 4

# Using a lambda
- datetime.date.set:
id: my_date
id: my_datetime_date
date: !lambda |-
// Return an ESPTime struct
return {.day_of_month: 4, .month: 12, .year: 2023};
Expand All @@ -142,7 +142,7 @@ advanced stuff (see the full API Reference for more info).
.. code-block:: cpp

// Within lambda, set the date to 2024-02-25
auto call = id(my_date).make_call();
auto call = id(my_datetime_date).make_call();
call.set_date("2024-02-25");
call.perform();

Expand Down Expand Up @@ -174,20 +174,20 @@ The ``time`` provided can be in one of 3 formats:

# String time
- datetime.time.set:
id: my_time
id: my_datetime_time
time: "12:34:56"

# Individual time parts
- datetime.time.set:
id: my_time
id: my_datetime_time
time:
hour: 12
minute: 34
second: 56

# Using a lambda
- datetime.time.set:
id: my_time
id: my_datetime_time
time: !lambda |-
// Return an ESPTime struct
return {.second: 56, .minute: 34, .hour: 12};
Expand All @@ -212,7 +212,7 @@ advanced stuff (see the full API Reference for more info).
.. code-block:: cpp

// Within lambda, set the time to 12:34:56
auto call = id(my_time).make_call();
auto call = id(my_datetime_time).make_call();
call.set_time("12:34:56");
call.perform();

Expand All @@ -227,7 +227,7 @@ advanced stuff (see the full API Reference for more info).
.. code-block:: cpp

// For example, create a custom log message when a value is received:
ESP_LOGI("main", "Value of my datetime: %0d:%02d:%02d", id(my_time).hour, id(my_time).minute, id(my_time).second);
ESP_LOGI("main", "Value of my datetime: %0d:%02d:%02d", id(my_datetime_time).hour, id(my_datetime_time).minute, id(my_datetime_time).second);


DateTime Automation
Expand Down
4 changes: 2 additions & 2 deletions components/datetime/template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using :ref:`lambdas <config-lambda>`.
datetime:
# Example Date
- platform: template
id: my_date
id: my_datetime_date
type: date
name: Pick a Date
optimistic: yes
Expand All @@ -22,7 +22,7 @@ using :ref:`lambdas <config-lambda>`.

# Example Time
- platform: template
id: my_time
id: my_datetime_time
type: time
name: Pick a Time
optimistic: yes
Expand Down