Izbornik Zatvoriti

ESPHome: Showing Project Name and Version as Text Sensors

Skraćena veza: https://pedja.supurovic.net/veza/10698

There is option to assign project name and version in ESPHome device config. Values are displayed in log when device is powered up. It is useful to have those information as sensors so it is easy to check them, if needed. Here is how.

How to set project name and version:

esphome:
  name: "my_device"
  project:
    name: "Me.MyProject"
    version: "0.1.0"

And now create Text Sensors:

text_sensor:
  - platform: template
    name: "Project"
    lambda: |-
     return to_string(ESPHOME_PROJECT_NAME);

  - platform: template
    name: "Version"
    lambda: |-
      return to_string(ESPHOME_PROJECT_VERSION);

I like to use substitutions as it let’s me put all configuration at the beginning of the yaml and reuse values where needed. Thus Text Sensors could be set like this:

substitutions:
  device_name: "my_device"
  descriptive_device_name: "My Device"
  project_name: "Me.MyProject"
  project_version: "0.1.0"

esphome:
  name: $device_name
  project:
    name: $project_name
    version: $project_version

text_sensor:
  - platform: template
    name: "Project"
    lambda: |-
      return to_string("$project_name");

  - platform: template
    name: "Version"
    lambda: |-
      return to_string("$project_version");

Slični članci

Ostavite odgovor

Vaša adresa e-pošte neće biti objavljena. Neophodna polja su označena *

Popunite izraz tako da bude tačan: *

Ovo veb mesto koristi Akismet kako bi smanjilo nepoželjne. Saznajte kako se vaši komentari obrađuju.