Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
SimpliSafeFlowHandler.async_get_options_flow
(config_entry)
Define the config flow to handle options.
Define the config flow to handle options.
def async_get_options_flow(config_entry): """Define the config flow to handle options.""" return SimpliSafeOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "SimpliSafeOptionsFlowHandler", "(", "config_entry", ")" ]
[ 41, 4 ]
[ 43, 57 ]
python
en
['en', 'en', 'en']
True
SimpliSafeFlowHandler._async_get_simplisafe_api
(self)
Get an authenticated SimpliSafe API client.
Get an authenticated SimpliSafe API client.
async def _async_get_simplisafe_api(self): """Get an authenticated SimpliSafe API client.""" client_id = await async_get_client_id(self.hass) websession = aiohttp_client.async_get_clientsession(self.hass) return await API.login_via_credentials( self._username, se...
[ "async", "def", "_async_get_simplisafe_api", "(", "self", ")", ":", "client_id", "=", "await", "async_get_client_id", "(", "self", ".", "hass", ")", "websession", "=", "aiohttp_client", ".", "async_get_clientsession", "(", "self", ".", "hass", ")", "return", "aw...
[ 45, 4 ]
[ 55, 9 ]
python
en
['en', 'su', 'en']
True
SimpliSafeFlowHandler._async_login_during_step
(self, *, step_id, form_schema)
Attempt to log into the API from within a config flow step.
Attempt to log into the API from within a config flow step.
async def _async_login_during_step(self, *, step_id, form_schema): """Attempt to log into the API from within a config flow step.""" errors = {} try: simplisafe = await self._async_get_simplisafe_api() except PendingAuthorizationError: LOGGER.info("Awaiting confi...
[ "async", "def", "_async_login_during_step", "(", "self", ",", "*", ",", "step_id", ",", "form_schema", ")", ":", "errors", "=", "{", "}", "try", ":", "simplisafe", "=", "await", "self", ".", "_async_get_simplisafe_api", "(", ")", "except", "PendingAuthorizatio...
[ 57, 4 ]
[ 85, 9 ]
python
en
['en', 'en', 'en']
True
SimpliSafeFlowHandler.async_step_finish
(self, user_input=None)
Handle finish config entry setup.
Handle finish config entry setup.
async def async_step_finish(self, user_input=None): """Handle finish config entry setup.""" existing_entry = await self.async_set_unique_id(self._username) if existing_entry: self.hass.config_entries.async_update_entry(existing_entry, data=user_input) return self.async_ab...
[ "async", "def", "async_step_finish", "(", "self", ",", "user_input", "=", "None", ")", ":", "existing_entry", "=", "await", "self", ".", "async_set_unique_id", "(", "self", ".", "_username", ")", "if", "existing_entry", ":", "self", ".", "hass", ".", "config...
[ 87, 4 ]
[ 93, 77 ]
python
en
['en', 'zu', 'en']
True
SimpliSafeFlowHandler.async_step_mfa
(self, user_input=None)
Handle multi-factor auth confirmation.
Handle multi-factor auth confirmation.
async def async_step_mfa(self, user_input=None): """Handle multi-factor auth confirmation.""" if user_input is None: return self.async_show_form(step_id="mfa") try: simplisafe = await self._async_get_simplisafe_api() except PendingAuthorizationError: ...
[ "async", "def", "async_step_mfa", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"mfa\"", ")", "try", ":", "simplisafe", "=", "await", "self", ...
[ 95, 4 ]
[ 114, 9 ]
python
en
['fr', 'en', 'en']
True
SimpliSafeFlowHandler.async_step_reauth
(self, config)
Handle configuration by re-auth.
Handle configuration by re-auth.
async def async_step_reauth(self, config): """Handle configuration by re-auth.""" self._code = config.get(CONF_CODE) self._username = config[CONF_USERNAME] return await self.async_step_reauth_confirm()
[ "async", "def", "async_step_reauth", "(", "self", ",", "config", ")", ":", "self", ".", "_code", "=", "config", ".", "get", "(", "CONF_CODE", ")", "self", ".", "_username", "=", "config", "[", "CONF_USERNAME", "]", "return", "await", "self", ".", "async_...
[ 116, 4 ]
[ 121, 53 ]
python
en
['en', 'en', 'en']
True
SimpliSafeFlowHandler.async_step_reauth_confirm
(self, user_input=None)
Handle re-auth completion.
Handle re-auth completion.
async def async_step_reauth_confirm(self, user_input=None): """Handle re-auth completion.""" if not user_input: return self.async_show_form( step_id="reauth_confirm", data_schema=self.password_data_schema ) self._password = user_input[CONF_PASSWORD] ...
[ "async", "def", "async_step_reauth_confirm", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "not", "user_input", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"reauth_confirm\"", ",", "data_schema", "=", "self", ".", "pass...
[ 123, 4 ]
[ 134, 9 ]
python
en
['en', 'en', 'en']
True
SimpliSafeFlowHandler.async_step_user
(self, user_input=None)
Handle the start of the config flow.
Handle the start of the config flow.
async def async_step_user(self, user_input=None): """Handle the start of the config flow.""" if not user_input: return self.async_show_form( step_id="user", data_schema=self.full_data_schema ) await self.async_set_unique_id(user_input[CONF_USERNAME]) ...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "not", "user_input", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"user\"", ",", "data_schema", "=", "self", ".", "full_data_schema", ")"...
[ 136, 4 ]
[ 152, 9 ]
python
en
['en', 'en', 'en']
True
SimpliSafeOptionsFlowHandler.__init__
(self, config_entry)
Initialize.
Initialize.
def __init__(self, config_entry): """Initialize.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 158, 4 ]
[ 160, 40 ]
python
en
['en', 'en', 'it']
False
SimpliSafeOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the options.
Manage the options.
async def async_step_init(self, user_input=None): """Manage the options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) return self.async_show_form( step_id="init", data_schema=vol.Schema( { ...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "return", ...
[ 162, 4 ]
[ 177, 9 ]
python
en
['en', 'en', 'en']
True
get_engine
(hass, config, discovery_info=None)
Set up Microsoft speech component.
Set up Microsoft speech component.
def get_engine(hass, config, discovery_info=None): """Set up Microsoft speech component.""" return MicrosoftProvider( config[CONF_API_KEY], config[CONF_LANG], config[CONF_GENDER], config[CONF_TYPE], config[CONF_RATE], config[CONF_VOLUME], config[CONF_PITCH...
[ "def", "get_engine", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "return", "MicrosoftProvider", "(", "config", "[", "CONF_API_KEY", "]", ",", "config", "[", "CONF_LANG", "]", ",", "config", "[", "CONF_GENDER", "]", ",", "confi...
[ 97, 0 ]
[ 109, 5 ]
python
en
['en', 'lb', 'en']
True
MicrosoftProvider.__init__
( self, apikey, lang, gender, ttype, rate, volume, pitch, contour, region )
Init Microsoft TTS service.
Init Microsoft TTS service.
def __init__( self, apikey, lang, gender, ttype, rate, volume, pitch, contour, region ): """Init Microsoft TTS service.""" self._apikey = apikey self._lang = lang self._gender = gender self._type = ttype self._output = DEFAULT_OUTPUT self._rate = f"{ra...
[ "def", "__init__", "(", "self", ",", "apikey", ",", "lang", ",", "gender", ",", "ttype", ",", "rate", ",", "volume", ",", "pitch", ",", "contour", ",", "region", ")", ":", "self", ".", "_apikey", "=", "apikey", "self", ".", "_lang", "=", "lang", "s...
[ 115, 4 ]
[ 129, 31 ]
python
en
['en', 'mt', 'en']
True
MicrosoftProvider.default_language
(self)
Return the default language.
Return the default language.
def default_language(self): """Return the default language.""" return self._lang
[ "def", "default_language", "(", "self", ")", ":", "return", "self", ".", "_lang" ]
[ 132, 4 ]
[ 134, 25 ]
python
en
['en', 'et', 'en']
True
MicrosoftProvider.supported_languages
(self)
Return list of supported languages.
Return list of supported languages.
def supported_languages(self): """Return list of supported languages.""" return SUPPORTED_LANGUAGES
[ "def", "supported_languages", "(", "self", ")", ":", "return", "SUPPORTED_LANGUAGES" ]
[ 137, 4 ]
[ 139, 34 ]
python
en
['en', 'en', 'en']
True
MicrosoftProvider.get_tts_audio
(self, message, language, options=None)
Load TTS from Microsoft.
Load TTS from Microsoft.
def get_tts_audio(self, message, language, options=None): """Load TTS from Microsoft.""" if language is None: language = self._lang try: trans = pycsspeechtts.TTSTranslator(self._apikey, self._region) data = trans.speak( language=language, ...
[ "def", "get_tts_audio", "(", "self", ",", "message", ",", "language", ",", "options", "=", "None", ")", ":", "if", "language", "is", "None", ":", "language", "=", "self", ".", "_lang", "try", ":", "trans", "=", "pycsspeechtts", ".", "TTSTranslator", "(",...
[ 141, 4 ]
[ 162, 28 ]
python
en
['en', 'en', 'en']
True
test_hit
(hass)
Test hitting the rate limit.
Test hitting the rate limit.
async def test_hit(hass): """Test hitting the rate limit.""" refresh_called = False @callback def _refresh(): nonlocal refresh_called refresh_called = True return rate_limiter = ratelimit.KeyedRateLimit(hass) rate_limiter.async_triggered("key1", dt_util.utcnow()) ...
[ "async", "def", "test_hit", "(", "hass", ")", ":", "refresh_called", "=", "False", "@", "callback", "def", "_refresh", "(", ")", ":", "nonlocal", "refresh_called", "refresh_called", "=", "True", "return", "rate_limiter", "=", "ratelimit", ".", "KeyedRateLimit", ...
[ 9, 0 ]
[ 43, 31 ]
python
en
['en', 'en', 'en']
True
test_miss
(hass)
Test missing the rate limit.
Test missing the rate limit.
async def test_miss(hass): """Test missing the rate limit.""" refresh_called = False @callback def _refresh(): nonlocal refresh_called refresh_called = True return rate_limiter = ratelimit.KeyedRateLimit(hass) assert ( rate_limiter.async_schedule_action( ...
[ "async", "def", "test_miss", "(", "hass", ")", ":", "refresh_called", "=", "False", "@", "callback", "def", "_refresh", "(", ")", ":", "nonlocal", "refresh_called", "refresh_called", "=", "True", "return", "rate_limiter", "=", "ratelimit", ".", "KeyedRateLimit",...
[ 46, 0 ]
[ 75, 31 ]
python
en
['en', 'en', 'en']
True
test_no_limit
(hass)
Test async_schedule_action always return None when there is no rate limit.
Test async_schedule_action always return None when there is no rate limit.
async def test_no_limit(hass): """Test async_schedule_action always return None when there is no rate limit.""" refresh_called = False @callback def _refresh(): nonlocal refresh_called refresh_called = True return rate_limiter = ratelimit.KeyedRateLimit(hass) rate_limi...
[ "async", "def", "test_no_limit", "(", "hass", ")", ":", "refresh_called", "=", "False", "@", "callback", "def", "_refresh", "(", ")", ":", "nonlocal", "refresh_called", "refresh_called", "=", "True", "return", "rate_limiter", "=", "ratelimit", ".", "KeyedRateLim...
[ 78, 0 ]
[ 107, 31 ]
python
en
['en', 'en', 'en']
True
get_args
()
get args from command line
get args from command line
def get_args(): """ get args from command line """ parser = argparse.ArgumentParser("fashion_mnist") parser.add_argument("--batch_size", type=int, default=128, help="batch size") parser.add_argument("--optimizer", type=str, default="SGD", help="optimizer") parser.add_argument("--epochs", type=in...
[ "def", "get_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "\"fashion_mnist\"", ")", "parser", ".", "add_argument", "(", "\"--batch_size\"", ",", "type", "=", "int", ",", "default", "=", "128", ",", "help", "=", "\"batch size\""...
[ 54, 0 ]
[ 70, 30 ]
python
en
['en', 'en', 'en']
True
build_graph_from_json
(ir_model_json)
build model from json representation
build model from json representation
def build_graph_from_json(ir_model_json): """build model from json representation """ graph = json_to_graph(ir_model_json) logging.debug(graph.operation_history) model = graph.produce_keras_model() return model
[ "def", "build_graph_from_json", "(", "ir_model_json", ")", ":", "graph", "=", "json_to_graph", "(", "ir_model_json", ")", "logging", ".", "debug", "(", "graph", ".", "operation_history", ")", "model", "=", "graph", ".", "produce_keras_model", "(", ")", "return",...
[ 80, 0 ]
[ 86, 16 ]
python
en
['en', 'en', 'en']
True
parse_rev_args
(receive_msg)
parse reveive msgs to global variable
parse reveive msgs to global variable
def parse_rev_args(receive_msg): """ parse reveive msgs to global variable """ global trainloader global testloader global net # Loading Data logger.debug("Preparing data..") (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data() y_train = to_categorical(y_train, 10) ...
[ "def", "parse_rev_args", "(", "receive_msg", ")", ":", "global", "trainloader", "global", "testloader", "global", "net", "# Loading Data", "logger", ".", "debug", "(", "\"Preparing data..\"", ")", "(", "x_train", ",", "y_train", ")", ",", "(", "x_test", ",", "...
[ 89, 0 ]
[ 139, 12 ]
python
en
['en', 'en', 'en']
True
train_eval
()
train and eval the model
train and eval the model
def train_eval(): """ train and eval the model """ global trainloader global testloader global net (x_train, y_train) = trainloader (x_test, y_test) = testloader # train procedure net.fit( x=x_train, y=y_train, batch_size=args.batch_size, validation...
[ "def", "train_eval", "(", ")", ":", "global", "trainloader", "global", "testloader", "global", "net", "(", "x_train", ",", "y_train", ")", "=", "trainloader", "(", "x_test", ",", "y_test", ")", "=", "testloader", "# train procedure", "net", ".", "fit", "(", ...
[ 162, 0 ]
[ 191, 32 ]
python
en
['en', 'en', 'en']
True
SendMetrics.on_epoch_end
(self, epoch, logs=None)
Run on end of each epoch
Run on end of each epoch
def on_epoch_end(self, epoch, logs=None): """ Run on end of each epoch """ if logs is None: logs = dict() logger.debug(logs) # TensorFlow 2.0 API reference claims the key is `val_acc`, but in fact it's `val_accuracy` if 'val_acc' in logs: n...
[ "def", "on_epoch_end", "(", "self", ",", "epoch", ",", "logs", "=", "None", ")", ":", "if", "logs", "is", "None", ":", "logs", "=", "dict", "(", ")", "logger", ".", "debug", "(", "logs", ")", "# TensorFlow 2.0 API reference claims the key is `val_acc`, but in ...
[ 147, 4 ]
[ 158, 64 ]
python
en
['en', 'error', 'th']
False
gen_matrix
(port_num: int, vessel_num: int)
A node that contains matrix in frame. Args: port_num (int): Number of ports. vessel_num (int): Number of vessels. Return: type: Matrix class definition.
A node that contains matrix in frame.
def gen_matrix(port_num: int, vessel_num: int): """A node that contains matrix in frame. Args: port_num (int): Number of ports. vessel_num (int): Number of vessels. Return: type: Matrix class definition. """ @node("matrices") class GeneralInfoMatrix(NodeBase): "...
[ "def", "gen_matrix", "(", "port_num", ":", "int", ",", "vessel_num", ":", "int", ")", ":", "@", "node", "(", "\"matrices\"", ")", "class", "GeneralInfoMatrix", "(", "NodeBase", ")", ":", "\"\"\"Used to save matrix, and provide matrix accessor.\"\"\"", "# distribution ...
[ 7, 0 ]
[ 41, 28 ]
python
en
['en', 'en', 'en']
True
test_state
(hass)
Test integration sensor state.
Test integration sensor state.
async def test_state(hass): """Test integration sensor state.""" config = { "sensor": { "platform": "integration", "name": "integration", "source": "sensor.power", "unit": ENERGY_KILO_WATT_HOUR, "round": 2, } } assert await asy...
[ "async", "def", "test_state", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"integration\"", ",", "\"name\"", ":", "\"integration\"", ",", "\"source\"", ":", "\"sensor.power\"", ",", "\"unit\"", ":", "ENERGY_KILO_WATT_...
[ 10, 0 ]
[ 39, 79 ]
python
en
['en', 'da', 'en']
True
test_trapezoidal
(hass)
Test integration sensor state.
Test integration sensor state.
async def test_trapezoidal(hass): """Test integration sensor state.""" config = { "sensor": { "platform": "integration", "name": "integration", "source": "sensor.power", "unit": ENERGY_KILO_WATT_HOUR, "round": 2, } } assert awa...
[ "async", "def", "test_trapezoidal", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"integration\"", ",", "\"name\"", ":", "\"integration\"", ",", "\"source\"", ":", "\"sensor.power\"", ",", "\"unit\"", ":", "ENERGY_KILO...
[ 42, 0 ]
[ 72, 79 ]
python
en
['en', 'da', 'en']
True
test_left
(hass)
Test integration sensor state with left reimann method.
Test integration sensor state with left reimann method.
async def test_left(hass): """Test integration sensor state with left reimann method.""" config = { "sensor": { "platform": "integration", "name": "integration", "method": "left", "source": "sensor.power", "unit": ENERGY_KILO_WATT_HOUR, ...
[ "async", "def", "test_left", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"integration\"", ",", "\"name\"", ":", "\"integration\"", ",", "\"method\"", ":", "\"left\"", ",", "\"source\"", ":", "\"sensor.power\"", ","...
[ 75, 0 ]
[ 106, 79 ]
python
en
['en', 'da', 'en']
True
test_right
(hass)
Test integration sensor state with left reimann method.
Test integration sensor state with left reimann method.
async def test_right(hass): """Test integration sensor state with left reimann method.""" config = { "sensor": { "platform": "integration", "name": "integration", "method": "right", "source": "sensor.power", "unit": ENERGY_KILO_WATT_HOUR, ...
[ "async", "def", "test_right", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"integration\"", ",", "\"name\"", ":", "\"integration\"", ",", "\"method\"", ":", "\"right\"", ",", "\"source\"", ":", "\"sensor.power\"", "...
[ 109, 0 ]
[ 140, 79 ]
python
en
['en', 'da', 'en']
True
test_prefix
(hass)
Test integration sensor state using a power source.
Test integration sensor state using a power source.
async def test_prefix(hass): """Test integration sensor state using a power source.""" config = { "sensor": { "platform": "integration", "name": "integration", "source": "sensor.power", "round": 2, "unit_prefix": "k", } } asser...
[ "async", "def", "test_prefix", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"integration\"", ",", "\"name\"", ":", "\"integration\"", ",", "\"source\"", ":", "\"sensor.power\"", ",", "\"round\"", ":", "2", ",", "\...
[ 143, 0 ]
[ 173, 79 ]
python
en
['en', 'en', 'en']
True
test_suffix
(hass)
Test integration sensor state using a network counter source.
Test integration sensor state using a network counter source.
async def test_suffix(hass): """Test integration sensor state using a network counter source.""" config = { "sensor": { "platform": "integration", "name": "integration", "source": "sensor.bytes_per_second", "round": 2, "unit_prefix": "k", ...
[ "async", "def", "test_suffix", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"integration\"", ",", "\"name\"", ":", "\"integration\"", ",", "\"source\"", ":", "\"sensor.bytes_per_second\"", ",", "\"round\"", ":", "2", ...
[ 176, 0 ]
[ 204, 42 ]
python
en
['en', 'en', 'en']
True
saunabox_fixture
()
Return a default climate entity mock.
Return a default climate entity mock.
def saunabox_fixture(): """Return a default climate entity mock.""" feature = mock_feature( "climates", blebox_uniapi.climate.Climate, unique_id="BleBox-saunaBox-1afe34db9437-thermostat", full_name="saunaBox-thermostat", device_class=None, is_on=None, desi...
[ "def", "saunabox_fixture", "(", ")", ":", "feature", "=", "mock_feature", "(", "\"climates\"", ",", "blebox_uniapi", ".", "climate", ".", "Climate", ",", "unique_id", "=", "\"BleBox-saunaBox-1afe34db9437-thermostat\"", ",", "full_name", "=", "\"saunaBox-thermostat\"", ...
[ 36, 0 ]
[ 53, 51 ]
python
en
['en', 'fr', 'en']
True
test_init
(saunabox, hass, config)
Test default state.
Test default state.
async def test_init(saunabox, hass, config): """Test default state.""" _, entity_id = saunabox entry = await async_setup_entity(hass, config, entity_id) assert entry.unique_id == "BleBox-saunaBox-1afe34db9437-thermostat" state = hass.states.get(entity_id) assert state.name == "saunaBox-thermos...
[ "async", "def", "test_init", "(", "saunabox", ",", "hass", ",", "config", ")", ":", "_", ",", "entity_id", "=", "saunabox", "entry", "=", "await", "async_setup_entity", "(", "hass", ",", "config", ",", "entity_id", ")", "assert", "entry", ".", "unique_id",...
[ 56, 0 ]
[ 89, 38 ]
python
da
['fr', 'da', 'en']
False
test_update
(saunabox, hass, config)
Test updating.
Test updating.
async def test_update(saunabox, hass, config): """Test updating.""" feature_mock, entity_id = saunabox def initial_update(): feature_mock.is_on = False feature_mock.desired = 64.3 feature_mock.current = 40.9 feature_mock.async_update = AsyncMock(side_effect=initial_update) ...
[ "async", "def", "test_update", "(", "saunabox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "saunabox", "def", "initial_update", "(", ")", ":", "feature_mock", ".", "is_on", "=", "False", "feature_mock", ".", "desired", "=", ...
[ 92, 0 ]
[ 109, 39 ]
python
en
['en', 'de', 'en']
False
test_on_when_below_desired
(saunabox, hass, config)
Test when temperature is below desired.
Test when temperature is below desired.
async def test_on_when_below_desired(saunabox, hass, config): """Test when temperature is below desired.""" feature_mock, entity_id = saunabox def initial_update(): feature_mock.is_on = False feature_mock.async_update = AsyncMock(side_effect=initial_update) await async_setup_entity(hass, ...
[ "async", "def", "test_on_when_below_desired", "(", "saunabox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "saunabox", "def", "initial_update", "(", ")", ":", "feature_mock", ".", "is_on", "=", "False", "feature_mock", ".", "as...
[ 112, 0 ]
[ 143, 40 ]
python
en
['en', 'de', 'en']
True
test_on_when_above_desired
(saunabox, hass, config)
Test when temperature is below desired.
Test when temperature is below desired.
async def test_on_when_above_desired(saunabox, hass, config): """Test when temperature is below desired.""" feature_mock, entity_id = saunabox def initial_update(): feature_mock.is_on = False feature_mock.async_update = AsyncMock(side_effect=initial_update) await async_setup_entity(hass, ...
[ "async", "def", "test_on_when_above_desired", "(", "saunabox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "saunabox", "def", "initial_update", "(", ")", ":", "feature_mock", ".", "is_on", "=", "False", "feature_mock", ".", "as...
[ 146, 0 ]
[ 178, 40 ]
python
en
['en', 'de', 'en']
True
test_off
(saunabox, hass, config)
Test turning off.
Test turning off.
async def test_off(saunabox, hass, config): """Test turning off.""" feature_mock, entity_id = saunabox def initial_update(): feature_mock.is_on = True feature_mock.is_heating = False feature_mock.async_update = AsyncMock(side_effect=initial_update) await async_setup_entity(hass, c...
[ "async", "def", "test_off", "(", "saunabox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "saunabox", "def", "initial_update", "(", ")", ":", "feature_mock", ".", "is_on", "=", "True", "feature_mock", ".", "is_heating", "=", ...
[ 181, 0 ]
[ 213, 39 ]
python
en
['en', 'en', 'en']
True
test_set_thermo
(saunabox, hass, config)
Test setting thermostat.
Test setting thermostat.
async def test_set_thermo(saunabox, hass, config): """Test setting thermostat.""" feature_mock, entity_id = saunabox def update(): feature_mock.is_on = False feature_mock.is_heating = False feature_mock.async_update = AsyncMock(side_effect=update) await async_setup_entity(hass, co...
[ "async", "def", "test_set_thermo", "(", "saunabox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "saunabox", "def", "update", "(", ")", ":", "feature_mock", ".", "is_on", "=", "False", "feature_mock", ".", "is_heating", "=", ...
[ 216, 0 ]
[ 247, 40 ]
python
en
['en', 'en', 'en']
True
test_update_failure
(saunabox, hass, config, caplog)
Test that update failures are logged.
Test that update failures are logged.
async def test_update_failure(saunabox, hass, config, caplog): """Test that update failures are logged.""" caplog.set_level(logging.ERROR) feature_mock, entity_id = saunabox feature_mock.async_update = AsyncMock(side_effect=blebox_uniapi.error.ClientError) await async_setup_entity(hass, config, en...
[ "async", "def", "test_update_failure", "(", "saunabox", ",", "hass", ",", "config", ",", "caplog", ")", ":", "caplog", ".", "set_level", "(", "logging", ".", "ERROR", ")", "feature_mock", ",", "entity_id", "=", "saunabox", "feature_mock", ".", "async_update", ...
[ 250, 0 ]
[ 259, 73 ]
python
en
['en', 'en', 'en']
True
GroupedBatchSampler.__len__
(self)
Return the number of mini-batches rather than the number of samples.
Return the number of mini-batches rather than the number of samples.
def __len__(self): """ Return the number of mini-batches rather than the number of samples. """ return (len(self.sampler) + self.batch_size - 1) // self.batch_size
[ "def", "__len__", "(", "self", ")", ":", "return", "(", "len", "(", "self", ".", "sampler", ")", "+", "self", ".", "batch_size", "-", "1", ")", "//", "self", ".", "batch_size" ]
[ 103, 4 ]
[ 107, 75 ]
python
en
['en', 'error', 'th']
False
trace_nms
()
Force NUMBA to trace and compile NMS :return: None
Force NUMBA to trace and compile NMS :return: None
def trace_nms(): ''' Force NUMBA to trace and compile NMS :return: None ''' wup_boxes = np.array([[0, 0, 100, 100, 1.0], [50, 50, 90, 90, 0.5]]).astype(np.float32) nms(wup_boxes)
[ "def", "trace_nms", "(", ")", ":", "wup_boxes", "=", "np", ".", "array", "(", "[", "[", "0", ",", "0", ",", "100", ",", "100", ",", "1.0", "]", ",", "[", "50", ",", "50", ",", "90", ",", "90", ",", "0.5", "]", "]", ")", ".", "astype", "("...
[ 35, 0 ]
[ 41, 18 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Tube sensor.
Set up the Tube sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Tube sensor.""" data = TubeData() data.update() sensors = [] for line in config.get(CONF_LINE): sensors.append(LondonTubeSensor(line, data)) add_entities(sensors, True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "data", "=", "TubeData", "(", ")", "data", ".", "update", "(", ")", "sensors", "=", "[", "]", "for", "line", "in", "config", ".", ...
[ 41, 0 ]
[ 50, 31 ]
python
en
['en', 'sq', 'en']
True
LondonTubeSensor.__init__
(self, name, data)
Initialize the London Underground sensor.
Initialize the London Underground sensor.
def __init__(self, name, data): """Initialize the London Underground sensor.""" self._data = data self._description = None self._name = name self._state = None self.attrs = {ATTR_ATTRIBUTION: ATTRIBUTION}
[ "def", "__init__", "(", "self", ",", "name", ",", "data", ")", ":", "self", ".", "_data", "=", "data", "self", ".", "_description", "=", "None", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "None", "self", ".", "attrs", "=", "{", ...
[ 56, 4 ]
[ 62, 52 ]
python
en
['en', 'zu', 'en']
True
LondonTubeSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 65, 4 ]
[ 67, 25 ]
python
en
['en', 'mi', 'en']
True
LondonTubeSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 70, 4 ]
[ 72, 26 ]
python
en
['en', 'en', 'en']
True
LondonTubeSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 75, 4 ]
[ 77, 19 ]
python
en
['en', 'en', 'en']
True
LondonTubeSensor.device_state_attributes
(self)
Return other details about the sensor state.
Return other details about the sensor state.
def device_state_attributes(self): """Return other details about the sensor state.""" self.attrs["Description"] = self._description return self.attrs
[ "def", "device_state_attributes", "(", "self", ")", ":", "self", ".", "attrs", "[", "\"Description\"", "]", "=", "self", ".", "_description", "return", "self", ".", "attrs" ]
[ 80, 4 ]
[ 83, 25 ]
python
en
['en', 'en', 'en']
True
LondonTubeSensor.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" self._data.update() self._state = self._data.data[self.name]["State"] self._description = self._data.data[self.name]["Description"]
[ "def", "update", "(", "self", ")", ":", "self", ".", "_data", ".", "update", "(", ")", "self", ".", "_state", "=", "self", ".", "_data", ".", "data", "[", "self", ".", "name", "]", "[", "\"State\"", "]", "self", ".", "_description", "=", "self", ...
[ 85, 4 ]
[ 89, 69 ]
python
en
['en', 'nl', 'en']
True
test_template
(hass)
Test template.
Test template.
async def test_template(hass): """Test template.""" with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", "sensors": { ...
[ "async", "def", "test_template", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", ...
[ 24, 0 ]
[ 52, 37 ]
python
en
['en', 'en', 'en']
False
test_icon_template
(hass)
Test icon template.
Test icon template.
async def test_icon_template(hass): """Test icon template.""" with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", "sensors...
[ "async", "def", "test_icon_template", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":...
[ 55, 0 ]
[ 87, 50 ]
python
en
['en', 'en', 'en']
True
test_entity_picture_template
(hass)
Test entity_picture template.
Test entity_picture template.
async def test_entity_picture_template(hass): """Test entity_picture template.""" with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_entity_picture_template", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"senso...
[ 90, 0 ]
[ 122, 68 ]
python
en
['fr', 'en', 'en']
True
test_friendly_name_template
(hass)
Test friendly_name template.
Test friendly_name template.
async def test_friendly_name_template(hass): """Test friendly_name template.""" with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_friendly_name_template", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor...
[ 125, 0 ]
[ 154, 59 ]
python
en
['en', 'en', 'en']
True
test_friendly_name_template_with_unknown_state
(hass)
Test friendly_name template with an unknown value_template.
Test friendly_name template with an unknown value_template.
async def test_friendly_name_template_with_unknown_state(hass): """Test friendly_name template with an unknown value_template.""" with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { ...
[ "async", "def", "test_friendly_name_template_with_unknown_state", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",",...
[ 157, 0 ]
[ 186, 59 ]
python
en
['en', 'en', 'en']
True
test_attribute_templates
(hass)
Test attribute_templates template.
Test attribute_templates template.
async def test_attribute_templates(hass): """Test attribute_templates template.""" with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_attribute_templates", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\""...
[ 189, 0 ]
[ 220, 60 ]
python
en
['en', 'en', 'en']
True
test_template_syntax_error
(hass)
Test templating syntax error.
Test templating syntax error.
async def test_template_syntax_error(hass): """Test templating syntax error.""" with assert_setup_component(0, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_template_syntax_error", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\...
[ 223, 0 ]
[ 242, 40 ]
python
ca
['ca', 'de', 'en']
False
test_template_attribute_missing
(hass)
Test missing attribute template.
Test missing attribute template.
async def test_template_attribute_missing(hass): """Test missing attribute template.""" with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_template_attribute_missing", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"se...
[ 245, 0 ]
[ 269, 43 ]
python
en
['en', 'en', 'en']
True
test_invalid_name_does_not_create
(hass)
Test invalid name.
Test invalid name.
async def test_invalid_name_does_not_create(hass): """Test invalid name.""" with assert_setup_component(0, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_invalid_name_does_not_create", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"...
[ 272, 0 ]
[ 294, 40 ]
python
en
['en', 'et', 'en']
True
test_invalid_sensor_does_not_create
(hass)
Test invalid sensor.
Test invalid sensor.
async def test_invalid_sensor_does_not_create(hass): """Test invalid sensor.""" with assert_setup_component(0, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_invalid_sensor_does_not_create", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "...
[ 297, 0 ]
[ 314, 40 ]
python
en
['en', 'et', 'en']
True
test_no_sensors_does_not_create
(hass)
Test no sensors.
Test no sensors.
async def test_no_sensors_does_not_create(hass): """Test no sensors.""" with assert_setup_component(0, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, {"sensor": {"platform": "template"}} ) await hass.async_block_till_done() await hass.async_start() ...
[ "async", "def", "test_no_sensors_does_not_create", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"se...
[ 317, 0 ]
[ 328, 40 ]
python
ca
['es', 'ca', 'pt']
False
test_missing_template_does_not_create
(hass)
Test missing template.
Test missing template.
async def test_missing_template_does_not_create(hass): """Test missing template.""" with assert_setup_component(0, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_missing_template_does_not_create", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", ...
[ 331, 0 ]
[ 353, 40 ]
python
en
['en', 'en', 'en']
True
test_setup_invalid_device_class
(hass)
Test setup with invalid device_class.
Test setup with invalid device_class.
async def test_setup_invalid_device_class(hass): """Test setup with invalid device_class.""" with assert_setup_component(0, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template...
[ "async", "def", "test_setup_invalid_device_class", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"se...
[ 356, 0 ]
[ 373, 9 ]
python
en
['en', 'en', 'en']
True
test_setup_valid_device_class
(hass)
Test setup with valid device_class.
Test setup with valid device_class.
async def test_setup_valid_device_class(hass): """Test setup with valid device_class.""" with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_setup_valid_device_class", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sens...
[ 376, 0 ]
[ 402, 49 ]
python
en
['en', 'en', 'en']
True
test_creating_sensor_loads_group
(hass)
Test setting up template sensor loads group component first.
Test setting up template sensor loads group component first.
async def test_creating_sensor_loads_group(hass): """Test setting up template sensor loads group component first.""" order = [] after_dep_event = Event() async def async_setup_group(hass, config): # Make sure group takes longer to load, so that it won't # be loaded first by chance ...
[ "async", "def", "test_creating_sensor_loads_group", "(", "hass", ")", ":", "order", "=", "[", "]", "after_dep_event", "=", "Event", "(", ")", "async", "def", "async_setup_group", "(", "hass", ",", "config", ")", ":", "# Make sure group takes longer to load, so that ...
[ 405, 0 ]
[ 442, 48 ]
python
en
['en', 'en', 'en']
True
test_available_template_with_entities
(hass)
Test availability tempalates with values from other entities.
Test availability tempalates with values from other entities.
async def test_available_template_with_entities(hass): """Test availability tempalates with values from other entities.""" hass.states.async_set("sensor.availability_sensor", STATE_OFF) with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, s...
[ "async", "def", "test_available_template_with_entities", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.availability_sensor\"", ",", "STATE_OFF", ")", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":...
[ 445, 0 ]
[ 481, 84 ]
python
en
['en', 'en', 'en']
True
test_invalid_attribute_template
(hass, caplog)
Test that errors are logged if rendering template fails.
Test that errors are logged if rendering template fails.
async def test_invalid_attribute_template(hass, caplog): """Test that errors are logged if rendering template fails.""" hass.states.async_set("sensor.test_sensor", "startup") await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "tem...
[ "async", "def", "test_invalid_attribute_template", "(", "hass", ",", "caplog", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_sensor\"", ",", "\"startup\"", ")", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ...
[ 484, 0 ]
[ 513, 42 ]
python
en
['en', 'en', 'en']
True
test_invalid_availability_template_keeps_component_available
(hass, caplog)
Test that an invalid availability keeps the device available.
Test that an invalid availability keeps the device available.
async def test_invalid_availability_template_keeps_component_available(hass, caplog): """Test that an invalid availability keeps the device available.""" await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", "...
[ "async", "def", "test_invalid_availability_template_keeps_component_available", "(", "hass", ",", "caplog", ")", ":", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"template\"", ...
[ 516, 0 ]
[ 540, 62 ]
python
en
['en', 'en', 'en']
True
test_no_template_match_all
(hass, caplog)
Test that we allow static templates.
Test that we allow static templates.
async def test_no_template_match_all(hass, caplog): """Test that we allow static templates.""" hass.states.async_set("sensor.test_sensor", "startup") hass.state = CoreState.not_running await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "...
[ "async", "def", "test_no_template_match_all", "(", "hass", ",", "caplog", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_sensor\"", ",", "\"startup\"", ")", "hass", ".", "state", "=", "CoreState", ".", "not_running", "await", "async_setup...
[ 543, 0 ]
[ 626, 71 ]
python
en
['en', 'en', 'en']
True
test_unique_id
(hass)
Test unique_id option only creates one sensor per id.
Test unique_id option only creates one sensor per id.
async def test_unique_id(hass): """Test unique_id option only creates one sensor per id.""" await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", "sensors": { "test_template_sensor_01": { ...
[ "async", "def", "test_unique_id", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"sensors\"", ":", "{", "\"test_template_sensor_01\...
[ 629, 0 ]
[ 655, 44 ]
python
en
['en', 'en', 'en']
True
test_sun_renders_once_per_sensor
(hass)
Test sun change renders the template only once per sensor.
Test sun change renders the template only once per sensor.
async def test_sun_renders_once_per_sensor(hass): """Test sun change renders the template only once per sensor.""" now = dt_util.utcnow() hass.states.async_set( "sun.sun", "above_horizon", {"elevation": 45.3, "next_rising": now} ) await async_setup_component( hass, sensor.D...
[ "async", "def", "test_sun_renders_once_per_sensor", "(", "hass", ")", ":", "now", "=", "dt_util", ".", "utcnow", "(", ")", "hass", ".", "states", ".", "async_set", "(", "\"sun.sun\"", ",", "\"above_horizon\"", ",", "{", "\"elevation\"", ":", "45.3", ",", "\"...
[ 658, 0 ]
[ 716, 5 ]
python
en
['en', 'en', 'en']
True
test_self_referencing_sensor_loop
(hass, caplog)
Test a self referencing sensor does not loop forever.
Test a self referencing sensor does not loop forever.
async def test_self_referencing_sensor_loop(hass, caplog): """Test a self referencing sensor does not loop forever.""" await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", "sensors": { "te...
[ "async", "def", "test_self_referencing_sensor_loop", "(", "hass", ",", "caplog", ")", ":", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"sensors\"", ":"...
[ 719, 0 ]
[ 751, 32 ]
python
en
['en', 'en', 'en']
True
test_self_referencing_sensor_with_icon_loop
(hass, caplog)
Test a self referencing sensor loops forever with a valid self referencing icon.
Test a self referencing sensor loops forever with a valid self referencing icon.
async def test_self_referencing_sensor_with_icon_loop(hass, caplog): """Test a self referencing sensor loops forever with a valid self referencing icon.""" await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template", ...
[ "async", "def", "test_self_referencing_sensor_with_icon_loop", "(", "hass", ",", "caplog", ")", ":", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"sensors...
[ 754, 0 ]
[ 789, 32 ]
python
en
['en', 'en', 'en']
True
test_self_referencing_sensor_with_icon_and_picture_entity_loop
(hass, caplog)
Test a self referencing sensor loop forevers with a valid self referencing icon.
Test a self referencing sensor loop forevers with a valid self referencing icon.
async def test_self_referencing_sensor_with_icon_and_picture_entity_loop(hass, caplog): """Test a self referencing sensor loop forevers with a valid self referencing icon.""" await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "templat...
[ "async", "def", "test_self_referencing_sensor_with_icon_and_picture_entity_loop", "(", "hass", ",", "caplog", ")", ":", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"template\"", ...
[ 792, 0 ]
[ 829, 32 ]
python
en
['en', 'en', 'en']
True
test_self_referencing_entity_picture_loop
(hass, caplog)
Test a self referencing sensor does not loop forever with a looping self referencing entity picture.
Test a self referencing sensor does not loop forever with a looping self referencing entity picture.
async def test_self_referencing_entity_picture_loop(hass, caplog): """Test a self referencing sensor does not loop forever with a looping self referencing entity picture.""" await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "template...
[ "async", "def", "test_self_referencing_entity_picture_loop", "(", "hass", ",", "caplog", ")", ":", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"sensors\"...
[ 832, 0 ]
[ 872, 32 ]
python
en
['en', 'en', 'en']
True
test_self_referencing_icon_with_no_loop
(hass, caplog)
Test a self referencing icon that does not loop.
Test a self referencing icon that does not loop.
async def test_self_referencing_icon_with_no_loop(hass, caplog): """Test a self referencing icon that does not loop.""" hass.states.async_set("sensor.heartworm_high_80", 10) hass.states.async_set("sensor.heartworm_low_57", 10) hass.states.async_set("sensor.heartworm_avg_64", 10) hass.states.async_s...
[ "async", "def", "test_self_referencing_icon_with_no_loop", "(", "hass", ",", "caplog", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.heartworm_high_80\"", ",", "10", ")", "hass", ".", "states", ".", "async_set", "(", "\"sensor.heartworm_low_57\""...
[ 875, 0 ]
[ 947, 54 ]
python
en
['en', 'en', 'en']
True
test_duplicate_templates
(hass)
Test template entity where the value and friendly name as the same template.
Test template entity where the value and friendly name as the same template.
async def test_duplicate_templates(hass): """Test template entity where the value and friendly name as the same template.""" hass.states.async_set("sensor.test_state", "Abc") with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMA...
[ "async", "def", "test_duplicate_templates", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_state\"", ",", "\"Abc\"", ")", "with", "assert_setup_component", "(", "1", ",", "sensor", ".", "DOMAIN", ")", ":", "assert", "await"...
[ 950, 0 ]
[ 984, 31 ]
python
en
['en', 'en', 'en']
True
test_services
(hass)
Test energy sensor reset service.
Test energy sensor reset service.
async def test_services(hass): """Test energy sensor reset service.""" config = { "utility_meter": { "energy_bill": { "source": "sensor.energy", "cycle": "hourly", "tariffs": ["peak", "offpeak"], } } } assert await ...
[ "async", "def", "test_services", "(", "hass", ")", ":", "config", "=", "{", "\"utility_meter\"", ":", "{", "\"energy_bill\"", ":", "{", "\"source\"", ":", "\"sensor.energy\"", ",", "\"cycle\"", ":", "\"hourly\"", ",", "\"tariffs\"", ":", "[", "\"peak\"", ",", ...
[ 23, 0 ]
[ 113, 29 ]
python
en
['en', 'hu', 'en']
True
validate_options
(value)
Validate options. If set position topic is set then get position topic is set as well.
Validate options.
def validate_options(value): """Validate options. If set position topic is set then get position topic is set as well. """ if CONF_SET_POSITION_TOPIC in value and CONF_GET_POSITION_TOPIC not in value: raise vol.Invalid( "set_position_topic must be set together with position_topic." ...
[ "def", "validate_options", "(", "value", ")", ":", "if", "CONF_SET_POSITION_TOPIC", "in", "value", "and", "CONF_GET_POSITION_TOPIC", "not", "in", "value", ":", "raise", "vol", ".", "Invalid", "(", "\"set_position_topic must be set together with position_topic.\"", ")", ...
[ 108, 0 ]
[ 117, 16 ]
python
en
['en', 'et', 'en']
False
async_setup_platform
( hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None )
Set up MQTT cover through configuration.yaml.
Set up MQTT cover through configuration.yaml.
async def async_setup_platform( hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None ): """Set up MQTT cover through configuration.yaml.""" await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await _async_setup_entity(hass, config, async_add_entities)
[ "async", "def", "async_setup_platform", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "await", "async_setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATF...
[ 171, 0 ]
[ 176, 63 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up MQTT cover dynamically through MQTT discovery.
Set up MQTT cover dynamically through MQTT discovery.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up MQTT cover dynamically through MQTT discovery.""" async def async_discover(discovery_payload): """Discover and add an MQTT cover.""" discovery_data = discovery_payload.discovery_data try: config =...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "async", "def", "async_discover", "(", "discovery_payload", ")", ":", "\"\"\"Discover and add an MQTT cover.\"\"\"", "discovery_data", "=", "discovery_payload", "."...
[ 179, 0 ]
[ 196, 5 ]
python
en
['en', 'en', 'en']
True
_async_setup_entity
( hass, config, async_add_entities, config_entry=None, discovery_data=None )
Set up the MQTT Cover.
Set up the MQTT Cover.
async def _async_setup_entity( hass, config, async_add_entities, config_entry=None, discovery_data=None ): """Set up the MQTT Cover.""" async_add_entities([MqttCover(hass, config, config_entry, discovery_data)])
[ "async", "def", "_async_setup_entity", "(", "hass", ",", "config", ",", "async_add_entities", ",", "config_entry", "=", "None", ",", "discovery_data", "=", "None", ")", ":", "async_add_entities", "(", "[", "MqttCover", "(", "hass", ",", "config", ",", "config_...
[ 199, 0 ]
[ 203, 79 ]
python
en
['en', 'en', 'en']
True
MqttCover.__init__
(self, hass, config, config_entry, discovery_data)
Initialize the cover.
Initialize the cover.
def __init__(self, hass, config, config_entry, discovery_data): """Initialize the cover.""" self.hass = hass self._unique_id = config.get(CONF_UNIQUE_ID) self._position = None self._state = None self._sub_state = None self._optimistic = None self._tilt_va...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ",", "config_entry", ",", "discovery_data", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_unique_id", "=", "config", ".", "get", "(", "CONF_UNIQUE_ID", ")", "self", ".", "_position"...
[ 215, 4 ]
[ 235, 72 ]
python
en
['en', 'en', 'en']
True
MqttCover.async_added_to_hass
(self)
Subscribe MQTT events.
Subscribe MQTT events.
async def async_added_to_hass(self): """Subscribe MQTT events.""" await super().async_added_to_hass() await self._subscribe_topics()
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "await", "self", ".", "_subscribe_topics", "(", ")" ]
[ 237, 4 ]
[ 240, 38 ]
python
en
['en', 'en', 'en']
True
MqttCover.discovery_update
(self, discovery_payload)
Handle updated discovery message.
Handle updated discovery message.
async def discovery_update(self, discovery_payload): """Handle updated discovery message.""" config = PLATFORM_SCHEMA(discovery_payload) self._setup_from_config(config) await self.attributes_discovery_update(config) await self.availability_discovery_update(config) await s...
[ "async", "def", "discovery_update", "(", "self", ",", "discovery_payload", ")", ":", "config", "=", "PLATFORM_SCHEMA", "(", "discovery_payload", ")", "self", ".", "_setup_from_config", "(", "config", ")", "await", "self", ".", "attributes_discovery_update", "(", "...
[ 242, 4 ]
[ 250, 35 ]
python
en
['en', 'en', 'en']
True
MqttCover._subscribe_topics
(self)
(Re)Subscribe to topics.
(Re)Subscribe to topics.
async def _subscribe_topics(self): """(Re)Subscribe to topics.""" topics = {} @callback @log_messages(self.hass, self.entity_id) def tilt_message_received(msg): """Handle tilt updates.""" payload = msg.payload tilt_status_template = self._conf...
[ "async", "def", "_subscribe_topics", "(", "self", ")", ":", "topics", "=", "{", "}", "@", "callback", "@", "log_messages", "(", "self", ".", "hass", ",", "self", ".", "entity_id", ")", "def", "tilt_message_received", "(", "msg", ")", ":", "\"\"\"Handle til...
[ 270, 4 ]
[ 373, 9 ]
python
en
['en', 'en', 'en']
True
MqttCover.async_will_remove_from_hass
(self)
Unsubscribe when removed.
Unsubscribe when removed.
async def async_will_remove_from_hass(self): """Unsubscribe when removed.""" self._sub_state = await subscription.async_unsubscribe_topics( self.hass, self._sub_state ) await MqttAttributes.async_will_remove_from_hass(self) await MqttAvailability.async_will_remove_fro...
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "self", ".", "_sub_state", "=", "await", "subscription", ".", "async_unsubscribe_topics", "(", "self", ".", "hass", ",", "self", ".", "_sub_state", ")", "await", "MqttAttributes", ".", "async_...
[ 375, 4 ]
[ 382, 67 ]
python
en
['en', 'en', 'en']
True
MqttCover.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 385, 4 ]
[ 387, 20 ]
python
en
['en', 'en', 'en']
True
MqttCover.assumed_state
(self)
Return true if we do optimistic updates.
Return true if we do optimistic updates.
def assumed_state(self): """Return true if we do optimistic updates.""" return self._optimistic
[ "def", "assumed_state", "(", "self", ")", ":", "return", "self", ".", "_optimistic" ]
[ 390, 4 ]
[ 392, 31 ]
python
en
['pt', 'la', 'en']
False
MqttCover.name
(self)
Return the name of the cover.
Return the name of the cover.
def name(self): """Return the name of the cover.""" return self._config[CONF_NAME]
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_config", "[", "CONF_NAME", "]" ]
[ 395, 4 ]
[ 397, 38 ]
python
en
['en', 'en', 'en']
True
MqttCover.is_closed
(self)
Return true if the cover is closed or None if the status is unknown.
Return true if the cover is closed or None if the status is unknown.
def is_closed(self): """Return true if the cover is closed or None if the status is unknown.""" if self._state is None: return None return self._state == STATE_CLOSED
[ "def", "is_closed", "(", "self", ")", ":", "if", "self", ".", "_state", "is", "None", ":", "return", "None", "return", "self", ".", "_state", "==", "STATE_CLOSED" ]
[ 400, 4 ]
[ 405, 42 ]
python
en
['en', 'en', 'en']
True
MqttCover.is_opening
(self)
Return true if the cover is actively opening.
Return true if the cover is actively opening.
def is_opening(self): """Return true if the cover is actively opening.""" return self._state == STATE_OPENING
[ "def", "is_opening", "(", "self", ")", ":", "return", "self", ".", "_state", "==", "STATE_OPENING" ]
[ 408, 4 ]
[ 410, 43 ]
python
en
['en', 'en', 'en']
True
MqttCover.is_closing
(self)
Return true if the cover is actively closing.
Return true if the cover is actively closing.
def is_closing(self): """Return true if the cover is actively closing.""" return self._state == STATE_CLOSING
[ "def", "is_closing", "(", "self", ")", ":", "return", "self", ".", "_state", "==", "STATE_CLOSING" ]
[ 413, 4 ]
[ 415, 43 ]
python
en
['en', 'en', 'en']
True
MqttCover.current_cover_position
(self)
Return current position of cover. None is unknown, 0 is closed, 100 is fully open.
Return current position of cover.
def current_cover_position(self): """Return current position of cover. None is unknown, 0 is closed, 100 is fully open. """ return self._position
[ "def", "current_cover_position", "(", "self", ")", ":", "return", "self", ".", "_position" ]
[ 418, 4 ]
[ 423, 29 ]
python
en
['en', 'en', 'en']
True
MqttCover.current_cover_tilt_position
(self)
Return current position of cover tilt.
Return current position of cover tilt.
def current_cover_tilt_position(self): """Return current position of cover tilt.""" return self._tilt_value
[ "def", "current_cover_tilt_position", "(", "self", ")", ":", "return", "self", ".", "_tilt_value" ]
[ 426, 4 ]
[ 428, 31 ]
python
en
['en', 'da', 'en']
True
MqttCover.device_class
(self)
Return the class of this sensor.
Return the class of this sensor.
def device_class(self): """Return the class of this sensor.""" return self._config.get(CONF_DEVICE_CLASS)
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_DEVICE_CLASS", ")" ]
[ 431, 4 ]
[ 433, 50 ]
python
en
['en', 'en', 'en']
True
MqttCover.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" supported_features = 0 if self._config.get(CONF_COMMAND_TOPIC) is not None: supported_features = OPEN_CLOSE_FEATURES if self._config.get(CONF_PAYLOAD_STOP) is not None: supported_features |= SUP...
[ "def", "supported_features", "(", "self", ")", ":", "supported_features", "=", "0", "if", "self", ".", "_config", ".", "get", "(", "CONF_COMMAND_TOPIC", ")", "is", "not", "None", ":", "supported_features", "=", "OPEN_CLOSE_FEATURES", "if", "self", ".", "_confi...
[ 436, 4 ]
[ 451, 33 ]
python
en
['da', 'en', 'en']
True
MqttCover.async_open_cover
(self, **kwargs)
Move the cover up. This method is a coroutine.
Move the cover up.
async def async_open_cover(self, **kwargs): """Move the cover up. This method is a coroutine. """ mqtt.async_publish( self.hass, self._config.get(CONF_COMMAND_TOPIC), self._config[CONF_PAYLOAD_OPEN], self._config[CONF_QOS], sel...
[ "async", "def", "async_open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mqtt", ".", "async_publish", "(", "self", ".", "hass", ",", "self", ".", "_config", ".", "get", "(", "CONF_COMMAND_TOPIC", ")", ",", "self", ".", "_config", "[", "CONF...
[ 453, 4 ]
[ 472, 39 ]
python
en
['en', 'en', 'en']
True
MqttCover.async_close_cover
(self, **kwargs)
Move the cover down. This method is a coroutine.
Move the cover down.
async def async_close_cover(self, **kwargs): """Move the cover down. This method is a coroutine. """ mqtt.async_publish( self.hass, self._config.get(CONF_COMMAND_TOPIC), self._config[CONF_PAYLOAD_CLOSE], self._config[CONF_QOS], ...
[ "async", "def", "async_close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mqtt", ".", "async_publish", "(", "self", ".", "hass", ",", "self", ".", "_config", ".", "get", "(", "CONF_COMMAND_TOPIC", ")", ",", "self", ".", "_config", "[", "CON...
[ 474, 4 ]
[ 493, 39 ]
python
en
['en', 'en', 'en']
True
MqttCover.async_stop_cover
(self, **kwargs)
Stop the device. This method is a coroutine.
Stop the device.
async def async_stop_cover(self, **kwargs): """Stop the device. This method is a coroutine. """ mqtt.async_publish( self.hass, self._config.get(CONF_COMMAND_TOPIC), self._config[CONF_PAYLOAD_STOP], self._config[CONF_QOS], self....
[ "async", "def", "async_stop_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mqtt", ".", "async_publish", "(", "self", ".", "hass", ",", "self", ".", "_config", ".", "get", "(", "CONF_COMMAND_TOPIC", ")", ",", "self", ".", "_config", "[", "CONF...
[ 495, 4 ]
[ 506, 9 ]
python
en
['en', 'en', 'en']
True
MqttCover.async_open_cover_tilt
(self, **kwargs)
Tilt the cover open.
Tilt the cover open.
async def async_open_cover_tilt(self, **kwargs): """Tilt the cover open.""" mqtt.async_publish( self.hass, self._config.get(CONF_TILT_COMMAND_TOPIC), self._config[CONF_TILT_OPEN_POSITION], self._config[CONF_QOS], self._config[CONF_RETAIN], ...
[ "async", "def", "async_open_cover_tilt", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mqtt", ".", "async_publish", "(", "self", ".", "hass", ",", "self", ".", "_config", ".", "get", "(", "CONF_TILT_COMMAND_TOPIC", ")", ",", "self", ".", "_config", "[...
[ 508, 4 ]
[ 521, 39 ]
python
en
['en', 'no', 'en']
True
MqttCover.async_close_cover_tilt
(self, **kwargs)
Tilt the cover closed.
Tilt the cover closed.
async def async_close_cover_tilt(self, **kwargs): """Tilt the cover closed.""" mqtt.async_publish( self.hass, self._config.get(CONF_TILT_COMMAND_TOPIC), self._config[CONF_TILT_CLOSED_POSITION], self._config[CONF_QOS], self._config[CONF_RETAIN],...
[ "async", "def", "async_close_cover_tilt", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mqtt", ".", "async_publish", "(", "self", ".", "hass", ",", "self", ".", "_config", ".", "get", "(", "CONF_TILT_COMMAND_TOPIC", ")", ",", "self", ".", "_config", "...
[ 523, 4 ]
[ 536, 39 ]
python
en
['en', 'en', 'en']
True
MqttCover.async_set_cover_tilt_position
(self, **kwargs)
Move the cover tilt to a specific position.
Move the cover tilt to a specific position.
async def async_set_cover_tilt_position(self, **kwargs): """Move the cover tilt to a specific position.""" position = kwargs[ATTR_TILT_POSITION] # The position needs to be between min and max level = self.find_in_range_from_percent(position) mqtt.async_publish( self...
[ "async", "def", "async_set_cover_tilt_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "position", "=", "kwargs", "[", "ATTR_TILT_POSITION", "]", "# The position needs to be between min and max", "level", "=", "self", ".", "find_in_range_from_percent", "(", ...
[ 538, 4 ]
[ 551, 9 ]
python
en
['en', 'en', 'en']
True