mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 00:51:49 +00:00 
			
		
		
		
	Compare commits
	
		
			64 Commits
		
	
	
		
			2022.12.0b
			...
			2022.12.7
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					75c9823899 | ||
| 
						 | 
					c8c0bd3351 | ||
| 
						 | 
					e1cdeb7c8f | ||
| 
						 | 
					7f97f42552 | ||
| 
						 | 
					aa7f3569ec | ||
| 
						 | 
					2d0a08442e | ||
| 
						 | 
					d2380756b2 | ||
| 
						 | 
					925e3cb6c9 | ||
| 
						 | 
					6757acba56 | ||
| 
						 | 
					5cc91cdd95 | ||
| 
						 | 
					2b41886819 | ||
| 
						 | 
					72c6efd6a0 | ||
| 
						 | 
					a1f1804112 | ||
| 
						 | 
					a8b1ceb4e9 | ||
| 
						 | 
					4fb0f7f8c6 | ||
| 
						 | 
					958cadeca8 | ||
| 
						 | 
					00f2655f1a | ||
| 
						 | 
					074f5029eb | ||
| 
						 | 
					1691976587 | ||
| 
						 | 
					60e6b4d21e | ||
| 
						 | 
					5750591df2 | ||
| 
						 | 
					a75da54455 | ||
| 
						 | 
					de7f6c3f5f | ||
| 
						 | 
					4245480656 | ||
| 
						 | 
					1824c8131e | ||
| 
						 | 
					4e9606d2e0 | ||
| 
						 | 
					78500fa933 | ||
| 
						 | 
					9c69b98a49 | ||
| 
						 | 
					e6d8ef98d3 | ||
| 
						 | 
					3f1af1690b | ||
| 
						 | 
					84374b6b1e | ||
| 
						 | 
					391316c9b5 | ||
| 
						 | 
					705c62ebd7 | ||
| 
						 | 
					cb520c00a5 | ||
| 
						 | 
					2f24138345 | ||
| 
						 | 
					96512b80cc | ||
| 
						 | 
					fcb9b51978 | ||
| 
						 | 
					f408f1a368 | ||
| 
						 | 
					7d8d563c62 | ||
| 
						 | 
					0a1f705fda | ||
| 
						 | 
					1952c1880b | ||
| 
						 | 
					7209dd8bae | ||
| 
						 | 
					ab736c89bb | ||
| 
						 | 
					6911639617 | ||
| 
						 | 
					b9720d0715 | ||
| 
						 | 
					47b3267ed4 | ||
| 
						 | 
					e16ba2adb5 | ||
| 
						 | 
					0a19b1e32c | ||
| 
						 | 
					bae9a950c0 | ||
| 
						 | 
					72b2943332 | ||
| 
						 | 
					4ec0ef7548 | ||
| 
						 | 
					25bc6761f6 | ||
| 
						 | 
					81b6562c25 | ||
| 
						 | 
					ae74189fc2 | ||
| 
						 | 
					9e516efe10 | ||
| 
						 | 
					366e29439e | ||
| 
						 | 
					1c9c700d7f | ||
| 
						 | 
					b2e6b9d31f | ||
| 
						 | 
					7623f63846 | ||
| 
						 | 
					2bfaf9dce3 | ||
| 
						 | 
					5c2c1560bb | ||
| 
						 | 
					f7096ab78e | ||
| 
						 | 
					98f8feb625 | ||
