diff --git a/esphome/config_validation.py b/esphome/config_validation.py index 3aebca81b8..61ef7d2f9f 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -1457,7 +1457,11 @@ class OnlyWith(Optional): if self._component in CORE.raw_config or ( CONF_PACKAGES in CORE.raw_config and self._component - in {list(x.keys())[0] for x in CORE.raw_config[CONF_PACKAGES].values()} + in [ + k + for package in CORE.raw_config[CONF_PACKAGES].values() + for k in package.keys() + ] ): return self._default return vol.UNDEFINED