Expose sensors to HA
This commit is contained in:
@@ -21,22 +21,12 @@ button:
|
||||
icon: mdi:file-sync
|
||||
id: tft_reparse_off
|
||||
entity_category: config
|
||||
internal: False
|
||||
disabled_by_default: true
|
||||
on_press:
|
||||
- logger.log: "Button pressed: Exit reparse"
|
||||
- script.execute: exit_reparse
|
||||
|
||||
##### UPDATE TFT BLANK DISPLAY #####
|
||||
- name: ${name} Update TFT display (blank)
|
||||
platform: template
|
||||
icon: mdi:file-sync
|
||||
id: tft_update_blank
|
||||
entity_category: config
|
||||
on_press:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "button.tft_update_blank";
|
||||
ESP_LOGD(TAG, "Button pressed: Update TFT display (blank)");
|
||||
upload_tft->execute("${nextion_blank_url}");
|
||||
|
||||
captive_portal:
|
||||
|
||||
sensor:
|
||||
@@ -70,7 +60,9 @@ text_sensor:
|
||||
##### ESPhome version used to compile the app #####
|
||||
- name: ${name} ESPhome Version
|
||||
platform: version
|
||||
disabled_by_default: true
|
||||
disabled_by_default: false
|
||||
internal: false
|
||||
icon: mdi:tag-text-outline
|
||||
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
|
||||
@@ -109,8 +109,7 @@ time:
|
||||
- seconds: 0
|
||||
then:
|
||||
- script.execute: refresh_datetime
|
||||
- minutes: /5
|
||||
seconds: 30
|
||||
- seconds: 30
|
||||
then:
|
||||
- script.execute: watchdog
|
||||
|
||||
@@ -1682,9 +1681,9 @@ text_sensor:
|
||||
entity_category: diagnostic
|
||||
icon: mdi:tag-text-outline
|
||||
internal: false
|
||||
update_interval: never
|
||||
lambda: |-
|
||||
return {"unknown"};
|
||||
update_interval: never
|
||||
on_value:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "text_sensor.version_blueprint";
|
||||
@@ -1703,6 +1702,7 @@ text_sensor:
|
||||
entity_category: diagnostic
|
||||
icon: mdi:tag-text-outline
|
||||
internal: false
|
||||
update_interval: never
|
||||
lambda: |-
|
||||
return {"${version}"};
|
||||
on_value:
|
||||
@@ -1724,6 +1724,7 @@ text_sensor:
|
||||
entity_category: diagnostic
|
||||
icon: mdi:tag-text-outline
|
||||
internal: false
|
||||
update_interval: never
|
||||
on_value:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "text_sensor.version_tft";
|
||||
@@ -1788,24 +1789,13 @@ script:
|
||||
ESP_LOGD(TAG, "Blueprint version: %s", version_blueprint->state.c_str());
|
||||
if (not compareVersions("${version}", version_blueprint->state.c_str())) ESP_LOGE(TAG, "Blueprint version mismatch!");
|
||||
|
||||
std::string framework = "unknown";
|
||||
#ifdef ARDUINO
|
||||
framework = "arduino";
|
||||
#elif defined(USE_ESP_IDF)
|
||||
framework = "esp-idf";
|
||||
#endif
|
||||
ESP_LOGD(TAG, "Framework: %s", framework.c_str());
|
||||
ESP_LOGD(TAG, "Baud rate: %" PRIu32, id(tf_uart).get_baud_rate());
|
||||
|
||||
auto ha_event = new esphome::api::CustomAPIDevice();
|
||||
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
|
||||
{
|
||||
{"type", "version"},
|
||||
{"tft", version_tft->state.c_str()},
|
||||
{"esphome", "${version}"},
|
||||
{"blueprint", version_blueprint->state.c_str()},
|
||||
{"framework", framework.c_str()},
|
||||
{"baud_rate", to_string(id(tf_uart).get_baud_rate())}
|
||||
{"blueprint", version_blueprint->state.c_str()}
|
||||
});
|
||||
|
||||
- id: display_embedded_temp
|
||||
@@ -3208,8 +3198,14 @@ script:
|
||||
ESP_LOGI(TAG, " Version: ${version}");
|
||||
// Report framework
|
||||
#ifdef ARDUINO
|
||||
size_t total_heap_size = ESP.getHeapSize();
|
||||
size_t free_heap_size = ESP.getFreeHeap();
|
||||
ESP_LOGI(TAG, " Heap: %zu bytes (%d%%)", free_heap_size, int(round(((float)free_heap_size / total_heap_size) * 100.0f)));
|
||||
ESP_LOGI(TAG, " Framework: arduino");
|
||||
#elif defined(USE_ESP_IDF)
|
||||
size_t total_heap_size = heap_caps_get_total_size(MALLOC_CAP_DEFAULT);
|
||||
size_t free_heap_size = esp_get_free_heap_size();
|
||||
ESP_LOGI(TAG, " Heap: %zu bytes (%d%%)", free_heap_size, int(round(((float)free_heap_size / total_heap_size) * 100.0f)));
|
||||
ESP_LOGI(TAG, " Framework: esp-idf");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
packages:
|
||||
core_package: !include advanced/esphome/nspanel_esphome_core.yaml
|
||||
#advanced_package: !include advanced/esphome/nspanel_esphome_advanced.yaml
|
||||
upload_tft_package: !include advanced/esphome/nspanel_esphome_addon_upload_tft.yaml
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user