I have a system with 5 separate ESPHomes connected with a DF player mini to play audio. Currently I have it working by having a separate ESPHome yaml file for each one, and I change the name of the device as well as all of the buttons I have defined, so that each of the instances have a unique entity name. The issue with this is that if I want to make a global change to the ESPHome coding, I have to recompile 5 times and upload them to each of the ESPHomes. Is there some way I can utilize the same binary file for each, and have some other way to uniquely identify each instance in Home Assistant?
esphome:
name: "mp3-player-1"
esp8266:
board: esp01_1m
# Enable logging
logger:
number:
- platform: template
name: MP3_1_track
max_value: 100
min_value: 1
step: 1
mode: box
optimistic: true
on_value:
then:
dfplayer.play: !lambda 'return x;'
- platform: template
name: MP3_1_volume
id: MP3_1_volume
max_value: 30
min_value: 1
step: 1
mode: slider
optimistic: true
on_value:
then:
dfplayer.set_volume: !lambda 'return x;'
button:
- platform: template
name: MP3_1_Pause
id: MP3_1_Pause
on_press:
- dfplayer.pause
- platform: template
name: MP3_1_Play
id: MP3_1_Play
on_press:
- dfplayer.start
- platform: template
name: MP3_1_VolUp
id: MP3_1_VolUp
on_press:
- dfplayer.volume_up
- platform: template
name: MP3_1_VolDown
id: MP3_1_VolDown
on_press:
- dfplayer.volume_down
# Enable Home Assistant API
api:
services:
- service: dfplayer_next
then:
- dfplayer.play_next:
- service: dfplayer_previous
then:
- dfplayer.play_previous:
- service: dfplayer_play
variables:
file: int
then:
- dfplayer.play: !lambda 'return id(MP3_1_volume).state;'
#- dfplayer.play: !lambda 'return file;'
- service: dfplayer_play_loop
variables:
file: int
loop_: bool
then:
- dfplayer.play:
file: !lambda 'return file;'
loop: !lambda 'return loop_;'
- service: dfplayer_play_folder
variables:
folder: int
file: int
then:
- dfplayer.play_folder:
folder: !lambda 'return folder;'
file: !lambda 'return file;'
- service: dfplayer_set_volume
variables:
volume: int
then:
- dfplayer.set_volume: !lambda 'return volume;'
- service: dfplayer_set_eq
variables:
preset: int
then:
- dfplayer.set_eq: !lambda 'return static_cast<dfplayer::EqPreset>(preset);'
- service: dfplayer_sleep
then:
- dfplayer.sleep
- service: dfplayer_reset
then:
- dfplayer.reset
- service: dfplayer_start
then:
- dfplayer.start
- service: dfplayer_pause
then:
- dfplayer.pause
- service: dfplayer_stop
then:
- dfplayer.stop
- service: dfplayer_volume_up
then:
- dfplayer.volume_up
- service: dfplayer_volume_down
then:
- dfplayer.volume_down
uart:
tx_pin: GPIO2
rx_pin: GPIO4
baud_rate: 9600
# Declare DFPlayer mini module
dfplayer:
on_finished_playback:
then:
logger.log: 'Somebody press play!'
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-129835"
password: "H05KGbeGEsm8"
captive_portal: