From 0ff543ffe5c38509ab1f8cd7ddcaffb4617b1a99 Mon Sep 17 00:00:00 2001
From: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Date: Thu, 28 Mar 2024 10:20:51 +1300
Subject: [PATCH 1/3] Disable truthy yamllint rule (#6442)

---
 .github/workflows/ci-api-proto.yml             | 1 -
 .github/workflows/ci-docker.yml                | 2 +-
 .github/workflows/ci.yml                       | 1 -
 .github/workflows/lock.yml                     | 1 -
 .github/workflows/needs-docs.yml               | 1 -
 .github/workflows/release.yml                  | 1 -
 .github/workflows/stale.yml                    | 1 -
 .github/workflows/sync-device-classes.yml      | 1 -
 .github/workflows/yaml-lint.yml                | 1 -
 .yamllint                                      | 1 +
 tests/components/lightwaverf/test.esp8266.yaml | 2 +-
 11 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/.github/workflows/ci-api-proto.yml b/.github/workflows/ci-api-proto.yml
index 038ef3a587..0b2465d1aa 100644
--- a/.github/workflows/ci-api-proto.yml
+++ b/.github/workflows/ci-api-proto.yml
@@ -1,6 +1,5 @@
 name: API Proto CI
 
-# yamllint disable-line rule:truthy
 on:
   pull_request:
     paths:
diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml
index 8a7b35fe33..f02efadf4d 100644
--- a/.github/workflows/ci-docker.yml
+++ b/.github/workflows/ci-docker.yml
@@ -2,7 +2,7 @@
 name: CI for docker images
 
 # Only run when docker paths change
-# yamllint disable-line rule:truthy
+
 on:
   push:
     branches: [dev, beta, release]
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 871f2e72c8..b0ac840972 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,7 +1,6 @@
 ---
 name: CI
 
-# yamllint disable-line rule:truthy
 on:
   push:
     branches: [dev, beta, release]
diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml
index e3d75f6d58..ee10f49f61 100644
--- a/.github/workflows/lock.yml
+++ b/.github/workflows/lock.yml
@@ -1,7 +1,6 @@
 ---
 name: Lock
 
-# yamllint disable-line rule:truthy
 on:
   schedule:
     - cron: "30 0 * * *"
diff --git a/.github/workflows/needs-docs.yml b/.github/workflows/needs-docs.yml
index 6a66e5769c..628b5cc5e3 100644
--- a/.github/workflows/needs-docs.yml
+++ b/.github/workflows/needs-docs.yml
@@ -1,6 +1,5 @@
 name: Needs Docs
 
-# yamllint disable-line rule:truthy
 on:
   pull_request:
     types: [labeled, unlabeled]
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6b567b5b6f..16469c904b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,7 +1,6 @@
 ---
 name: Publish Release
 
-# yamllint disable-line rule:truthy
 on:
   workflow_dispatch:
   release:
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
index 5f510ffe75..95f275e5a4 100644
--- a/.github/workflows/stale.yml
+++ b/.github/workflows/stale.yml
@@ -1,7 +1,6 @@
 ---
 name: Stale
 
-# yamllint disable-line rule:truthy
 on:
   schedule:
     - cron: "30 0 * * *"
diff --git a/.github/workflows/sync-device-classes.yml b/.github/workflows/sync-device-classes.yml
index 36fce2bbcf..3f8af4249a 100644
--- a/.github/workflows/sync-device-classes.yml
+++ b/.github/workflows/sync-device-classes.yml
@@ -1,7 +1,6 @@
 ---
 name: Synchronise Device Classes from Home Assistant
 
-# yamllint disable-line rule:truthy
 on:
   workflow_dispatch:
   schedule:
diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml
index 3694436866..a3c1937e56 100644
--- a/.github/workflows/yaml-lint.yml
+++ b/.github/workflows/yaml-lint.yml
@@ -1,7 +1,6 @@
 ---
 name: YAML lint
 
-# yamllint disable-line rule:truthy
 on:
   push:
     branches: [dev, beta, release]
diff --git a/.yamllint b/.yamllint
index 9cd1482869..22e9237f61 100644
--- a/.yamllint
+++ b/.yamllint
@@ -16,3 +16,4 @@ rules:
     indent-sequences: true
     check-multi-line-strings: false
   line-length: disable
+  truthy: disable
diff --git a/tests/components/lightwaverf/test.esp8266.yaml b/tests/components/lightwaverf/test.esp8266.yaml
index 8f983a3cca..7ed8000271 100644
--- a/tests/components/lightwaverf/test.esp8266.yaml
+++ b/tests/components/lightwaverf/test.esp8266.yaml
@@ -8,6 +8,6 @@ button:
     id: light_off_ceiling_sofa
     on_press:
       lightwaverf.send_raw:
-        code:  [0x04, 0x00, 0x00, 0x00, 0x0f, 0x03, 0x0d, 0x09, 0x08, 0x08]
+        code: [0x04, 0x00, 0x00, 0x00, 0x0f, 0x03, 0x0d, 0x09, 0x08, 0x08]
         name: "Sofa"
         repeat: 1

From 9194f7eb27f503e0f712d3e6407e48a16fc4ef99 Mon Sep 17 00:00:00 2001
From: Daniel Eisterhold <deisterhold@users.noreply.github.com>
Date: Wed, 27 Mar 2024 18:56:26 -0500
Subject: [PATCH 2/3] Add get_size method to QR Code header (#6430)

---
 esphome/components/qr_code/qr_code.cpp          | 12 ++++++++++++
 esphome/components/qr_code/qr_code.h            |  2 ++
 tests/components/qr_code/test.esp32-c3-idf.yaml |  7 +++++++
 tests/components/qr_code/test.esp32-c3.yaml     |  7 +++++++
 tests/components/qr_code/test.esp32-idf.yaml    |  7 +++++++
 tests/components/qr_code/test.esp32.yaml        |  7 +++++++
 tests/components/qr_code/test.esp8266.yaml      |  7 +++++++
 tests/components/qr_code/test.rp2040.yaml       |  7 +++++++
 8 files changed, 56 insertions(+)

diff --git a/esphome/components/qr_code/qr_code.cpp b/esphome/components/qr_code/qr_code.cpp
index aecf7628dc..b60e60a4b0 100644
--- a/esphome/components/qr_code/qr_code.cpp
+++ b/esphome/components/qr_code/qr_code.cpp
@@ -51,5 +51,17 @@ void QrCode::draw(display::Display *buff, uint16_t x_offset, uint16_t y_offset,
     }
   }
 }
