Skip to content

Commit

Permalink
Flash script (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored Sep 19, 2020
1 parent 38b06a9 commit 423476f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions scripts/flash
Original file line number Diff line number Diff line change
@@ -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}"
8 changes: 4 additions & 4 deletions tagreader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ captive_portal:

substitutions:
devicename: tagreader
upper_devicename: TagReader
friendly_name: TagReader

esphome:
name: $devicename
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 423476f

Please sign in to comment.