| 
						 | 
					9944ca414e | 
							
								
								
									
										91
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										91
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							@@ -30,6 +30,10 @@ jobs:
 | 
			
		||||
            TAG=$(cat esphome/const.py | sed -n -E "s/^__version__\s+=\s+\"(.+)\"$/\1/p")
 | 
			
		||||
            today="$(date --utc '+%Y%m%d')"
 | 
			
		||||
            TAG="${TAG}${today}"
 | 
			
		||||
            BRANCH=${GITHUB_REF#refs/heads/}
 | 
			
		||||
            if [[ "$BRANCH" != "dev" ]]; then
 | 
			
		||||
              TAG="${TAG}-${BRANCH}"
 | 
			
		||||
            fi
 | 
			
		||||
          fi
 | 
			
		||||
          echo "tag=${TAG}" >> $GITHUB_OUTPUT
 | 
			
		||||
        # yamllint enable rule:line-length
 | 
			
		||||
@@ -57,7 +61,7 @@ jobs:
 | 
			
		||||
        run: twine upload dist/*
 | 
			
		||||
 | 
			
		||||
  deploy-docker:
 | 
			
		||||
    name: Build and publish docker containers
 | 
			
		||||
    name: Build and publish ESPHome ${{ matrix.image.title}}
 | 
			
		||||
    if: github.repository == 'esphome/esphome'
 | 
			
		||||
    permissions:
 | 
			
		||||
      contents: read
 | 
			
		||||
@@ -66,8 +70,19 @@ jobs:
 | 
			
		||||
    needs: [init]
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
        arch: [amd64, armv7, aarch64]
 | 
			
		||||
        build_type: ["ha-addon", "docker", "lint"]
 | 
			
		||||
        image:
 | 
			
		||||
          - title: "ha-addon"
 | 
			
		||||
            suffix: "hassio"
 | 
			
		||||
            target: "hassio"
 | 
			
		||||
            baseimg: "hassio"
 | 
			
		||||
          - title: "docker"
 | 
			
		||||
            suffix: ""
 | 
			
		||||
            target: "docker"
 | 
			
		||||
            baseimg: "docker"
 | 
			
		||||
          - title: "lint"
 | 
			
		||||
            suffix: "lint"
 | 
			
		||||
            target: "lint"
 | 
			
		||||
            baseimg: "docker"
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v3
 | 
			
		||||
      - name: Set up Python
 | 
			
		||||
@@ -92,54 +107,29 @@ jobs:
 | 
			
		||||
          username: ${{ github.actor }}
 | 
			
		||||
          password: ${{ secrets.GITHUB_TOKEN }}
 | 
			
		||||
 | 
			
		||||
      - name: Generate short tags
 | 
			
		||||
        id: tags
 | 
			
		||||
        run: |
 | 
			
		||||
          docker/generate_tags.py \
 | 
			
		||||
            --tag "${{ needs.init.outputs.tag }}" \
 | 
			
		||||
            --suffix "${{ matrix.image.suffix }}"
 | 
			
		||||
 | 
			
		||||
      - name: Build and push
 | 
			
		||||
        run: |
 | 
			
		||||
          docker/build.py \
 | 
			
		||||
            --tag "${{ needs.init.outputs.tag }}" \
 | 
			
		||||
            --arch "${{ matrix.arch }}" \
 | 
			
		||||
            --build-type "${{ matrix.build_type }}" \
 | 
			
		||||
            build \
 | 
			
		||||
            --push
 | 
			
		||||
 | 
			
		||||
  deploy-docker-manifest:
 | 
			
		||||
    if: github.repository == 'esphome/esphome'
 | 
			
		||||
    permissions:
 | 
			
		||||
      contents: read
 | 
			
		||||
      packages: write
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    needs: [init, deploy-docker]
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
        build_type: ["ha-addon", "docker", "lint"]
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v3
 | 
			
		||||
      - name: Set up Python
 | 
			
		||||
        uses: actions/setup-python@v4
 | 
			
		||||
        uses: docker/build-push-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          python-version: "3.9"
 | 
			
		||||
      - name: Enable experimental manifest support
 | 
			
		||||
        run: |
 | 
			
		||||
          mkdir -p ~/.docker
 | 
			
		||||
          echo "{\"experimental\": \"enabled\"}" > ~/.docker/config.json
 | 
			
		||||
 | 
			
		||||
      - name: Log in to docker hub
 | 
			
		||||
        uses: docker/login-action@v2
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKER_USER }}
 | 
			
		||||
          password: ${{ secrets.DOCKER_PASSWORD }}
 | 
			
		||||
      - name: Log in to the GitHub container registry
 | 
			
		||||
        uses: docker/login-action@v2
 | 
			
		||||
        with:
 | 
			
		||||
          registry: ghcr.io
 | 
			
		||||
          username: ${{ github.actor }}
 | 
			
		||||
          password: ${{ secrets.GITHUB_TOKEN }}
 | 
			
		||||
 | 
			
		||||
      - name: Run manifest
 | 
			
		||||
        run: |
 | 
			
		||||
          docker/build.py \
 | 
			
		||||
            --tag "${{ needs.init.outputs.tag }}" \
 | 
			
		||||
            --build-type "${{ matrix.build_type }}" \
 | 
			
		||||
            manifest
 | 
			
		||||
          context: .
 | 
			
		||||
          file: ./docker/Dockerfile
 | 
			
		||||
          platforms: linux/amd64,linux/arm/v7,linux/arm64
 | 
			
		||||
          target: ${{ matrix.image.target }}
 | 
			
		||||
          push: true
 | 
			
		||||
          # yamllint disable rule:line-length
 | 
			
		||||
          cache-from: type=registry,ref=ghcr.io/${{ steps.tags.outputs.image }}:cache-${{ steps.tags.outputs.channel }}
 | 
			
		||||
          cache-to: type=registry,ref=ghcr.io/${{ steps.tags.outputs.image }}:cache-${{ steps.tags.outputs.channel }},mode=max
 | 
			
		||||
          # yamllint enable rule:line-length
 | 
			
		||||
          tags: ${{ steps.tags.outputs.tags }}
 | 
			
		||||
          build-args: |
 | 
			
		||||
            BASEIMGTYPE=${{ matrix.image.baseimg }}
 | 
			
		||||
            BUILD_VERSION=${{ needs.init.outputs.tag }}
 | 
			
		||||
 | 
			
		||||
  deploy-ha-addon-repo:
 | 
			
		||||
    if: github.repository == 'esphome/esphome' && github.event_name == 'release'
 | 
			
		||||
@@ -150,11 +140,10 @@ jobs:
 | 
			
		||||
          TOKEN: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }}
 | 
			
		||||
        # yamllint disable rule:line-length
 | 
			
		||||
        run: |
 | 
			
		||||
          TAG="${GITHUB_REF#refs/tags/}"
 | 
			
		||||
          curl \
 | 
			
		||||
            -u ":$TOKEN" \
 | 
			
		||||
            -X POST \
 | 
			
		||||
            -H "Accept: application/vnd.github.v3+json" \
 | 
			
		||||
            https://api.github.com/repos/esphome/home-assistant-addon/actions/workflows/bump-version.yml/dispatches \
 | 
			
		||||
            -d "{\"ref\":\"main\",\"inputs\":{\"version\":\"$TAG\"}}"
 | 
			
		||||
            -d '{"ref":"main","inputs":{"version":"${{ github.event.release.tag_name }}","content":${{ toJSON(github.event.release.body) }}}}'
 | 
			
		||||
        # yamllint enable rule:line-length
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,9 @@ FROM debian:bullseye-20221024-slim AS base-docker
 | 
			
		||||
 | 
			
		||||
FROM base-${BASEIMGTYPE} AS base
 | 
			
		||||
 | 
			
		||||
ARG TARGETARCH
 | 
			
		||||
ARG TARGETVARIANT
 | 
			
		||||
 | 
			
		||||
RUN \
 | 
			
		||||
    apt-get update \
 | 
			
		||||
    # Use pinned versions so that we get updates with build caching
 | 
			
		||||
@@ -36,6 +39,14 @@ ENV \
 | 
			
		||||
  # Store globally installed pio libs in /piolibs
 | 
			
		||||
  PLATFORMIO_GLOBALLIB_DIR=/piolibs
 | 
			
		||||
 | 
			
		||||
# Support legacy binaries on Debian multiarch system. There is no "correct" way
 | 
			
		||||
# to do this, other than using properly built toolchains...
 | 
			
		||||
# See: https://unix.stackexchange.com/questions/553743/correct-way-to-add-lib-ld-linux-so-3-in-debian
 | 
			
		||||
RUN \
 | 
			
		||||
    if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
 | 
			
		||||
        ln -s /lib/arm-linux-gnueabihf/ld-linux.so.3 /lib/ld-linux.so.3; \
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
RUN \
 | 
			
		||||
    # Ubuntu python3-pip is missing wheel
 | 
			
		||||
    pip3 install --no-cache-dir \
 | 
			
		||||
@@ -128,7 +139,7 @@ RUN \
 | 
			
		||||
        clang-tidy-11=1:11.0.1-2 \
 | 
			
		||||
        patch=2.7.6-7 \
 | 
			
		||||
        software-properties-common=0.96.20.2-2.1 \
 | 
			
		||||
        nano=5.4-2+deb11u1 \
 | 
			
		||||
        nano=5.4-2+deb11u2 \
 | 
			
		||||
        build-essential=12.9 \
 | 
			
		||||
        python3-dev=3.9.2-3 \
 | 
			
		||||
    && rm -rf \
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										68
									
								
								docker/generate_tags.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										68
									
								
								docker/generate_tags.py
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
#!/usr/bin/env python3
 | 
			
		||||
import re
 | 
			
		||||
import os
 | 
			
		||||
import argparse
 | 
			
		||||
import json
 | 
			
		||||
 | 
			
		||||
CHANNEL_DEV = "dev"
 | 
			
		||||
CHANNEL_BETA = "beta"
 | 
			
		||||
CHANNEL_RELEASE = "release"
 | 
			
		||||
 | 
			
		||||
parser = argparse.ArgumentParser()
 | 
			
		||||
parser.add_argument(
 | 
			
		||||
    "--tag",
 | 
			
		||||
    type=str,
 | 
			
		||||
    required=True,
 | 
			
		||||
    help="The main docker tag to push to. If a version number also adds latest and/or beta tag",
 | 
			
		||||
)
 | 
			
		||||
parser.add_argument(
 | 
			
		||||
    "--suffix",
 | 
			
		||||
    type=str,
 | 
			
		||||
    required=True,
 | 
			
		||||
    help="The suffix of the tag.",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    args = parser.parse_args()
 | 
			
		||||
 | 
			
		||||
    # detect channel from tag
 | 
			
		||||
    match = re.match(r"^(\d+\.\d+)(?:\.\d+)?(b\d+)?$", args.tag)
 | 
			
		||||
    major_minor_version = None
 | 
			
		||||
    if match is None:
 | 
			
		||||
        channel = CHANNEL_DEV
 | 
			
		||||
    elif match.group(2) is None:
 | 
			
		||||
        major_minor_version = match.group(1)
 | 
			
		||||
        channel = CHANNEL_RELEASE
 | 
			
		||||
    else:
 | 
			
		||||
        channel = CHANNEL_BETA
 | 
			
		||||
 | 
			
		||||
    tags_to_push = [args.tag]
 | 
			
		||||
    if channel == CHANNEL_DEV:
 | 
			
		||||
        tags_to_push.append("dev")
 | 
			
		||||
    elif channel == CHANNEL_BETA:
 | 
			
		||||
        tags_to_push.append("beta")
 | 
			
		||||
    elif channel == CHANNEL_RELEASE:
 | 
			
		||||
        # Additionally push to beta
 | 
			
		||||
        tags_to_push.append("beta")
 | 
			
		||||
        tags_to_push.append("latest")
 | 
			
		||||
 | 
			
		||||
        if major_minor_version:
 | 
			
		||||
            tags_to_push.append("stable")
 | 
			
		||||
            tags_to_push.append(major_minor_version)
 | 
			
		||||
 | 
			
		||||
    suffix = f"-{args.suffix}" if args.suffix else ""
 | 
			
		||||
 | 
			
		||||
    with open(os.environ["GITHUB_OUTPUT"], "w") as f:
 | 
			
		||||
        print(f"channel={channel}", file=f)
 | 
			
		||||
        print(f"image=esphome/esphome{suffix}", file=f)
 | 
			
		||||
        full_tags = []
 | 
			
		||||
 | 
			
		||||
        for tag in tags_to_push:
 | 
			
		||||
            full_tags += [f"ghcr.io/esphome/esphome{suffix}:{tag}"]
 | 
			
		||||
            full_tags += [f"esphome/esphome{suffix}:{tag}"]
 | 
			
		||||
        print(f"tags={','.join(full_tags)}", file=f)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    main()
 | 
			
		||||
@@ -46,6 +46,7 @@ void A4988::loop() {
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  this->dir_pin_->digital_write(dir == 1);
 | 
			
		||||
  delayMicroseconds(50);
 | 
			
		||||
  this->step_pin_->digital_write(true);
 | 
			
		||||
  delayMicroseconds(5);
 | 
			
		||||
  this->step_pin_->digital_write(false);
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,13 @@ from esphome.components import esp32_ble_tracker, esp32_ble_client
 | 
			
		||||
import esphome.config_validation as cv
 | 
			
		||||
import esphome.codegen as cg
 | 
			
		||||
from esphome.const import CONF_ACTIVE, CONF_ID
 | 
			
		||||
from esphome.components.esp32 import add_idf_sdkconfig_option
 | 
			
		||||
 | 
			
		||||
AUTO_LOAD = ["esp32_ble_client", "esp32_ble_tracker"]
 | 
			
		||||
DEPENDENCIES = ["api", "esp32"]
 | 
			
		||||
CODEOWNERS = ["@jesserockz"]
 | 
			
		||||
 | 
			
		||||
CONF_CACHE_SERVICES = "cache_services"
 | 
			
		||||
CONF_CONNECTIONS = "connections"
 | 
			
		||||
MAX_CONNECTIONS = 3
 | 
			
		||||
 | 
			
		||||
@@ -47,6 +49,9 @@ CONFIG_SCHEMA = cv.All(
 | 
			
		||||
        {
 | 
			
		||||
            cv.GenerateID(): cv.declare_id(BluetoothProxy),
 | 
			
		||||
            cv.Optional(CONF_ACTIVE, default=False): cv.boolean,
 | 
			
		||||
            cv.SplitDefault(CONF_CACHE_SERVICES, esp32_idf=True): cv.All(
 | 
			
		||||
                cv.only_with_esp_idf, cv.boolean
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_CONNECTIONS): cv.All(
 | 
			
		||||
                cv.ensure_list(CONNECTION_SCHEMA),
 | 
			
		||||
                cv.Length(min=1, max=MAX_CONNECTIONS),
 | 
			
		||||
@@ -72,4 +77,7 @@ async def to_code(config):
 | 
			
		||||
        cg.add(var.register_connection(connection_var))
 | 
			
		||||
        await esp32_ble_tracker.register_client(connection_var, connection_conf)
 | 
			
		||||
 | 
			
		||||
    if config.get(CONF_CACHE_SERVICES):
 | 
			
		||||
        add_idf_sdkconfig_option("CONFIG_BT_GATTC_CACHE_NVS_FLASH", True)
 | 
			
		||||
 | 
			
		||||
    cg.add_define("USE_BLUETOOTH_PROXY")
 | 
			
		||||
 
 | 
			
		||||
@@ -88,7 +88,10 @@ void BME280Component::setup() {
 | 
			
		||||
 | 
			
		||||
  // Mark as not failed before initializing. Some devices will turn off sensors to save on batteries
 | 
			
		||||
  // and when they come back on, the COMPONENT_STATE_FAILED bit must be unset on the component.
 | 
			
		||||
  this->component_state_ &= ~COMPONENT_STATE_FAILED;
 | 
			
		||||
  if ((this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_FAILED) {
 | 
			
		||||
    this->component_state_ &= ~COMPONENT_STATE_MASK;
 | 
			
		||||
    this->component_state_ |= COMPONENT_STATE_CONSTRUCTION;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!this->read_byte(BME280_REGISTER_CHIPID, &chip_id)) {
 | 
			
		||||
    this->error_code_ = COMMUNICATION_FAILED;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
#include "bmp280.h"
 | 
			
		||||
#include "esphome/core/hal.h"
 | 
			
		||||
#include "esphome/core/log.h"
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
@@ -11,8 +12,11 @@ static const uint8_t BMP280_REGISTER_CONTROL = 0xF4;
 | 
			
		||||
static const uint8_t BMP280_REGISTER_CONFIG = 0xF5;
 | 
			
		||||
static const uint8_t BMP280_REGISTER_PRESSUREDATA = 0xF7;
 | 
			
		||||
static const uint8_t BMP280_REGISTER_TEMPDATA = 0xFA;
 | 
			
		||||
static const uint8_t BMP280_REGISTER_RESET = 0xE0;
 | 
			
		||||
 | 
			
		||||
static const uint8_t BMP280_MODE_FORCED = 0b01;
 | 
			
		||||
static const uint8_t BMP280_SOFT_RESET = 0xB6;
 | 
			
		||||
static const uint8_t BMP280_STATUS_IM_UPDATE = 0b01;
 | 
			
		||||
 | 
			
		||||
inline uint16_t combine_bytes(uint8_t msb, uint8_t lsb) { return ((msb & 0xFF) << 8) | (lsb & 0xFF); }
 | 
			
		||||
 | 
			
		||||
@@ -66,6 +70,28 @@ void BMP280Component::setup() {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Send a soft reset.
 | 
			
		||||
  if (!this->write_byte(BMP280_REGISTER_RESET, BMP280_SOFT_RESET)) {
 | 
			
		||||
    this->mark_failed();
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  // Wait until the NVM data has finished loading.
 | 
			
		||||
  uint8_t status;
 | 
			
		||||
  uint8_t retry = 5;
 | 
			
		||||
  do {
 | 
			
		||||
    delay(2);
 | 
			
		||||
    if (!this->read_byte(BMP280_REGISTER_STATUS, &status)) {
 | 
			
		||||
      ESP_LOGW(TAG, "Error reading status register.");
 | 
			
		||||
      this->mark_failed();
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
  } while ((status & BMP280_STATUS_IM_UPDATE) && (--retry));
 | 
			
		||||
  if (status & BMP280_STATUS_IM_UPDATE) {
 | 
			
		||||
    ESP_LOGW(TAG, "Timeout loading NVM.");
 | 
			
		||||
    this->mark_failed();
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Read calibration
 | 
			
		||||
  this->calibration_.t1 = this->read_u16_le_(0x88);
 | 
			
		||||
  this->calibration_.t2 = this->read_s16_le_(0x8A);
 | 
			
		||||
 
 | 
			
		||||
@@ -27,10 +27,10 @@ DEFAULT_DELAY = "2ms"
 | 
			
		||||
CONFIG_SCHEMA = cv.Schema(
 | 
			
		||||
    {
 | 
			
		||||
        cv.GenerateID(): cv.declare_id(CD74HC4067Component),
 | 
			
		||||
        cv.Required(CONF_PIN_S0): pins.internal_gpio_output_pin_schema,
 | 
			
		||||
        cv.Required(CONF_PIN_S1): pins.internal_gpio_output_pin_schema,
 | 
			
		||||
        cv.Required(CONF_PIN_S2): pins.internal_gpio_output_pin_schema,
 | 
			
		||||
        cv.Required(CONF_PIN_S3): pins.internal_gpio_output_pin_schema,
 | 
			
		||||
        cv.Required(CONF_PIN_S0): pins.gpio_output_pin_schema,
 | 
			
		||||
        cv.Required(CONF_PIN_S1): pins.gpio_output_pin_schema,
 | 
			
		||||
        cv.Required(CONF_PIN_S2): pins.gpio_output_pin_schema,
 | 
			
		||||
        cv.Required(CONF_PIN_S3): pins.gpio_output_pin_schema,
 | 
			
		||||
        cv.Optional(
 | 
			
		||||
            CONF_DELAY, default=DEFAULT_DELAY
 | 
			
		||||
        ): cv.positive_time_period_milliseconds,
 | 
			
		||||
 
 | 
			
		||||
@@ -19,22 +19,22 @@ class CD74HC4067Component : public Component {
 | 
			
		||||
  void activate_pin(uint8_t pin);
 | 
			
		||||
 | 
			
		||||
  /// set the pin connected to multiplexer control pin 0
 | 
			
		||||
  void set_pin_s0(InternalGPIOPin *pin) { this->pin_s0_ = pin; }
 | 
			
		||||
  void set_pin_s0(GPIOPin *pin) { this->pin_s0_ = pin; }
 | 
			
		||||
  /// set the pin connected to multiplexer control pin 1
 | 
			
		||||
  void set_pin_s1(InternalGPIOPin *pin) { this->pin_s1_ = pin; }
 | 
			
		||||
  void set_pin_s1(GPIOPin *pin) { this->pin_s1_ = pin; }
 | 
			
		||||
  /// set the pin connected to multiplexer control pin 2
 | 
			
		||||
  void set_pin_s2(InternalGPIOPin *pin) { this->pin_s2_ = pin; }
 | 
			
		||||
  void set_pin_s2(GPIOPin *pin) { this->pin_s2_ = pin; }
 | 
			
		||||
  /// set the pin connected to multiplexer control pin 3
 | 
			
		||||
  void set_pin_s3(InternalGPIOPin *pin) { this->pin_s3_ = pin; }
 | 
			
		||||
  void set_pin_s3(GPIOPin *pin) { this->pin_s3_ = pin; }
 | 
			
		||||
 | 
			
		||||
  /// set the delay needed after an input switch
 | 
			
		||||
  void set_switch_delay(uint32_t switch_delay) { this->switch_delay_ = switch_delay; }
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  InternalGPIOPin *pin_s0_;
 | 
			
		||||
  InternalGPIOPin *pin_s1_;
 | 
			
		||||
  InternalGPIOPin *pin_s2_;
 | 
			
		||||
  InternalGPIOPin *pin_s3_;
 | 
			
		||||
  GPIOPin *pin_s0_;
 | 
			
		||||
  GPIOPin *pin_s1_;
 | 
			
		||||
  GPIOPin *pin_s2_;
 | 
			
		||||
  GPIOPin *pin_s3_;
 | 
			
		||||
  /// the currently active pin
 | 
			
		||||
  uint8_t active_pin_;
 | 
			
		||||
  uint32_t switch_delay_;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ import requests
 | 
			
		||||
import esphome.codegen as cg
 | 
			
		||||
import esphome.config_validation as cv
 | 
			
		||||
from esphome.components.packages import validate_source_shorthand
 | 
			
		||||
from esphome.const import CONF_WIFI
 | 
			
		||||
from esphome.const import CONF_WIFI, CONF_REF
 | 
			
		||||
from esphome.wizard import wizard_file
 | 
			
		||||
from esphome.yaml_util import dump
 | 
			
		||||
from esphome import git
 | 
			
		||||
@@ -21,19 +21,32 @@ CODEOWNERS = ["@esphome/core"]
 | 
			
		||||
def validate_import_url(value):
 | 
			
		||||
    value = cv.string_strict(value)
 | 
			
		||||
    value = cv.Length(max=255)(value)
 | 
			
		||||
    # ignore result, only check if it's a valid shorthand
 | 
			
		||||
    validate_source_shorthand(value)
 | 
			
		||||
    return value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def validate_full_url(config):
 | 
			
		||||
    if not config[CONF_IMPORT_FULL_CONFIG]:
 | 
			
		||||
        return config
 | 
			
		||||
    source = validate_source_shorthand(config[CONF_PACKAGE_IMPORT_URL])
 | 
			
		||||
    if CONF_REF not in source:
 | 
			
		||||
        raise cv.Invalid(
 | 
			
		||||
            "Must specify a ref (branch or tag) to import from when importing full config"
 | 
			
		||||
        )
 | 
			
		||||
    return config
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CONF_PACKAGE_IMPORT_URL = "package_import_url"
 | 
			
		||||
CONF_IMPORT_FULL_CONFIG = "import_full_config"
 | 
			
		||||
 | 
			
		||||
CONFIG_SCHEMA = cv.Schema(
 | 
			
		||||
    {
 | 
			
		||||
        cv.Required(CONF_PACKAGE_IMPORT_URL): validate_import_url,
 | 
			
		||||
        cv.Optional(CONF_IMPORT_FULL_CONFIG, default=False): cv.boolean,
 | 
			
		||||
    }
 | 
			
		||||
CONFIG_SCHEMA = cv.All(
 | 
			
		||||
    cv.Schema(
 | 
			
		||||
        {
 | 
			
		||||
            cv.Required(CONF_PACKAGE_IMPORT_URL): validate_import_url,
 | 
			
		||||
            cv.Optional(CONF_IMPORT_FULL_CONFIG, default=False): cv.boolean,
 | 
			
		||||
        }
 | 
			
		||||
    ),
 | 
			
		||||
    validate_full_url,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
WIFI_CONFIG = """
 | 
			
		||||
@@ -49,7 +62,7 @@ async def to_code(config):
 | 
			
		||||
    url = config[CONF_PACKAGE_IMPORT_URL]
 | 
			
		||||
    if config[CONF_IMPORT_FULL_CONFIG]:
 | 
			
		||||
        url += "?full_config"
 | 
			
		||||
    cg.add(dashboard_import_ns.set_package_import_url(config[CONF_PACKAGE_IMPORT_URL]))
 | 
			
		||||
    cg.add(dashboard_import_ns.set_package_import_url(url))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def import_config(
 | 
			
		||||
 
 | 
			
		||||
@@ -398,11 +398,11 @@ spiffs,   data, spiffs,  0x391000, 0x00F000
 | 
			
		||||
 | 
			
		||||
IDF_PARTITIONS_CSV = """\
 | 
			
		||||
# Name,   Type, SubType, Offset,   Size, Flags
 | 
			
		||||
nvs,      data, nvs,     ,        0x4000,
 | 
			
		||||
otadata,  data, ota,     ,        0x2000,
 | 
			
		||||
phy_init, data, phy,     ,        0x1000,
 | 
			
		||||
app0,     app,  ota_0,   ,      0x1C0000,
 | 
			
		||||
app1,     app,  ota_1,   ,      0x1C0000,
 | 
			
		||||
nvs,      data, nvs,     ,       0x6d000,
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -95,7 +95,7 @@ void ESP32InternalGPIOPin::pin_mode(gpio::Flags flags) {
 | 
			
		||||
  // can't call gpio_config here because that logs in esp-idf which may cause issues
 | 
			
		||||
  gpio_set_direction(pin_, flags_to_mode(flags));
 | 
			
		||||
  gpio_pull_mode_t pull_mode = GPIO_FLOATING;
 | 
			
		||||
  if (flags & (gpio::FLAG_PULLUP | gpio::FLAG_PULLDOWN)) {
 | 
			
		||||
  if ((flags & gpio::FLAG_PULLUP) && (flags & gpio::FLAG_PULLDOWN)) {
 | 
			
		||||
    pull_mode = GPIO_PULLUP_PULLDOWN;
 | 
			
		||||
  } else if (flags & gpio::FLAG_PULLUP) {
 | 
			
		||||
    pull_mode = GPIO_PULLUP_ONLY;
 | 
			
		||||
@@ -128,7 +128,7 @@ void IRAM_ATTR ISRInternalGPIOPin::pin_mode(gpio::Flags flags) {
 | 
			
		||||
  auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
 | 
			
		||||
  gpio_set_direction(arg->pin, flags_to_mode(flags));
 | 
			
		||||
  gpio_pull_mode_t pull_mode = GPIO_FLOATING;
 | 
			
		||||
  if (flags & (gpio::FLAG_PULLUP | gpio::FLAG_PULLDOWN)) {
 | 
			
		||||
  if ((flags & gpio::FLAG_PULLUP) && (flags & gpio::FLAG_PULLDOWN)) {
 | 
			
		||||
    pull_mode = GPIO_PULLUP_PULLDOWN;
 | 
			
		||||
  } else if (flags & gpio::FLAG_PULLUP) {
 | 
			
		||||
    pull_mode = GPIO_PULLUP_ONLY;
 | 
			
		||||
 
 | 
			
		||||
@@ -2,12 +2,14 @@ import esphome.codegen as cg
 | 
			
		||||
import esphome.config_validation as cv
 | 
			
		||||
from esphome.const import CONF_ID
 | 
			
		||||
from esphome.core import CORE
 | 
			
		||||
from esphome.components.esp32 import add_idf_sdkconfig_option
 | 
			
		||||
from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant, const
 | 
			
		||||
 | 
			
		||||
DEPENDENCIES = ["esp32"]
 | 
			
		||||
CODEOWNERS = ["@jesserockz"]
 | 
			
		||||
CONFLICTS_WITH = ["esp32_ble_tracker", "esp32_ble_beacon"]
 | 
			
		||||
 | 
			
		||||
NO_BLUTOOTH_VARIANTS = [const.VARIANT_ESP32S2]
 | 
			
		||||
 | 
			
		||||
esp32_ble_ns = cg.esphome_ns.namespace("esp32_ble")
 | 
			
		||||
ESP32BLE = esp32_ble_ns.class_("ESP32BLE", cg.Component)
 | 
			
		||||
 | 
			
		||||
@@ -19,6 +21,15 @@ CONFIG_SCHEMA = cv.Schema(
 | 
			
		||||
).extend(cv.COMPONENT_SCHEMA)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def validate_variant(_):
 | 
			
		||||
    variant = get_esp32_variant()
 | 
			
		||||
    if variant in NO_BLUTOOTH_VARIANTS:
 | 
			
		||||
        raise cv.Invalid(f"{variant} does not support Bluetooth")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FINAL_VALIDATE_SCHEMA = validate_variant
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def to_code(config):
 | 
			
		||||
    var = cg.new_Pvariable(config[CONF_ID])
 | 
			
		||||
    await cg.register_component(var, config)
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ import esphome.config_validation as cv
 | 
			
		||||
from esphome.const import CONF_ID, CONF_TYPE, CONF_UUID, CONF_TX_POWER
 | 
			
		||||
from esphome.core import CORE, TimePeriod
 | 
			
		||||
from esphome.components.esp32 import add_idf_sdkconfig_option
 | 
			
		||||
from esphome.components import esp32_ble
 | 
			
		||||
 | 
			
		||||
DEPENDENCIES = ["esp32"]
 | 
			
		||||
CONFLICTS_WITH = ["esp32_ble_tracker"]
 | 
			
		||||
@@ -54,6 +55,8 @@ CONFIG_SCHEMA = cv.All(
 | 
			
		||||
    validate_config,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
FINAL_VALIDATE_SCHEMA = esp32_ble.validate_variant
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def to_code(config):
 | 
			
		||||
    uuid = config[CONF_UUID].hex
 | 
			
		||||
 
 | 
			
		||||
@@ -95,7 +95,9 @@ void BLEClientBase::release_services() {
 | 
			
		||||
  for (auto &svc : this->services_)
 | 
			
		||||
    delete svc;  // NOLINT(cppcoreguidelines-owning-memory)
 | 
			
		||||
  this->services_.clear();
 | 
			
		||||
#ifndef CONFIG_BT_GATTC_CACHE_NVS_FLASH
 | 
			
		||||
  esp_ble_gattc_cache_clean(this->remote_bda_);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t esp_gattc_if,
 | 
			
		||||
@@ -130,16 +132,16 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
 | 
			
		||||
        this->set_state(espbt::ClientState::IDLE);
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      if (this->connection_type_ == espbt::ConnectionType::V3_WITH_CACHE) {
 | 
			
		||||
        this->set_state(espbt::ClientState::CONNECTED);
 | 
			
		||||
        this->state_ = espbt::ClientState::ESTABLISHED;
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      auto ret = esp_ble_gattc_send_mtu_req(this->gattc_if_, param->open.conn_id);
 | 
			
		||||
      if (ret) {
 | 
			
		||||
        ESP_LOGW(TAG, "[%d] [%s] esp_ble_gattc_send_mtu_req failed, status=%x", this->connection_index_,
 | 
			
		||||
                 this->address_str_.c_str(), ret);
 | 
			
		||||
      }
 | 
			
		||||
      if (this->connection_type_ == espbt::ConnectionType::V3_WITH_CACHE) {
 | 
			
		||||
        this->set_state(espbt::ClientState::CONNECTED);
 | 
			
		||||
        this->state_ = espbt::ClientState::ESTABLISHED;
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      esp_ble_gattc_search_service(esp_gattc_if, param->cfg_mtu.conn_id, nullptr);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
@@ -288,14 +290,17 @@ float BLEClientBase::parse_char_value(uint8_t *value, uint16_t length) {
 | 
			
		||||
      if (length > 2) {
 | 
			
		||||
        return (float) encode_uint16(value[1], value[2]);
 | 
			
		||||
      }
 | 
			
		||||
      // fall through
 | 
			
		||||
    case 0x7:  // uint24.
 | 
			
		||||
      if (length > 3) {
 | 
			
		||||
        return (float) encode_uint24(value[1], value[2], value[3]);
 | 
			
		||||
      }
 | 
			
		||||
      // fall through
 | 
			
		||||
    case 0x8:  // uint32.
 | 
			
		||||
      if (length > 4) {
 | 
			
		||||
        return (float) encode_uint32(value[1], value[2], value[3], value[4]);
 | 
			
		||||
      }
 | 
			
		||||
      // fall through
 | 
			
		||||
    case 0xC:  // int8.
 | 
			
		||||
      return (float) ((int8_t) value[1]);
 | 
			
		||||
    case 0xD:  // int12.
 | 
			
		||||
@@ -303,10 +308,12 @@ float BLEClientBase::parse_char_value(uint8_t *value, uint16_t length) {
 | 
			
		||||
      if (length > 2) {
 | 
			
		||||
        return (float) ((int16_t)(value[1] << 8) + (int16_t) value[2]);
 | 
			
		||||
      }
 | 
			
		||||
      // fall through
 | 
			
		||||
    case 0xF:  // int24.
 | 
			
		||||
      if (length > 3) {
 | 
			
		||||
        return (float) ((int32_t)(value[1] << 16) + (int32_t)(value[2] << 8) + (int32_t)(value[3]));
 | 
			
		||||
      }
 | 
			
		||||
      // fall through
 | 
			
		||||
    case 0x10:  // int32.
 | 
			
		||||
      if (length > 4) {
 | 
			
		||||
        return (float) ((int32_t)(value[1] << 24) + (int32_t)(value[2] << 16) + (int32_t)(value[3] << 8) +
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,7 @@ from esphome.const import (
 | 
			
		||||
)
 | 
			
		||||
from esphome.core import CORE
 | 
			
		||||
from esphome.components.esp32 import add_idf_sdkconfig_option
 | 
			
		||||
from esphome.components import esp32_ble
 | 
			
		||||
 | 
			
		||||
DEPENDENCIES = ["esp32"]
 | 
			
		||||
 | 
			
		||||
@@ -187,6 +188,8 @@ CONFIG_SCHEMA = cv.Schema(
 | 
			
		||||
    }
 | 
			
		||||
).extend(cv.COMPONENT_SCHEMA)
 | 
			
		||||
 | 
			
		||||
FINAL_VALIDATE_SCHEMA = esp32_ble.validate_variant
 | 
			
		||||
 | 
			
		||||
ESP_BLE_DEVICE_SCHEMA = cv.Schema(
 | 
			
		||||
    {
 | 
			
		||||
        cv.GenerateID(CONF_ESP32_BLE_ID): cv.use_id(ESP32BLETracker),
 | 
			
		||||
 
 | 
			
		||||
@@ -706,11 +706,7 @@ void ESPBTDevice::parse_adv_(const esp_ble_gap_cb_param_t::ble_scan_result_evt_p
 | 
			
		||||
  while (offset + 2 < len) {
 | 
			
		||||
    const uint8_t field_length = payload[offset++];  // First byte is length of adv record
 | 
			
		||||
    if (field_length == 0) {
 | 
			
		||||
      if (offset < param.adv_data_len && param.scan_rsp_len > 0) {  // Zero padded advertisement data
 | 
			
		||||
        offset = param.adv_data_len;
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      continue;  // Possible zero padded advertisement data
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // first byte of adv record is adv record type
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,11 @@ void ESP32Camera::dump_config() {
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "  HREF Pin: %d", conf.pin_href);
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "  Pixel Clock Pin: %d", conf.pin_pclk);
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "  External Clock: Pin:%d Frequency:%u", conf.pin_xclk, conf.xclk_freq_hz);
 | 
			
		||||
#ifdef USE_ESP_IDF  // Temporary until the espressif/esp32-camera library is updated
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "  I2C Pins: SDA:%d SCL:%d", conf.pin_sscb_sda, conf.pin_sscb_scl);
 | 
			
		||||
#else
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "  I2C Pins: SDA:%d SCL:%d", conf.pin_sccb_sda, conf.pin_sccb_scl);
 | 
			
		||||
#endif
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "  Reset Pin: %d", conf.pin_reset);
 | 
			
		||||
  switch (this->config_.frame_size) {
 | 
			
		||||
    case FRAMESIZE_QQVGA:
 | 
			
		||||
@@ -209,8 +213,13 @@ void ESP32Camera::set_external_clock(uint8_t pin, uint32_t frequency) {
 | 
			
		||||
  this->config_.xclk_freq_hz = frequency;
 | 
			
		||||
}
 | 
			
		||||
void ESP32Camera::set_i2c_pins(uint8_t sda, uint8_t scl) {
 | 
			
		||||
#ifdef USE_ESP_IDF  // Temporary until the espressif/esp32-camera library is updated
 | 
			
		||||
  this->config_.pin_sscb_sda = sda;
 | 
			
		||||
  this->config_.pin_sscb_scl = scl;
 | 
			
		||||
#else
 | 
			
		||||
  this->config_.pin_sccb_sda = sda;
 | 
			
		||||
  this->config_.pin_sccb_scl = scl;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
void ESP32Camera::set_reset_pin(uint8_t pin) { this->config_.pin_reset = pin; }
 | 
			
		||||
void ESP32Camera::set_power_down_pin(uint8_t pin) { this->config_.pin_pwdn = pin; }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
#include "esp32_can.h"
 | 
			
		||||
#include "esphome/core/log.h"
 | 
			
		||||
 | 
			
		||||
#include <driver/can.h>
 | 
			
		||||
#include <driver/twai.h>
 | 
			
		||||
 | 
			
		||||
// WORKAROUND, because CAN_IO_UNUSED is just defined as (-1) in this version
 | 
			
		||||
// of the framework which does not work with -fpermissive
 | 
			
		||||
@@ -14,25 +14,25 @@ namespace esp32_can {
 | 
			
		||||
 | 
			
		||||
static const char *const TAG = "esp32_can";
 | 
			
		||||
 | 
			
		||||
static bool get_bitrate(canbus::CanSpeed bitrate, can_timing_config_t *t_config) {
 | 
			
		||||
static bool get_bitrate(canbus::CanSpeed bitrate, twai_timing_config_t *t_config) {
 | 
			
		||||
  switch (bitrate) {
 | 
			
		||||
    case canbus::CAN_50KBPS:
 | 
			
		||||
      *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_50KBITS();
 | 
			
		||||
      *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_50KBITS();
 | 
			
		||||
      return true;
 | 
			
		||||
    case canbus::CAN_100KBPS:
 | 
			
		||||
      *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_100KBITS();
 | 
			
		||||
      *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_100KBITS();
 | 
			
		||||
      return true;
 | 
			
		||||
    case canbus::CAN_125KBPS:
 | 
			
		||||
      *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_125KBITS();
 | 
			
		||||
      *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_125KBITS();
 | 
			
		||||
      return true;
 | 
			
		||||
    case canbus::CAN_250KBPS:
 | 
			
		||||
      *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_250KBITS();
 | 
			
		||||
      *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_250KBITS();
 | 
			
		||||
      return true;
 | 
			
		||||
    case canbus::CAN_500KBPS:
 | 
			
		||||
      *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_500KBITS();
 | 
			
		||||
      *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_500KBITS();
 | 
			
		||||
      return true;
 | 
			
		||||
    case canbus::CAN_1000KBPS:
 | 
			
		||||
      *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_1MBITS();
 | 
			
		||||
      *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_1MBITS();
 | 
			
		||||
      return true;
 | 
			
		||||
    default:
 | 
			
		||||
      return false;
 | 
			
		||||
@@ -40,10 +40,10 @@ static bool get_bitrate(canbus::CanSpeed bitrate, can_timing_config_t *t_config)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool ESP32Can::setup_internal() {
 | 
			
		||||
  can_general_config_t g_config =
 | 
			
		||||
      CAN_GENERAL_CONFIG_DEFAULT((gpio_num_t) this->tx_, (gpio_num_t) this->rx_, CAN_MODE_NORMAL);
 | 
			
		||||
  can_filter_config_t f_config = CAN_FILTER_CONFIG_ACCEPT_ALL();
 | 
			
		||||
  can_timing_config_t t_config;
 | 
			
		||||
  twai_general_config_t g_config =
 | 
			
		||||
      TWAI_GENERAL_CONFIG_DEFAULT((gpio_num_t) this->tx_, (gpio_num_t) this->rx_, TWAI_MODE_NORMAL);
 | 
			
		||||
  twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
 | 
			
		||||
  twai_timing_config_t t_config;
 | 
			
		||||
 | 
			
		||||
  if (!get_bitrate(this->bit_rate_, &t_config)) {
 | 
			
		||||
    // invalid bit rate
 | 
			
		||||
@@ -51,15 +51,15 @@ bool ESP32Can::setup_internal() {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Install CAN driver
 | 
			
		||||
  if (can_driver_install(&g_config, &t_config, &f_config) != ESP_OK) {
 | 
			
		||||
  // Install TWAI driver
 | 
			
		||||
  if (twai_driver_install(&g_config, &t_config, &f_config) != ESP_OK) {
 | 
			
		||||
    // Failed to install driver
 | 
			
		||||
    this->mark_failed();
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Start CAN driver
 | 
			
		||||
  if (can_start() != ESP_OK) {
 | 
			
		||||
  // Start TWAI driver
 | 
			
		||||
  if (twai_start() != ESP_OK) {
 | 
			
		||||
    // Failed to start driver
 | 
			
		||||
    this->mark_failed();
 | 
			
		||||
    return false;
 | 
			
		||||
@@ -72,15 +72,15 @@ canbus::Error ESP32Can::send_message(struct canbus::CanFrame *frame) {
 | 
			
		||||
    return canbus::ERROR_FAILTX;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  uint32_t flags = CAN_MSG_FLAG_NONE;
 | 
			
		||||
  uint32_t flags = TWAI_MSG_FLAG_NONE;
 | 
			
		||||
  if (frame->use_extended_id) {
 | 
			
		||||
    flags |= CAN_MSG_FLAG_EXTD;
 | 
			
		||||
    flags |= TWAI_MSG_FLAG_EXTD;
 | 
			
		||||
  }
 | 
			
		||||
  if (frame->remote_transmission_request) {
 | 
			
		||||
    flags |= CAN_MSG_FLAG_RTR;
 | 
			
		||||
    flags |= TWAI_MSG_FLAG_RTR;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  can_message_t message = {
 | 
			
		||||
  twai_message_t message = {
 | 
			
		||||
      .flags = flags,
 | 
			
		||||
      .identifier = frame->can_id,
 | 
			
		||||
      .data_length_code = frame->can_data_length_code,
 | 
			
		||||
@@ -89,7 +89,7 @@ canbus::Error ESP32Can::send_message(struct canbus::CanFrame *frame) {
 | 
			
		||||
    memcpy(message.data, frame->data, frame->can_data_length_code);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (can_transmit(&message, pdMS_TO_TICKS(1000)) == ESP_OK) {
 | 
			
		||||
  if (twai_transmit(&message, pdMS_TO_TICKS(1000)) == ESP_OK) {
 | 
			
		||||
    return canbus::ERROR_OK;
 | 
			
		||||
  } else {
 | 
			
		||||
    return canbus::ERROR_ALLTXBUSY;
 | 
			
		||||
@@ -97,15 +97,15 @@ canbus::Error ESP32Can::send_message(struct canbus::CanFrame *frame) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
canbus::Error ESP32Can::read_message(struct canbus::CanFrame *frame) {
 | 
			
		||||
  can_message_t message;
 | 
			
		||||
  twai_message_t message;
 | 
			
		||||
 | 
			
		||||
  if (can_receive(&message, 0) != ESP_OK) {
 | 
			
		||||
  if (twai_receive(&message, 0) != ESP_OK) {
 | 
			
		||||
    return canbus::ERROR_NOMSG;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  frame->can_id = message.identifier;
 | 
			
		||||
  frame->use_extended_id = message.flags & CAN_MSG_FLAG_EXTD;
 | 
			
		||||
  frame->remote_transmission_request = message.flags & CAN_MSG_FLAG_RTR;
 | 
			
		||||
  frame->use_extended_id = message.flags & TWAI_MSG_FLAG_EXTD;
 | 
			
		||||
  frame->remote_transmission_request = message.flags & TWAI_MSG_FLAG_RTR;
 | 
			
		||||
  frame->can_data_length_code = message.data_length_code;
 | 
			
		||||
 | 
			
		||||
  if (!frame->remote_transmission_request) {
 | 
			
		||||
 
 | 
			
		||||
@@ -103,9 +103,11 @@ void I2SAudioMediaPlayer::stop_() {
 | 
			
		||||
 | 
			
		||||
void I2SAudioMediaPlayer::setup() {
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "Setting up Audio...");
 | 
			
		||||
#if SOC_I2S_SUPPORTS_DAC
 | 
			
		||||
  if (this->internal_dac_mode_ != I2S_DAC_CHANNEL_DISABLE) {
 | 
			
		||||
    this->audio_ = make_unique<Audio>(true, this->internal_dac_mode_);
 | 
			
		||||
  } else {
 | 
			
		||||
#endif
 | 
			
		||||
    this->audio_ = make_unique<Audio>(false);
 | 
			
		||||
    this->audio_->setPinout(this->bclk_pin_, this->lrclk_pin_, this->dout_pin_);
 | 
			
		||||
    this->audio_->forceMono(this->external_dac_channels_ == 1);
 | 
			
		||||
@@ -113,7 +115,9 @@ void I2SAudioMediaPlayer::setup() {
 | 
			
		||||
      this->mute_pin_->setup();
 | 
			
		||||
      this->mute_pin_->digital_write(false);
 | 
			
		||||
    }
 | 
			
		||||
#if SOC_I2S_SUPPORTS_DAC
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
  this->state = media_player::MEDIA_PLAYER_STATE_IDLE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -137,6 +141,7 @@ void I2SAudioMediaPlayer::dump_config() {
 | 
			
		||||
    ESP_LOGCONFIG(TAG, "Audio failed to initialize!");
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
#if SOC_I2S_SUPPORTS_DAC
 | 
			
		||||
  if (this->internal_dac_mode_ != I2S_DAC_CHANNEL_DISABLE) {
 | 
			
		||||
    switch (this->internal_dac_mode_) {
 | 
			
		||||
      case I2S_DAC_CHANNEL_LEFT_EN:
 | 
			
		||||
@@ -152,6 +157,7 @@ void I2SAudioMediaPlayer::dump_config() {
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace i2s_audio
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,9 @@ class I2SAudioMediaPlayer : public Component, public media_player::MediaPlayer {
 | 
			
		||||
  void set_bclk_pin(uint8_t pin) { this->bclk_pin_ = pin; }
 | 
			
		||||
  void set_lrclk_pin(uint8_t pin) { this->lrclk_pin_ = pin; }
 | 
			
		||||
  void set_mute_pin(GPIOPin *mute_pin) { this->mute_pin_ = mute_pin; }
 | 
			
		||||
#if SOC_I2S_SUPPORTS_DAC
 | 
			
		||||
  void set_internal_dac_mode(i2s_dac_mode_t mode) { this->internal_dac_mode_ = mode; }
 | 
			
		||||
#endif
 | 
			
		||||
  void set_external_dac_channels(uint8_t channels) { this->external_dac_channels_ = channels; }
 | 
			
		||||
 | 
			
		||||
  media_player::MediaPlayerTraits get_traits() override;
 | 
			
		||||
@@ -51,7 +53,9 @@ class I2SAudioMediaPlayer : public Component, public media_player::MediaPlayer {
 | 
			
		||||
  bool muted_{false};
 | 
			
		||||
  float unmuted_volume_{0};
 | 
			
		||||
 | 
			
		||||
#if SOC_I2S_SUPPORTS_DAC
 | 
			
		||||
  i2s_dac_mode_t internal_dac_mode_{I2S_DAC_CHANNEL_DISABLE};
 | 
			
		||||
#endif
 | 
			
		||||
  uint8_t external_dac_channels_;
 | 
			
		||||
 | 
			
		||||
  HighFrequencyLoopRequester high_freq_;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
import esphome.codegen as cg
 | 
			
		||||
from esphome.components import media_player
 | 
			
		||||
from esphome.components import media_player, esp32
 | 
			
		||||
import esphome.config_validation as cv
 | 
			
		||||
 | 
			
		||||
from esphome import pins
 | 
			
		||||
@@ -33,6 +33,18 @@ INTERNAL_DAC_OPTIONS = {
 | 
			
		||||
 | 
			
		||||
EXTERNAL_DAC_OPTIONS = ["mono", "stereo"]
 | 
			
		||||
 | 
			
		||||
NO_INTERNAL_DAC_VARIANTS = [esp32.const.VARIANT_ESP32S2]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def validate_esp32_variant(config):
 | 
			
		||||
    if config[CONF_DAC_TYPE] != "internal":
 | 
			
		||||
        return config
 | 
			
		||||
    variant = esp32.get_esp32_variant()
 | 
			
		||||
    if variant in NO_INTERNAL_DAC_VARIANTS:
 | 
			
		||||
        raise cv.Invalid(f"{variant} does not have an internal DAC")
 | 
			
		||||
    return config
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CONFIG_SCHEMA = cv.All(
 | 
			
		||||
    cv.typed_schema(
 | 
			
		||||
        {
 | 
			
		||||
@@ -68,6 +80,7 @@ CONFIG_SCHEMA = cv.All(
 | 
			
		||||
        key=CONF_DAC_TYPE,
 | 
			
		||||
    ),
 | 
			
		||||
    cv.only_with_arduino,
 | 
			
		||||
    validate_esp32_variant,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
"""Constants used by esphome."""
 | 
			
		||||
 | 
			
		||||
__version__ = "2022.12.0b4"
 | 
			
		||||
__version__ = "2022.12.7"
 | 
			
		||||
 | 
			
		||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -129,9 +129,9 @@ class GitFile:
 | 
			
		||||
    def raw_url(self) -> str:
 | 
			
		||||
        if self.ref is None:
 | 
			
		||||
            raise ValueError("URL has no ref")
 | 
			
		||||
        if self.domain == "github":
 | 
			
		||||
        if self.domain == "github.com":
 | 
			
		||||
            return f"https://raw.githubusercontent.com/{self.owner}/{self.repo}/{self.ref}/{self.filename}"
 | 
			
		||||
        if self.domain == "gitlab":
 | 
			
		||||
        if self.domain == "gitlab.com":
 | 
			
		||||
            return f"https://gitlab.com/{self.owner}/{self.repo}/-/raw/{self.ref}/{self.filename}"
 | 
			
		||||
        raise NotImplementedError(f"Git domain {self.domain} not supported")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user