Изборник Затворити

ESPHome: Showing Project Name and Version as Text Sensors

Скраћена веза: 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");

Слични чланци

Оставите одговор

Ваша адреса е-поште неће бити објављена. Неопходна поља су означена *

Попуните израз тако да буде тачан: *

Ово веб место користи Акисмет како би смањило непожељне. Сазнајте како се ваши коментари обрађују.