From 423476f8ff6616b65205985b35f7e4c161b62a2f Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Sun, 20 Sep 2020 09:05:31 +1200 Subject: [PATCH] Flash script (#20) --- .gitignore | 10 ++++++++++ scripts/flash | 19 +++++++++++++++++++ tagreader.yaml | 8 ++++---- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100755 scripts/flash diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0bbf89c --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Gitignore settings for ESPHome +# This is an example and may include too much for your use-case. +# You can modify this file to suit your needs. +/.esphome/ +**/.pioenvs/ +**/.piolibdeps/ +**/lib/ +**/src/ +**/platformio.ini +/secrets.yaml diff --git a/scripts/flash b/scripts/flash new file mode 100755 index 0000000..3227251 --- /dev/null +++ b/scripts/flash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -e + +echo "Getting mac address from device..." +mac=$(esptool.py read_mac | grep -m 1 'MAC:' | grep -o '.\{8\}$' ) +mac=${mac//:/} + +echo "MAC ending: ${mac}" + +devicename="tagreader_${mac}" +friendly_name="TagReader ${mac}" + +esphome --substitution devicename "${devicename}" --substitution friendly_name "${friendly_name}" tagreader.yaml compile +esphome --substitution devicename "${devicename}" --substitution friendly_name "${friendly_name}" tagreader.yaml upload + +rm -rf tagreader_${mac} + +echo "Done tagreader_${mac}" diff --git a/tagreader.yaml b/tagreader.yaml index 193a0b0..e303d50 100644 --- a/tagreader.yaml +++ b/tagreader.yaml @@ -11,7 +11,7 @@ captive_portal: substitutions: devicename: tagreader - upper_devicename: TagReader + friendly_name: TagReader esphome: name: $devicename @@ -30,12 +30,12 @@ esphome: # Define switches to control LED and buzzer from HA switch: - platform: template - name: "${upper_devicename} Buzzer Enabled" + name: "${friendly_name} Buzzer Enabled" id: buzzer_enabled icon: mdi:volume-high optimistic: true - platform: template - name: "${upper_devicename} LED enabled" + name: "${friendly_name} LED enabled" id: led_enabled icon: mdi:alarm-light-outline optimistic: true @@ -120,5 +120,5 @@ light: num_leds: 1 rgb_order: GRB id: activity_led - name: "${upper_devicename} LED" + name: "${friendly_name} LED" restore_mode: ALWAYS_OFF