+
+uint8_t QrCode::get_size() {
+  if (this->needs_update_) {
+    this->generate_qr_code();
+    this->needs_update_ = false;
+  }
+
+  uint8_t size = qrcodegen_getSize(this->qr_);
+
+  return size;
+}
+
 }  // namespace qr_code
 }  // namespace esphome
diff --git a/esphome/components/qr_code/qr_code.h b/esphome/components/qr_code/qr_code.h
index d88e0aa09a..ab4c587b6d 100644
--- a/esphome/components/qr_code/qr_code.h
+++ b/esphome/components/qr_code/qr_code.h
@@ -24,6 +24,8 @@ class QrCode : public Component {
 
   void generate_qr_code();
 
+  uint8_t get_size();
+
  protected:
   std::string value_;
   qrcodegen_Ecc ecc_;
diff --git a/tests/components/qr_code/test.esp32-c3-idf.yaml b/tests/components/qr_code/test.esp32-c3-idf.yaml
index 3e875c026c..63973b1aa2 100644
--- a/tests/components/qr_code/test.esp32-c3-idf.yaml
+++ b/tests/components/qr_code/test.esp32-c3-idf.yaml
@@ -11,6 +11,13 @@ display:
     cs_pin: 8
     dc_pin: 9
     reset_pin: 10
+    lambda: |-
+      // Draw a QR code in the center of the screen
+      auto scale = 2;
+      auto size = id(homepage_qr).get_size() * scale;
+      auto x = (it.get_width() / 2) - (size / 2);
+      auto y = (it.get_height() / 2) - (size / 2);
+      it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale);
 
 qr_code:
   - id: homepage_qr
diff --git a/tests/components/qr_code/test.esp32-c3.yaml b/tests/components/qr_code/test.esp32-c3.yaml
index 3e875c026c..63973b1aa2 100644
--- a/tests/components/qr_code/test.esp32-c3.yaml
+++ b/tests/components/qr_code/test.esp32-c3.yaml
@@ -11,6 +11,13 @@ display:
     cs_pin: 8
     dc_pin: 9
     reset_pin: 10
+    lambda: |-
+      // Draw a QR code in the center of the screen
+      auto scale = 2;
+      auto size = id(homepage_qr).get_size() * scale;
+      auto x = (it.get_width() / 2) - (size / 2);
+      auto y = (it.get_height() / 2) - (size / 2);
+      it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale);
 
 qr_code:
   - id: homepage_qr
