Skip to content

Commit

Permalink
Add useful template examples for both text and numerical sensors (#4445)
Browse files Browse the repository at this point in the history
  • Loading branch information
jzucker2 authored Jan 24, 2025
1 parent 79ace6b commit 92bfa9d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
31 changes: 31 additions & 0 deletions components/sensor/template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,37 @@ Configuration options:
id(template_sens).publish_state(42.0);
Useful Template Sensors
-----------------------

Here are some useful sensors for debugging and tracking Bluetooth proxies.

.. code-block:: yaml
# Example configuration entry
sensor:
- platform: template
name: "Bluetooth Proxy Connections Limit"
id: bluetooth_proxy_connections_limit
icon: "mdi:bluetooth-settings"
update_interval: 30s
entity_category: "diagnostic"
lambda: |-
int limit = bluetooth_proxy::global_bluetooth_proxy->get_bluetooth_connections_limit();
ESP_LOGD("bluetooth_proxy_sensor", "Current connections limit => %d", limit);
return limit;
- platform: template
name: "Bluetooth Proxy Connections Free"
id: bluetooth_proxy_connections_free
icon: "mdi:bluetooth-settings"
update_interval: 30s
entity_category: "diagnostic"
lambda: |-
int free = bluetooth_proxy::global_bluetooth_proxy->get_bluetooth_connections_free();
ESP_LOGD("bluetooth_proxy_sensor", "Current connections free => %d", free);
return free;
See Also
--------

Expand Down
36 changes: 36 additions & 0 deletions components/text_sensor/template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,42 @@ Configuration options:
id(template_text).publish_state("Hello World");
Useful Template Sensors
-----------------------

Here are some useful text sensors for debugging and tracking project info.

.. code-block:: yaml
# Example configuration entry
text_sensor:
- platform: template
name: "ESPHome Project Version"
id: esphome_project_version_text_short
icon: "mdi:information-box"
entity_category: "diagnostic"
update_interval: 600s
lambda: |-
return { ESPHOME_PROJECT_VERSION };
- platform: template
name: "ESPHome Project Version Detailed"
id: esphome_project_version_text_detailed
icon: "mdi:information-box"
entity_category: "diagnostic"
update_interval: 600s
lambda: |-
return { ESPHOME_PROJECT_VERSION " " + App.get_compilation_time() };
- platform: template
name: "ESPHome Project Name"
id: esphome_project_name
icon: "mdi:information-box"
entity_category: "diagnostic"
update_interval: 600s
lambda: |-
return { ESPHOME_PROJECT_NAME };
See Also
--------

Expand Down

0 comments on commit 92bfa9d

Please sign in to comment.