hey everyone i’m trying to make a component with a list of attributes obtained from the config.yaml file . what i have now is:
my_component:
username: my_username
password: !secret a_password
my component has the following code in it to retrieve the attributes from the config file. I’m not actually sure how it works, but it works.
from homeassistant.const import (CONF_PASSWORD, CONF_USERNAME)
DOMAIN = "my_component"
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
}),
}, extra=vol.ALLOW_EXTRA)
def setup(hass, config):
email = config[DOMAIN].get(CONF_USERNAME, "no username")
password = config[DOMAIN].get(CONF_PASSWORD, "no password")
what is want to do is this is to have something like the following in my config file and somehow retrieve all the attributes in my component:
#config.yaml
my_component:
usernames:
- my_username
- my_username2
passwords:
- !secret password1
- !secret password2
the config yaml doesn’t have to work exactly like this, perhaps getting the passwords from a list in the secrets.yaml could work or maybe somehow a list that has both the username and the password for each entry. what i’m just trying to do is get multiple usernames and corresponding passwords and load them into the component.