diff --git a/tests/components/qr_code/test.esp32-idf.yaml b/tests/components/qr_code/test.esp32-idf.yaml
index b354a3f512..3e70d3258f 100644
--- a/tests/components/qr_code/test.esp32-idf.yaml
+++ b/tests/components/qr_code/test.esp32-idf.yaml
@@ -11,6 +11,13 @@ display:
     cs_pin: 12
     dc_pin: 13
     reset_pin: 21
+    lambda: |-
+      // Draw a QR code in the center of the screen
+      auto scale = 2;
+      auto size = id(homepage_qr).get_size() * scale;
+      auto x = (it.get_width() / 2) - (size / 2);
+      auto y = (it.get_height() / 2) - (size / 2);
+      it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale);
 
 qr_code:
   - id: homepage_qr
diff --git a/tests/components/qr_code/test.esp32.yaml b/tests/components/qr_code/test.esp32.yaml
index b354a3f512..3e70d3258f 100644
--- a/tests/components/qr_code/test.esp32.yaml
+++ b/tests/components/qr_code/test.esp32.yaml
@@ -11,6 +11,13 @@ display:
     cs_pin: 12
     dc_pin: 13
     reset_pin: 21
+    lambda: |-
+      // Draw a QR code in the center of the screen
+      auto scale = 2;
+      auto size = id(homepage_qr).get_size() * scale;
+      auto x = (it.get_width() / 2) - (size / 2);
+      auto y = (it.get_height() / 2) - (size / 2);
+      it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale);
 
 qr_code:
   - id: homepage_qr
diff --git a/tests/components/qr_code/test.esp8266.yaml b/tests/components/qr_code/test.esp8266.yaml
index dd0d75c472..3c304d7575 100644
--- a/tests/components/qr_code/test.esp8266.yaml
+++ b/tests/components/qr_code/test.esp8266.yaml
@@ -11,6 +11,13 @@ display:
     cs_pin: 5
     dc_pin: 15
     reset_pin: 16
+    lambda: |-
+      // Draw a QR code in the center of the screen
+      auto scale = 2;
+      auto size = id(homepage_qr).get_size() * scale;
+      auto x = (it.get_width() / 2) - (size / 2);
+      auto y = (it.get_height() / 2) - (size / 2);
+      it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale);
 
 qr_code:
   - id: homepage_qr
diff --git a/tests/components/qr_code/test.rp2040.yaml b/tests/components/qr_code/test.rp2040.yaml
index b0e046d275..94cb772ba3 100644
--- a/tests/components/qr_code/test.rp2040.yaml
+++ b/tests/components/qr_code/test.rp2040.yaml
@@ -11,6 +11,13 @@ display:
     cs_pin: 20
     dc_pin: 21
     reset_pin: 22
+    lambda: |-
+      // Draw a QR code in the center of the screen
+      auto scale = 2;
+      auto size = id(homepage_qr).get_size() * scale;
+      auto x = (it.get_width() / 2) - (size / 2);
+      auto y = (it.get_height() / 2) - (size / 2);
+      it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale);
 
 qr_code:
   - id: homepage_qr

