diff --git a/.github/workflows/validate_esphome.yml b/.github/workflows/validate_esphome.yml index 5f11d17..4c2c12e 100644 --- a/.github/workflows/validate_esphome.yml +++ b/.github/workflows/validate_esphome.yml @@ -191,48 +191,91 @@ jobs: with: yaml_file: "./.test/esphome_advanced_climate_heat_customizations.yaml" - # build_prebuilt_firmware: - # name: Prebuilt Firmware - # runs-on: ubuntu-latest - # needs: build_core # Ensure this job runs after the core build job - # if: github.ref == 'refs/heads/dev' || github.base_ref == 'dev' - # steps: - # - uses: actions/checkout@main - # with: - # fetch-depth: '0' + build_prebuilt_firmware: + name: Prebuilt Firmware + runs-on: ubuntu-latest + needs: build_core # Ensure this job runs after the core build job + if: github.ref == 'refs/heads/dev' || github.base_ref == 'dev' + steps: + - uses: actions/checkout@main + with: + fetch-depth: '0' - # - name: Build ESPHome Prebuilt Firmware - # uses: barndawgie/build-action@v1.9.0 - # with: - # yaml_file: prebuilt/nspanel_esphome_prebuilt.yaml + - name: Build ESPHome Prebuilt Firmware + uses: barndawgie/build-action@v1.9.0 + with: + yaml_file: prebuilt/nspanel_esphome_prebuilt.yaml - # - name: Move and Rename Firmware File - # run: | - # mkdir -p prebuilt - # cp prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware.bin prebuilt/nspanel_esphome_prebuilt.bin || true - # cp prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware-factory.bin prebuilt/nspanel_esphome_prebuilt-factory.bin || true + - name: Move and Rename Firmware File + run: | + mkdir -p prebuilt + cp prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware.bin prebuilt/nspanel_esphome_prebuilt.bin || true + cp prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware-factory.bin prebuilt/nspanel_esphome_prebuilt-factory.bin || true - # - name: Set Commit Message - # id: set_commit_message - # run: | - # if [[ "${{ github.event_name }}" == "pull_request" ]]; then - # echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel - ${{ github.event.pull_request.title }}" >> $GITHUB_ENV - # elif [[ "${{ github.event_name }}" == "push" ]]; then - # commit_message=$(git log -1 --pretty=format:'%s') - # echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel - $commit_message" >> $GITHUB_ENV - # else - # echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel" >> $GITHUB_ENV - # fi + - name: Set Commit Message + id: set_commit_message + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel - ${{ github.event.pull_request.title }}" >> $GITHUB_ENV + elif [[ "${{ github.event_name }}" == "push" ]]; then + commit_message=$(git log -1 --pretty=format:'%s') + echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel - $commit_message" >> $GITHUB_ENV + else + echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel" >> $GITHUB_ENV + fi - # - name: Commit and Push Firmware Files - # run: | - # git config --global user.name 'GitHub Actions' - # git config --global user.email 'actions@github.com' - # git add prebuilt/*.bin - # git commit -m "${{ env.COMMIT_MESSAGE }}" - # git push - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Commit and Push Firmware Files + run: | + git config --global user.name 'GitHub Actions' + git config --global user.email 'actions@github.com' + git add prebuilt/*.bin + git commit -m "${{ env.COMMIT_MESSAGE }}" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build_wall_display_firmware: + name: Prebuilt Wall Display Firmware + runs-on: ubuntu-latest + needs: build_core # Ensure this job runs after the core build job + if: github.ref == 'refs/heads/dev' || github.base_ref == 'dev' + steps: + - uses: actions/checkout@main + with: + fetch-depth: '0' + + - name: Build ESPHome Prebuilt Wall Display Firmware + uses: barndawgie/build-action@v1.9.0 + with: + yaml_file: prebuilt/Wall_Display.yaml + + - name: Move and Rename Firmware File + run: | + mkdir -p prebuilt + cp prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware.bin prebuilt/wall_display.bin || true + cp prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware-factory.bin prebuilt/wall_display-factory.bin || true + + - name: Set Commit Message + id: set_commit_message + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel - ${{ github.event.pull_request.title }}" >> $GITHUB_ENV + elif [[ "${{ github.event_name }}" == "push" ]]; then + commit_message=$(git log -1 --pretty=format:'%s') + echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel - $commit_message" >> $GITHUB_ENV + else + echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel" >> $GITHUB_ENV + fi + + - name: Commit and Push Firmware Files + run: | + git config --global user.name 'GitHub Actions' + git config --global user.email 'actions@github.com' + git add prebuilt/*.bin + git commit -m "${{ env.COMMIT_MESSAGE }}" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build_climate_cool_bluetooth_proxy: name: Climate cool & BLE proxy diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index 8515e59..282b9b6 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -1712,7 +1712,20 @@ text_sensor: entity_category: diagnostic internal: false disabled_by_default: false - lambda: return {"${name}"}; + lambda: |- + #ifdef NSPANEL_HA_BLUEPRINT_PREBUILT + std::string suffix; + uint8_t mac[6] = {0,0,0,0,0,0}; + esp_read_mac(mac, ESP_MAC_WIFI_STA); + for (int i = 3; i < 6; ++i) { + char hex[3]; + snprintf(hex, sizeof(hex), "%02X", mac[i]); + suffix += hex; + } + return {"${name}" + "-" + suffix}; + #else + return {"${name}"}; + #endif filters: - lambda: |- std::string result; diff --git a/esphome/nspanel_esphome_prebuilt.bin b/esphome/nspanel_esphome_prebuilt.bin new file mode 100644 index 0000000..817b146 Binary files /dev/null and b/esphome/nspanel_esphome_prebuilt.bin differ diff --git a/esphome/nspanel_esphome_prebuilt.bin.md5 b/esphome/nspanel_esphome_prebuilt.bin.md5 new file mode 100644 index 0000000..14eee82 --- /dev/null +++ b/esphome/nspanel_esphome_prebuilt.bin.md5 @@ -0,0 +1 @@ +f53721201290b27c41030a476ce3653e prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware.bin diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 194a09a..278fc56 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -36,6 +36,8 @@ blueprint: filter: - integration: esphome model: esp32dev + - integration: esphome + model: Wall_Display multiple: false ##### SYSTEM SETTINGS ##### diff --git a/prebuilt/Wall_Display.yaml b/prebuilt/Wall_Display.yaml new file mode 100644 index 0000000..c60166f --- /dev/null +++ b/prebuilt/Wall_Display.yaml @@ -0,0 +1,39 @@ +######################## +##### EXPERIMENTAL ##### +######################## + +##################################################################################################### +##### NSPANEL ESPHOME created by Blackymas - https://github.com/Blackymas/NSPanel_HA_Blueprint ##### +##### ESPHOME PRE-BUILT - Wall_Display variation by https://github.com/MichaelHeimann ##### +##### PLEASE only make changes if it is necessary and also the required knowledge is available. ##### +##### For normal use with the Blueprint, no changes are necessary. ##### +##################################################################################################### +substitutions: + heater_relay: "1" # Possible values: 1/2 + temp_units: "°C" # Temperatures in Fahrenheit + temp_min: "16" # Min supported temperature is 40°F + temp_max: "26" # Max supported temperature is 80°F + temp_step: "0.5" # Temperature granularity is 1°F + +packages: + climate_heat: !include ../esphome/nspanel_esphome_addon_climate_heat.yaml + prebuilt_package: !include nspanel_esphome_prebuilt.yaml + +dashboard_import: + package_import_url: github://Blackymas/NSPanel_HA_Blueprint/prebuilt/Wall_Display.yaml@main + import_full_config: false + +esphome: + project: + name: esphome.Wall_Display + platformio_options: + build_flags: + - -D NSPANEL_HA_BLUEPRINT_PREBUILT_WALL_DISPLAY + on_boot: + - priority: 602.0 + then: + - text.set: + id: fw_url + value: "https://raw.githubusercontent.com/Blackymas/NSPanel_HA_Blueprint/main/prebuilt/wall_display.bin" + +... diff --git a/prebuilt/firmware.bin b/prebuilt/firmware.bin new file mode 100644 index 0000000..0403897 Binary files /dev/null and b/prebuilt/firmware.bin differ diff --git a/prebuilt/nspanel_esphome_prebuilt.bin b/prebuilt/nspanel_esphome_prebuilt.bin new file mode 100644 index 0000000..121a78b Binary files /dev/null and b/prebuilt/nspanel_esphome_prebuilt.bin differ diff --git a/prebuilt/nspanel_esphome_prebuilt.bin.md5 b/prebuilt/nspanel_esphome_prebuilt.bin.md5 new file mode 100644 index 0000000..be22a20 --- /dev/null +++ b/prebuilt/nspanel_esphome_prebuilt.bin.md5 @@ -0,0 +1 @@ +01e3ae4e26f613b4f62240edaf51641a prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware.bin diff --git a/prebuilt/nspanel_esphome_prebuilt.yaml b/prebuilt/nspanel_esphome_prebuilt.yaml index ed26787..783de1b 100644 --- a/prebuilt/nspanel_esphome_prebuilt.yaml +++ b/prebuilt/nspanel_esphome_prebuilt.yaml @@ -8,7 +8,6 @@ ##### PLEASE only make changes if it is necessary and also the required knowledge is available. ##### ##### For normal use with the Blueprint, no changes are necessary. ##### ##################################################################################################### ---- substitutions: device_name: nspanel wifi_ssid: nspanel @@ -38,8 +37,8 @@ api: url: string then: - ota_http.flash: - url: !lambda return url.c_str(); - verify_ssl: false + md5_url: !lambda return id(fw_url).state + ".md5"; + url: !lambda return id(fw_url).state; - lambda: |- static const char *const TAG = "prebuilt.button.bt_firmware_update"; ESP_LOGE(TAG, "Firmware update failed!"); @@ -56,8 +55,8 @@ button: on_press: then: - ota_http.flash: - url: !lambda return id(firmware_url).state; - verify_ssl: false + md5_url: !lambda return id(fw_url).state + ".md5"; + url: !lambda return id(fw_url).state; - lambda: |- static const char *const TAG = "prebuilt.button.bt_firmware_update"; ESP_LOGE(TAG, "Firmware update failed!"); @@ -65,7 +64,7 @@ button: captive_portal: dashboard_import: - package_import_url: github://Blackymas/NSPanel_HA_Blueprint/prebuilt/nspanel_esphome_prebuilt.yaml@dev # Must be updated + package_import_url: github://Blackymas/NSPanel_HA_Blueprint/prebuilt/nspanel_esphome_prebuilt.yaml@main # Must be updated import_full_config: false esp32_improv: @@ -79,9 +78,9 @@ esphome: on_boot: - priority: 602.0 then: - - text_sensor.template.publish: - id: firmware_url - state: https://raw.githubusercontent.com/Blackymas/NSPanel_HA_Blueprint/dev/prebuilt/nspanel_esphome_prebuilt.bin # Must be updated + - text.set: + id: fw_url + value: "https://raw.githubusercontent.com/Blackymas/NSPanel_HA_Blueprint/main/prebuilt/nspanel_esphome_prebuilt.bin" improv_serial: @@ -107,16 +106,16 @@ select: - "NSPanel US (CJK languages)" - "NSPanel US Landscape (CJK languages)" -text_sensor: - - id: firmware_url - name: Firmware update - URL - platform: template - update_interval: 60s - internal: true +text: + - platform: template + name: Firmware URL + id: fw_url icon: mdi:cloud-download + mode: text + optimistic: true + # internal: true wifi: networks: !remove ap: {} power_save_mode: LIGHT # To make it compatible with BLE -...