I am trying to make sure I understand something from the packages documentation. It appears to be taking the values in a cascading manner. Like, the yaml you are configuring would take the most importance and it just goes down the list from there. My questions would be best describe with examples.
outdoor-kitchen-shelly-1.yaml
substitutions:
device_name: outdoor-kitchen-shelly-1
friendly_name: Outside Kitchen Light
esphome:
name: $device_name
platform: ESP8266
board: esp01_1m
packages:
common: !include common/.common.yaml
# Device Specific Config
output:
- platform: gpio
pin: GPIO4
id: shelly_1_relay
light:
- platform: binary
name: $friendly_name
output: shelly_1_relay
id: outsidekitchenlight
binary_sensor:
- platform: gpio
pin:
number: GPIO5
#mode: INPUT_PULLUP
#inverted: True
name: "Outside Rear Garage Switch"
on_state:
then:
- light.toggle: outsidekitchenlight
internal: true
id: switchid
./common/.common.yaml
wifi:
# https://esphome.io/components/wifi
ssid: !secret ssid1
password: !secret ssid1_pass
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${friendly_name}"
password: !secret wifi_ap_password
captive_portal:
# Enable logging
logger:
# https://esphome.io/components/logger
# Enable Home Assistant API
api:
# https://esphome.io/components/api
encryption:
key: !secret api_password
ota:
# https://esphome.io/components/ota
- platform: esphome
password: !secret ota_password
# Enable Web server.
web_server:
port: 80
auth:
username: !secret web_username
password: !secret web_password
# Get the time from Home Assistant to sync the onboard real-time-clock.
time:
- platform: homeassistant
id: ha_time
So, I pull in the common configuration into the individual configs. But, for esp8266 devices, I need wifi to have power_save_mode: HIGH
because of this issue. To my understanding, I can change the outdoor-kitchen-shelly-1.yaml to the following:
substitutions:
device_name: outdoor-kitchen-shelly-1
friendly_name: Outside Kitchen Light
esphome:
name: $device_name
platform: ESP8266
board: esp01_1m
packages:
common: !include common/.common.yaml
wifi:
power_save_mode: HIGH
# Device Specific Config
output:
- platform: gpio
pin: GPIO4
id: shelly_1_relay
light:
- platform: binary
name: $friendly_name
output: shelly_1_relay
id: outsidekitchenlight
binary_sensor:
- platform: gpio
pin:
number: GPIO5
#mode: INPUT_PULLUP
#inverted: True
name: "Outside Rear Garage Switch"
on_state:
then:
- light.toggle: outsidekitchenlight
internal: true
id: switchid
I believe that it would only override that value and not the ssid, password, and ap sections of wifi under the common section. Is that correct? Or would having wifi in the main configuration disable the entire wifi section from .common.yaml?
The next part is that I would possibly like to make it even more simple later. Make a ./common/.shelly1.yaml
that would handle most of the configuration for all shelly devices. If I did that and I had the following, and both had the same value for something. Does the first one listed override the second one. Or is it the other way around?
packages:
common: !include common/.common.yaml
shelly: !include common/.shelly1.yaml
One final question, Can you have packages in your packages? Can the .shelly1.yaml have a package that pulls in .common.yaml?