From 356708c96a6de382c1a6ffd552c37f532cb72a13 Mon Sep 17 00:00:00 2001 From: Nikita Pedorich Date: Fri, 27 Dec 2024 22:37:20 +0900 Subject: [PATCH] Move esphome device to a separate repo --- firmware/.base.yaml | 71 ------------------------------------- firmware/.led_sensor.yaml | 14 -------- firmware/README.md | 6 ++-- firmware/humidifier_s2.yaml | 1 + flake.nix | 19 +++------- justfile | 27 -------------- 6 files changed, 8 insertions(+), 130 deletions(-) delete mode 100644 firmware/.base.yaml delete mode 100644 firmware/.led_sensor.yaml delete mode 100644 justfile diff --git a/firmware/.base.yaml b/firmware/.base.yaml deleted file mode 100644 index d8634df..0000000 --- a/firmware/.base.yaml +++ /dev/null @@ -1,71 +0,0 @@ -substitutions: - git_rev: undefined - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - fast_connect: true - power_save_mode: none - use_address: humidifier-s2.lan - - # ap: - # ssid: ${friendly_name} Fallback AP - # password: !secret wifi_ap_password - -# captive_portal: - -# AP and/or Captive portal causes random reboots on this board :( -# See: https://github.com/esphome/issues/issues/1679 -# https://community.home-assistant.io/t/cant-stop-esphome-restarting-with-weak-wifi/453821/21 - -ota: - platform: esphome - port: 3232 - password: !secret ota_password - -safe_mode: - disabled: false - -debug: - update_interval: 5s - -button: - - platform: safe_mode - name: "Restart in Safe Mode" - icon: "mdi:restart-alert" - - - platform: restart - name: "Restart" - icon: "mdi:restart" - -sensor: - - platform: debug - loop_time: - name: "Loop Time" - - - platform: uptime - update_interval: 60s - name: Uptime Sensor - - - platform: wifi_signal - name: "WiFi Signal" - update_interval: 10s - - - platform: internal_temperature - name: "Internal Temperature" - -text_sensor: - - platform: debug - reset_reason: - name: "Reset Reason" - - - platform: version - name: "ESPHome Version" - hide_timestamp: true - - - platform: template - name: "Git Rev" - icon: "mdi:source-repository" - entity_category: "diagnostic" - lambda: |- - return {"${git_rev}"}; diff --git a/firmware/.led_sensor.yaml b/firmware/.led_sensor.yaml deleted file mode 100644 index f8c50ba..0000000 --- a/firmware/.led_sensor.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# Expected ${led} to substitute for LED number -# Expected ${pin} to substitute for the gpio pin -# Expected ${update_interval} to substitute for the update_interval -sensor: - - platform: duty_cycle - name: "LED${led}" - id: led_${led}_sensor - update_interval: ${update_interval} - internal: true - pin: - number: ${pin} - mode: - input: true - pulldown: true diff --git a/firmware/README.md b/firmware/README.md index 4df1705..d6e7886 100644 --- a/firmware/README.md +++ b/firmware/README.md @@ -10,6 +10,6 @@
-> [!IMPORTANT] -> Enabling fallback AP and/or Captive Portal causes ESPHome stability issues. -> See: https://community.home-assistant.io/t/cant-stop-esphome-restarting-with-weak-wifi/453821/21 +## Device configuration + +See example use at https://github.com/pedorich-n/esphome-devices/tree/main/devices/sharp-hv-r75 \ No newline at end of file diff --git a/firmware/humidifier_s2.yaml b/firmware/humidifier_s2.yaml index 661dcab..4907ae0 100644 --- a/firmware/humidifier_s2.yaml +++ b/firmware/humidifier_s2.yaml @@ -39,6 +39,7 @@ mqtt: password: !secret mqtt_password discovery: true topic_prefix: humidifier + discovery_unique_id_generator: mac logger: level: INFO diff --git a/flake.nix b/flake.nix index 145b944..3f7d2c3 100644 --- a/flake.nix +++ b/flake.nix @@ -35,11 +35,9 @@ export INSIDE_NIX_DEVELOP=true export ESPHOME_NOGITIGNORE=true - ${lib.getExe pkgs.python3} --version - ${lib.getExe pkgs.platformio-core} --version - echo "ESPHome $(${lib.getExe pkgs.esphome} version)" - - eval "$(register-python-argcomplete esphome)" + python --version + platformio --version + echo "ESPHome $(esphome version)" ''; }; }; @@ -49,16 +47,6 @@ flakeCheck = true; settings.formatter = { - just = { - command = pkgs.just; - options = [ - "--fmt" - "--unstable" - "--justfile" - ]; - includes = [ "justfile" ]; - }; - black.options = [ "--line-length=120" ]; }; @@ -78,6 +66,7 @@ # YAML, etc prettier.enable = true; + just.enable = true; }; }; }; diff --git a/justfile b/justfile deleted file mode 100644 index 579ee63..0000000 --- a/justfile +++ /dev/null @@ -1,27 +0,0 @@ -firmware_file := 'firmware/humidifier_s2.yaml' -esphome_command_in_nix := replace('esphome %CMD% %FILE%', '%FILE%', firmware_file) -esphome_command_with_dev := replace('nix develop -c bash -c "%DEV_CMD%"', '%DEV_CMD%', esphome_command_in_nix) -esphome_command := if env_var_or_default('INSIDE_NIX_DEVELOP', 'false') == 'true' { esphome_command_in_nix } else { esphome_command_with_dev } -git_rev := `git describe --tags --always --dirty` -git_rev_substitution := replace('--substitution "git_rev" "%GIT_REV%"', '%GIT_REV%', git_rev) - -dev: - nix develop - -config: - {{ replace(esphome_command, '%CMD%', git_rev_substitution + ' config') }} - -compile: - {{ replace(esphome_command, '%CMD%', git_rev_substitution + ' compile') }} - -run: - {{ replace(esphome_command, '%CMD%', git_rev_substitution + ' run') }} - -clean: - {{ replace(esphome_command, '%CMD%', 'clean') }} - -clean-mqtt: - {{ replace(esphome_command, '%CMD%', 'clean-mqtt') }} - -logs: - {{ replace(esphome_command, '%CMD%', 'logs') }}