Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/esphome/esphome into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
clydebarrow committed Apr 16, 2024
2 parents eafd852 + 0141982 commit b038b63
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/sync-device-classes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Python
uses: actions/[email protected]
with:
python-version: 3.11
python-version: 3.12

- name: Install Home Assistant
run: |
Expand All @@ -36,7 +36,7 @@ jobs:
python ./script/sync-device_class.py
- name: Commit changes
uses: peter-evans/[email protected].2
uses: peter-evans/[email protected].3
with:
commit-message: "Synchronise Device Classes from Home Assistant"
committer: esphomebot <[email protected]>
Expand Down
5 changes: 3 additions & 2 deletions esphome/components/esp32_ble_tracker/esp32_ble_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "esphome/core/automation.h"
#include "esphome/core/component.h"
#include "esphome/core/defines.h"
#include "esphome/core/helpers.h"

#include <array>
Expand Down Expand Up @@ -248,11 +249,11 @@ class ESP32BLETracker : public Component,
SemaphoreHandle_t scan_result_lock_;
SemaphoreHandle_t scan_end_lock_;
size_t scan_result_index_{0};
#if CONFIG_SPIRAM
#ifdef USE_PSRAM
const static u_int8_t SCAN_RESULT_BUFFER_SIZE = 32;
#else
const static u_int8_t SCAN_RESULT_BUFFER_SIZE = 16;
#endif // CONFIG_SPIRAM
#endif // USE_PSRAM
esp_ble_gap_cb_param_t::ble_scan_result_evt_param *scan_result_buffer_;
esp_bt_status_t scan_start_failed_{ESP_BT_STATUS_SUCCESS};
esp_bt_status_t scan_set_param_failed_{ESP_BT_STATUS_SUCCESS};
Expand Down
3 changes: 1 addition & 2 deletions esphome/components/font/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ def getmetrics(self, glyphs):
for glyph in glyphs:
mask = self.getmask(glyph, mode="1")
_, height = mask.size
if height > max_height:
max_height = height
max_height = max(max_height, height)
return (max_height, 0)


Expand Down
2 changes: 2 additions & 0 deletions esphome/components/psram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ async def to_code(config):
if CONF_SPEED in config:
add_idf_sdkconfig_option(f"{SPIRAM_SPEEDS[config[CONF_SPEED]]}", True)

cg.add_define("USE_PSRAM")

var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
2 changes: 1 addition & 1 deletion esphome/components/time/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _load_tzdata(iana_key: str) -> Optional[bytes]:
package = "tzdata.zoneinfo." + package_loc.replace("/", ".")

try:
return resources.read_binary(package, resource)
return (resources.files(package) / resource).read_bytes()
except (FileNotFoundError, ModuleNotFoundError):
return None

Expand Down
13 changes: 10 additions & 3 deletions esphome/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class FileResource:
resource: str

def path(self) -> ContextManager[Path]:
return importlib.resources.path(self.package, self.resource)
return importlib.resources.as_file(
importlib.resources.files(self.package) / self.resource
)


class ComponentManifest:
Expand Down Expand Up @@ -101,10 +103,15 @@ def resources(self) -> list[FileResource]:
loaded .py file (does not look through subdirectories)
"""
ret = []
for resource in importlib.resources.contents(self.package):

for resource in (
r.name
for r in importlib.resources.files(self.package).iterdir()
if r.is_file()
):
if Path(resource).suffix not in SOURCE_FILE_EXTENSIONS:
continue
if not importlib.resources.is_resource(self.package, resource):
if not importlib.resources.files(self.package).joinpath(resource).is_file():
# Not a resource = this is a directory (yeah this is confusing)
continue
ret.append(FileResource(self.package, resource))
Expand Down
4 changes: 2 additions & 2 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pylint==3.0.3
pylint==3.1.0
flake8==7.0.0 # also change in .pre-commit-config.yaml when updating
black==24.2.0 # also change in .pre-commit-config.yaml when updating
black==24.4.0 # also change in .pre-commit-config.yaml when updating
pyupgrade==3.15.1 # also change in .pre-commit-config.yaml when updating
pre-commit

Expand Down

0 comments on commit b038b63

Please sign in to comment.