From 731dcc40bcbadb197f0f2a091c4d3790f28e5980 Mon Sep 17 00:00:00 2001
From: mrtoy-me <118446898+mrtoy-me@users.noreply.github.com>
Date: Thu, 28 Mar 2024 12:19:27 +1000
Subject: [PATCH 3/3] Minor change to support sht85 sensor (#6415)

---
 CODEOWNERS                           |  1 +
 esphome/components/sht3xd/sensor.py  |  6 ++++--
 esphome/components/sht3xd/sht3xd.cpp | 21 ++++++++++++++++-----
 esphome/components/sht3xd/sht3xd.h   |  1 +
 4 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/CODEOWNERS b/CODEOWNERS
index 7c1f7ff70b..fafbaae6c6 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -309,6 +309,7 @@ esphome/components/sfa30/* @ghsensdev
 esphome/components/sgp40/* @SenexCrenshaw
 esphome/components/sgp4x/* @SenexCrenshaw @martgras
 esphome/components/shelly_dimmer/* @edge90 @rnauber
+esphome/components/sht3xd/* @mrtoy-me
 esphome/components/sht4x/* @sjtrny
 esphome/components/shutdown/* @esphome/core @jsuanet
 esphome/components/sigma_delta_output/* @Cat-Ion
diff --git a/esphome/components/sht3xd/sensor.py b/esphome/components/sht3xd/sensor.py
index 80e15a1ab9..1286489b29 100644
--- a/esphome/components/sht3xd/sensor.py
+++ b/esphome/components/sht3xd/sensor.py
@@ -14,6 +14,8 @@ from esphome.const import (
 
 CONF_HEATER_ENABLED = "heater_enabled"
 
+CODEOWNERS = ["@mrtoy-me"]
+
 DEPENDENCIES = ["i2c"]
 AUTO_LOAD = ["sensirion_common"]
 
@@ -26,13 +28,13 @@ CONFIG_SCHEMA = (
     cv.Schema(
         {
             cv.GenerateID(): cv.declare_id(SHT3XDComponent),
-            cv.Required(CONF_TEMPERATURE): sensor.sensor_schema(
+            cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
                 unit_of_measurement=UNIT_CELSIUS,
                 accuracy_decimals=1,
                 device_class=DEVICE_CLASS_TEMPERATURE,
                 state_class=STATE_CLASS_MEASUREMENT,
             ),
-            cv.Required(CONF_HUMIDITY): sensor.sensor_schema(
+            cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
                 unit_of_measurement=UNIT_PERCENT,
                 accuracy_decimals=1,
                 device_class=DEVICE_CLASS_HUMIDITY,
diff --git a/esphome/components/sht3xd/sht3xd.cpp b/esphome/components/sht3xd/sht3xd.cpp
index 25332165c0..888e954c6b 100644
--- a/esphome/components/sht3xd/sht3xd.cpp
+++ b/esphome/components/sht3xd/sht3xd.cpp
@@ -6,7 +6,11 @@ namespace sht3xd {
 
 static const char *const TAG = "sht3xd";
 
-static const uint16_t SHT3XD_COMMAND_READ_SERIAL_NUMBER = 0x3780;
+// use read serial number register with clock stretching disabled as per other SHT3XD_COMMAND registers
+// which provides support for SHT85 sensor
+// SHT85 does not support clock stretching and uses same registers as SHT3xd with clock stretching disabled
+static const uint16_t SHT3XD_COMMAND_READ_SERIAL_NUMBER = 0x3682;
+
 static const uint16_t SHT3XD_COMMAND_READ_STATUS = 0xF32D;
 static const uint16_t SHT3XD_COMMAND_CLEAR_STATUS = 0x3041;
 static const uint16_t SHT3XD_COMMAND_HEATER_ENABLE = 0x306D;
@@ -22,25 +26,32 @@ void SHT3XDComponent::setup() {
     this->mark_failed();
     return;
   }
+  this->serial_number_ = (uint32_t(raw_serial_number[0]) << 16) | uint32_t(raw_serial_number[1]);
+
   if (!this->write_command(heater_enabled_ ? SHT3XD_COMMAND_HEATER_ENABLE : SHT3XD_COMMAND_HEATER_DISABLE)) {
     this->mark_failed();
     return;
   }
-  uint32_t serial_number = (uint32_t(raw_serial_number[0]) << 16) | uint32_t(raw_serial_number[1]);
-  ESP_LOGV(TAG, "    Serial Number: 0x%08" PRIX32, serial_number);
 }
+
 void SHT3XDComponent::dump_config() {
   ESP_LOGCONFIG(TAG, "SHT3xD:");
-  LOG_I2C_DEVICE(this);
   if (this->is_failed()) {
-    ESP_LOGE(TAG, "Communication with SHT3xD failed!");
+    ESP_LOGE(TAG, "  Communication with SHT3xD failed!");
+    return;
   }
+  ESP_LOGD(TAG, "  Serial Number: 0x%08" PRIX32, this->serial_number_);
+  ESP_LOGD(TAG, "  Heater Enabled: %s", this->heater_enabled_ ? "true" : "false");
+
+  LOG_I2C_DEVICE(this);
   LOG_UPDATE_INTERVAL(this);
 
   LOG_SENSOR("  ", "Temperature", this->temperature_sensor_);
   LOG_SENSOR("  ", "Humidity", this->humidity_sensor_);
 }
+
 float SHT3XDComponent::get_setup_priority() const { return setup_priority::DATA; }
+
 void SHT3XDComponent::update() {
   if (this->status_has_warning()) {
     ESP_LOGD(TAG, "Retrying to reconnect the sensor.");
diff --git a/esphome/components/sht3xd/sht3xd.h b/esphome/components/sht3xd/sht3xd.h
index 4133bf7b93..d1a3360e69 100644
--- a/esphome/components/sht3xd/sht3xd.h
+++ b/esphome/components/sht3xd/sht3xd.h
@@ -25,6 +25,7 @@ class SHT3XDComponent : public PollingComponent, public sensirion_common::Sensir
   sensor::Sensor *temperature_sensor_{nullptr};
   sensor::Sensor *humidity_sensor_{nullptr};
   bool heater_enabled_{true};
+  uint32_t serial_number_{0};
 };
 
 }  // namespace sht3xd