From 3d7d10fd13d2f187e57c5a22d1d2c583b1f444b7 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 7 Jun 2024 13:09:38 +0200 Subject: [PATCH] Change Sensor Command code to templatable --- .../tcs_intercom/binary_sensor/__init__.py | 2 +- components/tcs_intercom/tcs_intercom.cpp | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/components/tcs_intercom/binary_sensor/__init__.py b/components/tcs_intercom/binary_sensor/__init__.py index 9cb5611..7046035 100644 --- a/components/tcs_intercom/binary_sensor/__init__.py +++ b/components/tcs_intercom/binary_sensor/__init__.py @@ -19,7 +19,7 @@ { cv.GenerateID(): cv.declare_id(TCSIntercomBinarySensor), cv.GenerateID(CONF_TCS_ID): cv.use_id(TCSIntercom), - cv.Required(CONF_COMMAND): cv.hex_uint32_t, + cv.Required(CONF_COMMAND): cv.templatable(cv.hex_uint32_t), cv.Optional(CONF_ICON, default="mdi:doorbell"): cv.icon, cv.Optional(CONF_NAME, default="Doorbell"): cv.string, cv.Optional(CONF_AUTO_OFF, default="3s"): cv.positive_time_period_milliseconds diff --git a/components/tcs_intercom/tcs_intercom.cpp b/components/tcs_intercom/tcs_intercom.cpp index 501f95c..b06974a 100644 --- a/components/tcs_intercom/tcs_intercom.cpp +++ b/components/tcs_intercom/tcs_intercom.cpp @@ -5,6 +5,9 @@ #include "esphome/core/application.h" #include +#include "esp_efuse.h" +#include "esp_efuse_table.h" + namespace esphome { namespace tcs_intercom @@ -21,6 +24,24 @@ namespace esphome { ESP_LOGCONFIG(TAG, "Setting up TCS Intercom..."); + #if defined(ESP32) + ESP_LOGD(TAG, "Check for Doorman Hardware Revision"); + + // Doorman Hardware Revision + uint8_t ver[3]; + uint32_t value; + esp_efuse_read_block(EFUSE_BLK3, &value, 0, 24); + ver[0] = value >> 0; + ver[1] = value >> 8; + ver[2] = value >> 16; + + if(ver[0] > 0) + { + ESP_LOGI(TAG, "Doorman Hardware detected: V%i.%i.%i", ver[0], ver[1], ver[2]); + } + #endif + + this->rx_pin_->setup(); this->tx_pin_->setup(); this->tx_pin_->digital_write(false);