From 7ac4faf60d11c50fad76bac981ef172b9b6a009f Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Wed, 5 Jun 2024 20:48:37 +0200 Subject: [PATCH] Fix CI (#159) --- .github/workflows/ci.yaml | 76 +++++++++++++++++++--------- .yamllint | 8 --- bluesmart-charger-esp32-example.yaml | 8 +-- components/victron/sensor.py | 2 +- 4 files changed, 56 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e4eb69d..c1ab874 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,17 +21,23 @@ jobs: lint-clang-format: env: esphome_directory: esphome - esphome_version: 2022.9.3 runs-on: ubuntu-latest - # cpp lint job runs with esphome-lint docker image so that clang-format-* - # doesn't have to be installed - container: esphome/esphome-lint:latest steps: - uses: actions/checkout@v2 - # Set up the pio project so that the cpp checks know how files are compiled - # (build flags, libraries etc) + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.12' + - name: Cache pip modules + uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: esphome-pip-3.12-${{ hashFiles('setup.py') }} + restore-keys: | + esphome-pip-3.12- + - name: 💣 Clone esphome project - run: git clone -b ${{ env.esphome_version }} https://github.com/esphome/esphome.git + run: git clone https://github.com/esphome/esphome.git - name: 💣 Copy component into the esphome project run: | cp -r ../components/* esphome/components/ @@ -41,6 +47,14 @@ jobs: git commit -a -m "Add external component" working-directory: ${{ env.esphome_directory }} + - name: Add missing requirements + run: pip3 install setuptools wheel + - name: Set up python environment + run: VIRTUAL_ENV=false script/setup + working-directory: ${{ env.esphome_directory }} + + # Set up the pio project so that the cpp checks know how files are compiled + # (build flags, libraries etc) - name: Set up platformio environment run: pio init --ide vscode working-directory: ${{ env.esphome_directory }} @@ -56,17 +70,24 @@ jobs: lint-clang-tidy: env: esphome_directory: esphome - esphome_version: 2022.9.3 runs-on: ubuntu-latest - # cpp lint job runs with esphome-lint docker image so that clang-format-* - # doesn't have to be installed - container: esphome/esphome-lint:latest steps: - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.12' + - name: Cache pip modules + uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: esphome-pip-3.12-${{ hashFiles('setup.py') }} + restore-keys: | + esphome-pip-3.12- - - name: 💣 Clone esphome project - run: git clone -b ${{ env.esphome_version }} https://github.com/esphome/esphome.git - - name: 💣 Copy component into the esphome project + - name: 💣Clone esphome project + run: git clone https://github.com/esphome/esphome.git + - name: 💣Copy component into the esphome project run: | cp -r ../components/* esphome/components/ git config user.name "ci" @@ -75,6 +96,12 @@ jobs: git commit -a -m "Add external component" working-directory: ${{ env.esphome_directory }} + - name: Add missing requirements + run: pip3 install setuptools wheel + - name: Set up python environment + run: VIRTUAL_ENV=false script/setup + working-directory: ${{ env.esphome_directory }} + # Set up the pio project so that the cpp checks know how files are compiled # (build flags, libraries etc) - name: Set up platformio environment @@ -95,7 +122,6 @@ jobs: lint-python: env: esphome_directory: esphome - esphome_version: 2022.9.3 # Don't use the esphome-lint docker image because it may contain outdated requirements. # This way, all dependencies are cached via the cache action. runs-on: ubuntu-latest @@ -104,17 +130,17 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.9' + python-version: '3.12' - name: Cache pip modules uses: actions/cache@v1 with: path: ~/.cache/pip - key: esphome-pip-3.9-${{ hashFiles('setup.py') }} + key: esphome-pip-3.12-${{ hashFiles('setup.py') }} restore-keys: | - esphome-pip-3.9- + esphome-pip-3.12- - name: 💣Clone esphome project - run: git clone -b ${{ env.esphome_version }} https://github.com/esphome/esphome.git + run: git clone https://github.com/esphome/esphome.git - name: 💣Copy component into the esphome project run: | cp -r ../components/* esphome/components/ @@ -148,10 +174,10 @@ jobs: steps: - name: ⤵️ Check out configuration from GitHub uses: actions/checkout@v2 - - name: Setup Python 3.9 + - name: Setup Python 3.12 uses: actions/setup-python@v1 with: - python-version: 3.9 + python-version: 3.12 - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel @@ -161,6 +187,8 @@ jobs: - name: Write secrets.yaml shell: bash run: 'echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password" > secrets.yaml; cp secrets.yaml tests' + - run: | + esphome -s external_components_source components config bluesmart-charger-esp32-example.yaml - run: | esphome -s external_components_source components config smartsolar-mppt-esp8266-example.yaml - run: | @@ -204,10 +232,10 @@ jobs: path: .pioenvs key: esphome-compile-pioenvs-${{ hashFiles('*.yaml') }} restore-keys: esphome-compile-pioenvs- - - name: Set up Python 3.9 + - name: Set up Python 3.12 uses: actions/setup-python@v1 with: - python-version: 3.9 + python-version: 3.12 - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel @@ -221,6 +249,8 @@ jobs: - name: Write secrets.yaml shell: bash run: 'echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password" > secrets.yaml' + - run: | + esphome -s external_components_source components compile bluesmart-charger-esp32-example.yaml - run: | esphome -s external_components_source components compile smartsolar-mppt-esp8266-example.yaml - run: | diff --git a/.yamllint b/.yamllint index b72570f..26ec59c 100644 --- a/.yamllint +++ b/.yamllint @@ -8,14 +8,6 @@ yaml-files: ignore: | /.cache/ esphome/**/*.pio* - config/automations.yaml - config/known_devices.yaml - config/scenes.yaml - config/google_calendars.yaml - config/custom_components/scheduler - config/custom_components/xiaomi_cloud_map_extractor - config/custom_components/zha_map - config/custom_components/hacs rules: braces: diff --git a/bluesmart-charger-esp32-example.yaml b/bluesmart-charger-esp32-example.yaml index 5e99f7d..a682b3c 100644 --- a/bluesmart-charger-esp32-example.yaml +++ b/bluesmart-charger-esp32-example.yaml @@ -1,4 +1,3 @@ - substitutions: name: bluesmart-charger external_components_source: github://KinDR007/VictronMPPT-ESPHOME@main @@ -25,7 +24,6 @@ ota: logger: baud_rate: 0 - mqtt: broker: !secret mqtt_host username: !secret mqtt_username @@ -34,8 +32,8 @@ mqtt: uart: id: uart_0 - tx_pin: D8 # Not connected! The communication is read-only - rx_pin: D7 # Connect this this GPIO and GND to the charger + tx_pin: GPIO16 # Not connected! The communication is read-only + rx_pin: GPIO17 # Connect this this GPIO and GND to the charger baud_rate: 19200 rx_buffer_size: 256 @@ -57,7 +55,6 @@ sensor: charging_mode_id: name: "${name} mode id" - text_sensor: - platform: victron victron_id: victron0 @@ -73,4 +70,3 @@ text_sensor: name: "${name} error" charging_mode: name: "${name} Charging mode" - diff --git a/components/victron/sensor.py b/components/victron/sensor.py index edb36a0..f08bcf0 100644 --- a/components/victron/sensor.py +++ b/components/victron/sensor.py @@ -5,8 +5,8 @@ from esphome.const import ( CONF_BATTERY_VOLTAGE, DEVICE_CLASS_CURRENT, DEVICE_CLASS_EMPTY, - DEVICE_CLASS_POWER, DEVICE_CLASS_ENERGY, + DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_VOLTAGE, ICON_CURRENT_AC,