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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
HiveDevicePlug.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self.session.switch.get_state(self.node_id) | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"session",
".",
"switch",
".",
"get_state",
"(",
"self",
".",
"node_id",
")"
] | [
47,
4
] | [
49,
58
] | python | en | ['en', 'fy', 'en'] | True |
HiveDevicePlug.turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | def turn_on(self, **kwargs):
"""Turn the switch on."""
self.session.switch.turn_on(self.node_id) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"session",
".",
"switch",
".",
"turn_on",
"(",
"self",
".",
"node_id",
")"
] | [
52,
4
] | [
54,
49
] | python | en | ['en', 'en', 'en'] | True |
HiveDevicePlug.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
self.session.switch.turn_off(self.node_id) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"session",
".",
"switch",
".",
"turn_off",
"(",
"self",
".",
"node_id",
")"
] | [
57,
4
] | [
59,
50
] | python | en | ['en', 'en', 'en'] | True |
HiveDevicePlug.update | (self) | Update all Node data from Hive. | Update all Node data from Hive. | def update(self):
"""Update all Node data from Hive."""
self.session.core.update_data(self.node_id)
self.attributes = self.session.attributes.state_attributes(self.node_id) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"session",
".",
"core",
".",
"update_data",
"(",
"self",
".",
"node_id",
")",
"self",
".",
"attributes",
"=",
"self",
".",
"session",
".",
"attributes",
".",
"state_attributes",
"(",
"self",
".",
"no... | [
61,
4
] | [
64,
80
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up tellduslive sensors dynamically. | Set up tellduslive sensors dynamically. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up tellduslive sensors dynamically."""
async def async_discover_cover(device_id):
"""Discover and add a discovered sensor."""
client = hass.data[tellduslive.DOMAIN]
async_add_entities([TelldusLiveCover(client, d... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"async_discover_cover",
"(",
"device_id",
")",
":",
"\"\"\"Discover and add a discovered sensor.\"\"\"",
"client",
"=",
"hass",
".",
"data",
"["... | [
8,
0
] | [
20,
5
] | python | en | ['en', 'hu', 'en'] | True |
TelldusLiveCover.is_closed | (self) | Return the current position of the cover. | Return the current position of the cover. | def is_closed(self):
"""Return the current position of the cover."""
return self.device.is_down | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"device",
".",
"is_down"
] | [
27,
4
] | [
29,
34
] | python | en | ['en', 'en', 'en'] | True |
TelldusLiveCover.close_cover | (self, **kwargs) | Close the cover. | Close the cover. | def close_cover(self, **kwargs):
"""Close the cover."""
self.device.down()
self._update_callback() | [
"def",
"close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"device",
".",
"down",
"(",
")",
"self",
".",
"_update_callback",
"(",
")"
] | [
31,
4
] | [
34,
31
] | python | en | ['en', 'en', 'en'] | True |
TelldusLiveCover.open_cover | (self, **kwargs) | Open the cover. | Open the cover. | def open_cover(self, **kwargs):
"""Open the cover."""
self.device.up()
self._update_callback() | [
"def",
"open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"device",
".",
"up",
"(",
")",
"self",
".",
"_update_callback",
"(",
")"
] | [
36,
4
] | [
39,
31
] | python | en | ['en', 'en', 'en'] | True |
TelldusLiveCover.stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | def stop_cover(self, **kwargs):
"""Stop the cover."""
self.device.stop()
self._update_callback() | [
"def",
"stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"device",
".",
"stop",
"(",
")",
"self",
".",
"_update_callback",
"(",
")"
] | [
41,
4
] | [
44,
31
] | python | en | ['en', 'en', 'en'] | True |
mock_successful_connection | (*args, **kwargs) | Return a successful connection. | Return a successful connection. | async def mock_successful_connection(*args, **kwargs):
"""Return a successful connection."""
return True | [
"async",
"def",
"mock_successful_connection",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"True"
] | [
46,
0
] | [
48,
15
] | python | en | ['en', 'en', 'en'] | True |
mock_failed_connection | (*args, **kwargs) | Return a failed connection. | Return a failed connection. | async def mock_failed_connection(*args, **kwargs):
"""Return a failed connection."""
raise ConnectionError("Connection failed") | [
"async",
"def",
"mock_failed_connection",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"ConnectionError",
"(",
"\"Connection failed\"",
")"
] | [
51,
0
] | [
53,
46
] | python | en | ['en', 'ga', 'en'] | True |
test_setup_entry | (hass: HomeAssistantType) | Test setting up the entry. | Test setting up the entry. | async def test_setup_entry(hass: HomeAssistantType):
"""Test setting up the entry."""
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_INPUT_PLM)
config_entry.add_to_hass(hass)
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "... | [
"async",
"def",
"test_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"MOCK_USER_INPUT_PLM",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"with",... | [
56,
0
] | [
76,
32
] | python | en | ['en', 'en', 'en'] | True |
test_import_plm | (hass: HomeAssistantType) | Test setting up the entry from YAML to a PLM. | Test setting up the entry from YAML to a PLM. | async def test_import_plm(hass: HomeAssistantType):
"""Test setting up the entry from YAML to a PLM."""
config = {}
config[DOMAIN] = MOCK_IMPORT_CONFIG_PLM
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "close_insteon_connection"), patch... | [
"async",
"def",
"test_import_plm",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_CONFIG_PLM",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",
"new",
"=... | [
79,
0
] | [
101,
32
] | python | en | ['en', 'en', 'en'] | True |
test_import_hub1 | (hass: HomeAssistantType) | Test setting up the entry from YAML to a hub v1. | Test setting up the entry from YAML to a hub v1. | async def test_import_hub1(hass: HomeAssistantType):
"""Test setting up the entry from YAML to a hub v1."""
config = {}
config[DOMAIN] = MOCK_IMPORT_MINIMUM_HUB_V1
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "close_insteon_connection"... | [
"async",
"def",
"test_import_hub1",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_MINIMUM_HUB_V1",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",
"new",... | [
104,
0
] | [
128,
36
] | python | en | ['en', 'en', 'en'] | True |
test_import_hub2 | (hass: HomeAssistantType) | Test setting up the entry from YAML to a hub v2. | Test setting up the entry from YAML to a hub v2. | async def test_import_hub2(hass: HomeAssistantType):
"""Test setting up the entry from YAML to a hub v2."""
config = {}
config[DOMAIN] = MOCK_IMPORT_MINIMUM_HUB_V2
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "close_insteon_connection"... | [
"async",
"def",
"test_import_hub2",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_MINIMUM_HUB_V2",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",
"new",... | [
131,
0
] | [
155,
75
] | python | en | ['en', 'en', 'en'] | True |
test_import_options | (hass: HomeAssistantType) | Test setting up the entry from YAML including options. | Test setting up the entry from YAML including options. | async def test_import_options(hass: HomeAssistantType):
"""Test setting up the entry from YAML including options."""
config = {}
config[DOMAIN] = MOCK_IMPORT_FULL_CONFIG_PLM
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "close_insteon_c... | [
"async",
"def",
"test_import_options",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_FULL_CONFIG_PLM",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",
"n... | [
158,
0
] | [
188,
75
] | python | en | ['en', 'en', 'en'] | True |
test_import_failed_connection | (hass: HomeAssistantType) | Test a failed connection in import does not create a config entry. | Test a failed connection in import does not create a config entry. | async def test_import_failed_connection(hass: HomeAssistantType):
"""Test a failed connection in import does not create a config entry."""
config = {}
config[DOMAIN] = MOCK_IMPORT_CONFIG_PLM
with patch.object(
insteon, "async_connect", new=mock_failed_connection
), patch.object(insteon, "as... | [
"async",
"def",
"test_import_failed_connection",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_CONFIG_PLM",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",... | [
191,
0
] | [
207,
60
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_failed_connection | (hass: HomeAssistantType, caplog) | Test setting up the entry with a failed connection. | Test setting up the entry with a failed connection. | async def test_setup_entry_failed_connection(hass: HomeAssistantType, caplog):
"""Test setting up the entry with a failed connection."""
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_INPUT_PLM)
config_entry.add_to_hass(hass)
with patch.object(
insteon, "async_connect", new=mock_f... | [
"async",
"def",
"test_setup_entry_failed_connection",
"(",
"hass",
":",
"HomeAssistantType",
",",
"caplog",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"MOCK_USER_INPUT_PLM",
")",
"config_entry",
".",
"add_to_has... | [
210,
0
] | [
223,
66
] | python | en | ['en', 'en', 'en'] | True |
create_parameter_id | () | Create an id
Returns
-------
int
parameter id
| Create an id | def create_parameter_id():
"""Create an id
Returns
-------
int
parameter id
"""
global _next_parameter_id
_next_parameter_id += 1
return _next_parameter_id - 1 | [
"def",
"create_parameter_id",
"(",
")",
":",
"global",
"_next_parameter_id",
"_next_parameter_id",
"+=",
"1",
"return",
"_next_parameter_id",
"-",
"1"
] | [
30,
0
] | [
40,
33
] | python | en | ['en', 'gd', 'en'] | True |
create_bracket_parameter_id | (brackets_id, brackets_curr_decay, increased_id=-1) | Create a full id for a specific bracket's hyperparameter configuration
Parameters
----------
brackets_id: int
brackets id
brackets_curr_decay: int
brackets curr decay
increased_id: int
increased id
Returns
-------
int
params id
| Create a full id for a specific bracket's hyperparameter configuration | def create_bracket_parameter_id(brackets_id, brackets_curr_decay, increased_id=-1):
"""Create a full id for a specific bracket's hyperparameter configuration
Parameters
----------
brackets_id: int
brackets id
brackets_curr_decay: int
brackets curr decay
increased_id: int
... | [
"def",
"create_bracket_parameter_id",
"(",
"brackets_id",
",",
"brackets_curr_decay",
",",
"increased_id",
"=",
"-",
"1",
")",
":",
"if",
"increased_id",
"==",
"-",
"1",
":",
"increased_id",
"=",
"str",
"(",
"create_parameter_id",
"(",
")",
")",
"params_id",
"... | [
43,
0
] | [
64,
20
] | python | en | ['en', 'en', 'en'] | True |
Bracket.is_completed | (self) | check whether this bracket has sent out all the hyperparameter configurations | check whether this bracket has sent out all the hyperparameter configurations | def is_completed(self):
"""check whether this bracket has sent out all the hyperparameter configurations"""
return self.no_more_trial | [
"def",
"is_completed",
"(",
"self",
")",
":",
"return",
"self",
".",
"no_more_trial"
] | [
105,
4
] | [
107,
33
] | python | en | ['en', 'en', 'en'] | True |
Bracket.get_n_r | (self) | return the values of n and r for the next round | return the values of n and r for the next round | def get_n_r(self):
"""return the values of n and r for the next round"""
return math.floor(self.n / self.eta**self.i + _epsilon), math.floor(self.r * self.eta**self.i +_epsilon) | [
"def",
"get_n_r",
"(",
"self",
")",
":",
"return",
"math",
".",
"floor",
"(",
"self",
".",
"n",
"/",
"self",
".",
"eta",
"**",
"self",
".",
"i",
"+",
"_epsilon",
")",
",",
"math",
".",
"floor",
"(",
"self",
".",
"r",
"*",
"self",
".",
"eta",
... | [
109,
4
] | [
111,
112
] | python | en | ['en', 'en', 'en'] | True |
Bracket.increase_i | (self) | i means the ith round. Increase i by 1 | i means the ith round. Increase i by 1 | def increase_i(self):
"""i means the ith round. Increase i by 1"""
self.i += 1 | [
"def",
"increase_i",
"(",
"self",
")",
":",
"self",
".",
"i",
"+=",
"1"
] | [
113,
4
] | [
115,
19
] | python | en | ['en', 'en', 'en'] | True |
Bracket.set_config_perf | (self, i, parameter_id, seq, value) | update trial's latest result with its sequence number, e.g., epoch number or batch number
Parameters
----------
i: int
the ith round
parameter_id: int
the id of the trial/parameter
seq: int
sequence number, e.g., epoch number or batch number
... | update trial's latest result with its sequence number, e.g., epoch number or batch number | def set_config_perf(self, i, parameter_id, seq, value):
"""update trial's latest result with its sequence number, e.g., epoch number or batch number
Parameters
----------
i: int
the ith round
parameter_id: int
the id of the trial/parameter
seq: in... | [
"def",
"set_config_perf",
"(",
"self",
",",
"i",
",",
"parameter_id",
",",
"seq",
",",
"value",
")",
":",
"if",
"parameter_id",
"in",
"self",
".",
"configs_perf",
"[",
"i",
"]",
":",
"if",
"self",
".",
"configs_perf",
"[",
"i",
"]",
"[",
"parameter_id"... | [
117,
4
] | [
139,
61
] | python | en | ['en', 'en', 'en'] | True |
Bracket.inform_trial_end | (self, i) | If the trial is finished and the corresponding round (i.e., i) has all its trials finished,
it will choose the top k trials for the next round (i.e., i+1)
Parameters
----------
i: int
the ith round
Returns
-------
new trial or None:
If we... | If the trial is finished and the corresponding round (i.e., i) has all its trials finished,
it will choose the top k trials for the next round (i.e., i+1) | def inform_trial_end(self, i):
"""If the trial is finished and the corresponding round (i.e., i) has all its trials finished,
it will choose the top k trials for the next round (i.e., i+1)
Parameters
----------
i: int
the ith round
Returns
-------
... | [
"def",
"inform_trial_end",
"(",
"self",
",",
"i",
")",
":",
"global",
"_KEY",
"self",
".",
"num_finished_configs",
"[",
"i",
"]",
"+=",
"1",
"logger",
".",
"debug",
"(",
"'bracket id: %d, round: %d %d, finished: %d, all: %d'",
",",
"self",
".",
"s",
",",
"self... | [
141,
4
] | [
191,
19
] | python | en | ['en', 'en', 'en'] | True |
Bracket.get_hyperparameter_configurations | (self, num, r, config_generator) | generate num hyperparameter configurations from search space using Bayesian optimization
Parameters
----------
num: int
the number of hyperparameter configurations
Returns
-------
list
a list of hyperparameter configurations. Format: [[key1, valu... | generate num hyperparameter configurations from search space using Bayesian optimization | def get_hyperparameter_configurations(self, num, r, config_generator):
"""generate num hyperparameter configurations from search space using Bayesian optimization
Parameters
----------
num: int
the number of hyperparameter configurations
Returns
-------
... | [
"def",
"get_hyperparameter_configurations",
"(",
"self",
",",
"num",
",",
"r",
",",
"config_generator",
")",
":",
"global",
"_KEY",
"assert",
"self",
".",
"i",
"==",
"0",
"hyperparameter_configs",
"=",
"dict",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"num... | [
193,
4
] | [
215,
78
] | python | en | ['en', 'en', 'en'] | True |
Bracket._record_hyper_configs | (self, hyper_configs) | after generating one round of hyperconfigs, this function records the generated hyperconfigs,
creates a dict to record the performance when those hyperconifgs are running, set the number of finished configs
in this round to be 0, and increase the round number.
Parameters
----------
... | after generating one round of hyperconfigs, this function records the generated hyperconfigs,
creates a dict to record the performance when those hyperconifgs are running, set the number of finished configs
in this round to be 0, and increase the round number. | def _record_hyper_configs(self, hyper_configs):
"""after generating one round of hyperconfigs, this function records the generated hyperconfigs,
creates a dict to record the performance when those hyperconifgs are running, set the number of finished configs
in this round to be 0, and increase th... | [
"def",
"_record_hyper_configs",
"(",
"self",
",",
"hyper_configs",
")",
":",
"self",
".",
"hyper_configs",
".",
"append",
"(",
"hyper_configs",
")",
"self",
".",
"configs_perf",
".",
"append",
"(",
"dict",
"(",
")",
")",
"self",
".",
"num_finished_configs",
... | [
217,
4
] | [
231,
25
] | python | en | ['en', 'en', 'en'] | True |
BOHB.handle_initialize | (self, data) | Initialize Tuner, including creating Bayesian optimization-based parametric models
and search space formations
Parameters
----------
data: search space
search space of this experiment
Raises
------
ValueError
Error: Search space is None
... | Initialize Tuner, including creating Bayesian optimization-based parametric models
and search space formations | def handle_initialize(self, data):
"""Initialize Tuner, including creating Bayesian optimization-based parametric models
and search space formations
Parameters
----------
data: search space
search space of this experiment
Raises
------
ValueE... | [
"def",
"handle_initialize",
"(",
"self",
",",
"data",
")",
":",
"logger",
".",
"info",
"(",
"'start to handle_initialize'",
")",
"# convert search space jason to ConfigSpace",
"self",
".",
"handle_update_search_space",
"(",
"data",
")",
"# generate BOHB config_generator usi... | [
338,
4
] | [
369,
41
] | python | en | ['en', 'en', 'en'] | True |
BOHB.generate_new_bracket | (self) | generate a new bracket | generate a new bracket | def generate_new_bracket(self):
"""generate a new bracket"""
logger.debug(
'start to create a new SuccessiveHalving iteration, self.curr_s=%d', self.curr_s)
if self.curr_s < 0:
logger.info("s < 0, Finish this round of Hyperband in BOHB. Generate new round")
se... | [
"def",
"generate_new_bracket",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'start to create a new SuccessiveHalving iteration, self.curr_s=%d'",
",",
"self",
".",
"curr_s",
")",
"if",
"self",
".",
"curr_s",
"<",
"0",
":",
"logger",
".",
"info",
"(",
"\"... | [
371,
4
] | [
388,
69
] | python | en | ['en', 'co', 'en'] | True |
BOHB.handle_request_trial_jobs | (self, data) | recerive the number of request and generate trials
Parameters
----------
data: int
number of trial jobs that nni manager ask to generate
| recerive the number of request and generate trials | def handle_request_trial_jobs(self, data):
"""recerive the number of request and generate trials
Parameters
----------
data: int
number of trial jobs that nni manager ask to generate
"""
# Receive new request
self.credit += data
for _ in rang... | [
"def",
"handle_request_trial_jobs",
"(",
"self",
",",
"data",
")",
":",
"# Receive new request",
"self",
".",
"credit",
"+=",
"data",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"credit",
")",
":",
"self",
".",
"_request_one_trial_job",
"(",
")"
] | [
390,
4
] | [
402,
41
] | python | en | ['en', 'en', 'en'] | True |
BOHB._get_one_trial_job | (self) | get one trial job, i.e., one hyperparameter configuration.
If this function is called, Command will be sent by BOHB:
a. If there is a parameter need to run, will return "NewTrialJob" with a dict:
{
'parameter_id': id of new hyperparameter
'parameter_source': 'algorithm'
... | get one trial job, i.e., one hyperparameter configuration. | def _get_one_trial_job(self):
"""get one trial job, i.e., one hyperparameter configuration.
If this function is called, Command will be sent by BOHB:
a. If there is a parameter need to run, will return "NewTrialJob" with a dict:
{
'parameter_id': id of new hyperparameter
... | [
"def",
"_get_one_trial_job",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"generated_hyper_configs",
":",
"ret",
"=",
"{",
"'parameter_id'",
":",
"'-1_0_0'",
",",
"'parameter_source'",
":",
"'algorithm'",
",",
"'parameters'",
":",
"''",
"}",
"send",
"(",
... | [
404,
4
] | [
437,
18
] | python | en | ['en', 'pt', 'en'] | True |
BOHB._request_one_trial_job | (self) | get one trial job, i.e., one hyperparameter configuration.
If this function is called, Command will be sent by BOHB:
a. If there is a parameter need to run, will return "NewTrialJob" with a dict:
{
'parameter_id': id of new hyperparameter
'parameter_source': 'algorithm'
... | get one trial job, i.e., one hyperparameter configuration. | def _request_one_trial_job(self):
"""get one trial job, i.e., one hyperparameter configuration.
If this function is called, Command will be sent by BOHB:
a. If there is a parameter need to run, will return "NewTrialJob" with a dict:
{
'parameter_id': id of new hyperparameter... | [
"def",
"_request_one_trial_job",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"_get_one_trial_job",
"(",
")",
"if",
"ret",
"is",
"not",
"None",
":",
"send",
"(",
"CommandType",
".",
"NewTrialJob",
",",
"json_tricks",
".",
"dumps",
"(",
"ret",
")",
")"... | [
439,
4
] | [
459,
28
] | python | en | ['en', 'pt', 'en'] | True |
BOHB.handle_update_search_space | (self, data) | change json format to ConfigSpace format dict<dict> -> configspace
Parameters
----------
data: JSON object
search space of this experiment
| change json format to ConfigSpace format dict<dict> -> configspace | def handle_update_search_space(self, data):
"""change json format to ConfigSpace format dict<dict> -> configspace
Parameters
----------
data: JSON object
search space of this experiment
"""
search_space = data
cs = CS.ConfigurationSpace()
for ... | [
"def",
"handle_update_search_space",
"(",
"self",
",",
"data",
")",
":",
"search_space",
"=",
"data",
"cs",
"=",
"CS",
".",
"ConfigurationSpace",
"(",
")",
"for",
"var",
"in",
"search_space",
":",
"_type",
"=",
"str",
"(",
"search_space",
"[",
"var",
"]",
... | [
461,
4
] | [
513,
30
] | python | en | ['en', 'en', 'en'] | True |
BOHB.handle_trial_end | (self, data) | receive the information of trial end and generate next configuaration.
Parameters
----------
data: dict()
it has three keys: trial_job_id, event, hyper_params
trial_job_id: the id generated by training service
event: the job's state
hyper_params: ... | receive the information of trial end and generate next configuaration. | def handle_trial_end(self, data):
"""receive the information of trial end and generate next configuaration.
Parameters
----------
data: dict()
it has three keys: trial_job_id, event, hyper_params
trial_job_id: the id generated by training service
even... | [
"def",
"handle_trial_end",
"(",
"self",
",",
"data",
")",
":",
"logger",
".",
"debug",
"(",
"'Tuner handle trial end, result is %s'",
",",
"data",
")",
"hyper_params",
"=",
"json_tricks",
".",
"loads",
"(",
"data",
"[",
"'hyper_params'",
"]",
")",
"self",
".",... | [
515,
4
] | [
530,
61
] | python | en | ['en', 'en', 'en'] | True |
BOHB.handle_report_metric_data | (self, data) | reveice the metric data and update Bayesian optimization with final result
Parameters
----------
data:
it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'.
Raises
------
ValueError
Data type not supported
... | reveice the metric data and update Bayesian optimization with final result | def handle_report_metric_data(self, data):
"""reveice the metric data and update Bayesian optimization with final result
Parameters
----------
data:
it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'.
Raises
------
... | [
"def",
"handle_report_metric_data",
"(",
"self",
",",
"data",
")",
":",
"logger",
".",
"debug",
"(",
"'handle report metric data = %s'",
",",
"data",
")",
"if",
"'value'",
"in",
"data",
":",
"data",
"[",
"'value'",
"]",
"=",
"json_tricks",
".",
"loads",
"(",... | [
560,
4
] | [
627,
71
] | python | en | ['en', 'en', 'en'] | True |
BOHB.handle_import_data | (self, data) | Import additional data for tuning
Parameters
----------
data:
a list of dictionarys, each of which has at least two keys, 'parameter' and 'value'
Raises
------
AssertionError
data doesn't have required key 'parameter' and 'value'
| Import additional data for tuning | def handle_import_data(self, data):
"""Import additional data for tuning
Parameters
----------
data:
a list of dictionarys, each of which has at least two keys, 'parameter' and 'value'
Raises
------
AssertionError
data doesn't have requir... | [
"def",
"handle_import_data",
"(",
"self",
",",
"data",
")",
":",
"for",
"entry",
"in",
"data",
":",
"entry",
"[",
"'value'",
"]",
"=",
"json_tricks",
".",
"loads",
"(",
"entry",
"[",
"'value'",
"]",
")",
"_completed_num",
"=",
"0",
"for",
"trial_info",
... | [
632,
4
] | [
675,
71
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the eQ-3 BLE thermostats. | Set up the eQ-3 BLE thermostats. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the eQ-3 BLE thermostats."""
devices = []
for name, device_cfg in config[CONF_DEVICES].items():
mac = device_cfg[CONF_MAC]
devices.append(EQ3BTSmartThermostat(mac, name))
add_entities(devices, True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"devices",
"=",
"[",
"]",
"for",
"name",
",",
"device_cfg",
"in",
"config",
"[",
"CONF_DEVICES",
"]",
".",
"items",
"(",
")",
":",
"... | [
66,
0
] | [
74,
31
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.__init__ | (self, _mac, _name) | Initialize the thermostat. | Initialize the thermostat. | def __init__(self, _mac, _name):
"""Initialize the thermostat."""
# We want to avoid name clash with this module.
self._name = _name
self._thermostat = eq3.Thermostat(_mac) | [
"def",
"__init__",
"(",
"self",
",",
"_mac",
",",
"_name",
")",
":",
"# We want to avoid name clash with this module.",
"self",
".",
"_name",
"=",
"_name",
"self",
".",
"_thermostat",
"=",
"eq3",
".",
"Thermostat",
"(",
"_mac",
")"
] | [
80,
4
] | [
84,
47
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self):
"""Return the list of supported features."""
return SUPPORT_FLAGS | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_FLAGS"
] | [
87,
4
] | [
89,
28
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.available | (self) | Return if thermostat is available. | Return if thermostat is available. | def available(self) -> bool:
"""Return if thermostat is available."""
return self._thermostat.mode >= 0 | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_thermostat",
".",
"mode",
">=",
"0"
] | [
92,
4
] | [
94,
41
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
97,
4
] | [
99,
25
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.temperature_unit | (self) | Return the unit of measurement that is used. | Return the unit of measurement that is used. | def temperature_unit(self):
"""Return the unit of measurement that is used."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"TEMP_CELSIUS"
] | [
102,
4
] | [
104,
27
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.precision | (self) | Return eq3bt's precision 0.5. | Return eq3bt's precision 0.5. | def precision(self):
"""Return eq3bt's precision 0.5."""
return PRECISION_HALVES | [
"def",
"precision",
"(",
"self",
")",
":",
"return",
"PRECISION_HALVES"
] | [
107,
4
] | [
109,
31
] | python | en | ['en', 'cy', 'en'] | True |
EQ3BTSmartThermostat.current_temperature | (self) | Can not report temperature, so return target_temperature. | Can not report temperature, so return target_temperature. | def current_temperature(self):
"""Can not report temperature, so return target_temperature."""
return self.target_temperature | [
"def",
"current_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"target_temperature"
] | [
112,
4
] | [
114,
38
] | python | en | ['en', 'la', 'en'] | True |
EQ3BTSmartThermostat.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self):
"""Return the temperature we try to reach."""
return self._thermostat.target_temperature | [
"def",
"target_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"_thermostat",
".",
"target_temperature"
] | [
117,
4
] | [
119,
50
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | def set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is None:
return
self._thermostat.target_temperature = temperature | [
"def",
"set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"temperature",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"if",
"temperature",
"is",
"None",
":",
"return",
"self",
".",
"_thermostat",
".",
"target_temperature",
"=",
... | [
121,
4
] | [
126,
57
] | python | en | ['en', 'ca', 'en'] | True |
EQ3BTSmartThermostat.hvac_mode | (self) | Return the current operation mode. | Return the current operation mode. | def hvac_mode(self):
"""Return the current operation mode."""
if self._thermostat.mode < 0:
return HVAC_MODE_OFF
return EQ_TO_HA_HVAC[self._thermostat.mode] | [
"def",
"hvac_mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"_thermostat",
".",
"mode",
"<",
"0",
":",
"return",
"HVAC_MODE_OFF",
"return",
"EQ_TO_HA_HVAC",
"[",
"self",
".",
"_thermostat",
".",
"mode",
"]"
] | [
129,
4
] | [
133,
51
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.hvac_modes | (self) | Return the list of available operation modes. | Return the list of available operation modes. | def hvac_modes(self):
"""Return the list of available operation modes."""
return list(HA_TO_EQ_HVAC) | [
"def",
"hvac_modes",
"(",
"self",
")",
":",
"return",
"list",
"(",
"HA_TO_EQ_HVAC",
")"
] | [
136,
4
] | [
138,
34
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.set_hvac_mode | (self, hvac_mode) | Set operation mode. | Set operation mode. | def set_hvac_mode(self, hvac_mode):
"""Set operation mode."""
if self.preset_mode:
return
self._thermostat.mode = HA_TO_EQ_HVAC[hvac_mode] | [
"def",
"set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
")",
":",
"if",
"self",
".",
"preset_mode",
":",
"return",
"self",
".",
"_thermostat",
".",
"mode",
"=",
"HA_TO_EQ_HVAC",
"[",
"hvac_mode",
"]"
] | [
140,
4
] | [
144,
56
] | python | en | ['nl', 'ny', 'en'] | False |
EQ3BTSmartThermostat.min_temp | (self) | Return the minimum temperature. | Return the minimum temperature. | def min_temp(self):
"""Return the minimum temperature."""
return self._thermostat.min_temp | [
"def",
"min_temp",
"(",
"self",
")",
":",
"return",
"self",
".",
"_thermostat",
".",
"min_temp"
] | [
147,
4
] | [
149,
40
] | python | en | ['en', 'la', 'en'] | True |
EQ3BTSmartThermostat.max_temp | (self) | Return the maximum temperature. | Return the maximum temperature. | def max_temp(self):
"""Return the maximum temperature."""
return self._thermostat.max_temp | [
"def",
"max_temp",
"(",
"self",
")",
":",
"return",
"self",
".",
"_thermostat",
".",
"max_temp"
] | [
152,
4
] | [
154,
40
] | python | en | ['en', 'la', 'en'] | True |
EQ3BTSmartThermostat.device_state_attributes | (self) | Return the device specific state attributes. | Return the device specific state attributes. | def device_state_attributes(self):
"""Return the device specific state attributes."""
dev_specific = {
ATTR_STATE_AWAY_END: self._thermostat.away_end,
ATTR_STATE_LOCKED: self._thermostat.locked,
ATTR_STATE_LOW_BAT: self._thermostat.low_battery,
ATTR_STATE_... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"dev_specific",
"=",
"{",
"ATTR_STATE_AWAY_END",
":",
"self",
".",
"_thermostat",
".",
"away_end",
",",
"ATTR_STATE_LOCKED",
":",
"self",
".",
"_thermostat",
".",
"locked",
",",
"ATTR_STATE_LOW_BAT",
":",
... | [
157,
4
] | [
167,
27
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.preset_mode | (self) | Return the current preset mode, e.g., home, away, temp.
Requires SUPPORT_PRESET_MODE.
| Return the current preset mode, e.g., home, away, temp. | def preset_mode(self):
"""Return the current preset mode, e.g., home, away, temp.
Requires SUPPORT_PRESET_MODE.
"""
return EQ_TO_HA_PRESET.get(self._thermostat.mode) | [
"def",
"preset_mode",
"(",
"self",
")",
":",
"return",
"EQ_TO_HA_PRESET",
".",
"get",
"(",
"self",
".",
"_thermostat",
".",
"mode",
")"
] | [
170,
4
] | [
175,
57
] | python | en | ['en', 'pt', 'en'] | True |
EQ3BTSmartThermostat.preset_modes | (self) | Return a list of available preset modes.
Requires SUPPORT_PRESET_MODE.
| Return a list of available preset modes. | def preset_modes(self):
"""Return a list of available preset modes.
Requires SUPPORT_PRESET_MODE.
"""
return list(HA_TO_EQ_PRESET) | [
"def",
"preset_modes",
"(",
"self",
")",
":",
"return",
"list",
"(",
"HA_TO_EQ_PRESET",
")"
] | [
178,
4
] | [
183,
36
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.set_preset_mode | (self, preset_mode) | Set new preset mode. | Set new preset mode. | def set_preset_mode(self, preset_mode):
"""Set new preset mode."""
if preset_mode == PRESET_NONE:
self.set_hvac_mode(HVAC_MODE_HEAT)
self._thermostat.mode = HA_TO_EQ_PRESET[preset_mode] | [
"def",
"set_preset_mode",
"(",
"self",
",",
"preset_mode",
")",
":",
"if",
"preset_mode",
"==",
"PRESET_NONE",
":",
"self",
".",
"set_hvac_mode",
"(",
"HVAC_MODE_HEAT",
")",
"self",
".",
"_thermostat",
".",
"mode",
"=",
"HA_TO_EQ_PRESET",
"[",
"preset_mode",
"... | [
185,
4
] | [
189,
60
] | python | en | ['en', 'sr', 'en'] | True |
EQ3BTSmartThermostat.update | (self) | Update the data from the thermostat. | Update the data from the thermostat. | def update(self):
"""Update the data from the thermostat."""
try:
self._thermostat.update()
except BTLEException as ex:
_LOGGER.warning("Updating the state failed: %s", ex) | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_thermostat",
".",
"update",
"(",
")",
"except",
"BTLEException",
"as",
"ex",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Updating the state failed: %s\"",
",",
"ex",
")"
] | [
191,
4
] | [
197,
64
] | python | en | ['en', 'en', 'en'] | True |
test_calling_intent | (hass) | Test calling an intent from a conversation. | Test calling an intent from a conversation. | async def test_calling_intent(hass):
"""Test calling an intent from a conversation."""
intents = async_mock_intent(hass, "OrderBeer")
result = await async_setup_component(hass, "homeassistant", {})
assert result
result = await async_setup_component(
hass,
"conversation",
{"... | [
"async",
"def",
"test_calling_intent",
"(",
"hass",
")",
":",
"intents",
"=",
"async_mock_intent",
"(",
"hass",
",",
"\"OrderBeer\"",
")",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"assert",
"re... | [
11,
0
] | [
41,
36
] | python | en | ['en', 'lb', 'en'] | True |
test_register_before_setup | (hass) | Test calling an intent from a conversation. | Test calling an intent from a conversation. | async def test_register_before_setup(hass):
"""Test calling an intent from a conversation."""
intents = async_mock_intent(hass, "OrderBeer")
hass.components.conversation.async_register("OrderBeer", ["A {type} beer, please"])
result = await async_setup_component(
hass,
"conversation",
... | [
"async",
"def",
"test_register_before_setup",
"(",
"hass",
")",
":",
"intents",
"=",
"async_mock_intent",
"(",
"hass",
",",
"\"OrderBeer\"",
")",
"hass",
".",
"components",
".",
"conversation",
".",
"async_register",
"(",
"\"OrderBeer\"",
",",
"[",
"\"A {type} bee... | [
44,
0
] | [
81,
63
] | python | en | ['en', 'lb', 'en'] | True |
test_http_processing_intent | (hass, hass_client, hass_admin_user) | Test processing intent via HTTP API. | Test processing intent via HTTP API. | async def test_http_processing_intent(hass, hass_client, hass_admin_user):
"""Test processing intent via HTTP API."""
class TestIntentHandler(intent.IntentHandler):
"""Test Intent Handler."""
intent_type = "OrderBeer"
async def async_handle(self, intent):
"""Handle the int... | [
"async",
"def",
"test_http_processing_intent",
"(",
"hass",
",",
"hass_client",
",",
"hass_admin_user",
")",
":",
"class",
"TestIntentHandler",
"(",
"intent",
".",
"IntentHandler",
")",
":",
"\"\"\"Test Intent Handler.\"\"\"",
"intent_type",
"=",
"\"OrderBeer\"",
"async... | [
84,
0
] | [
126,
5
] | python | en | ['en', 'pt', 'en'] | True |
test_turn_on_intent | (hass, sentence) | Test calling the turn on intent. | Test calling the turn on intent. | async def test_turn_on_intent(hass, sentence):
"""Test calling the turn on intent."""
result = await async_setup_component(hass, "homeassistant", {})
assert result
result = await async_setup_component(hass, "conversation", {})
assert result
hass.states.async_set("light.kitchen", "off")
cal... | [
"async",
"def",
"test_turn_on_intent",
"(",
"hass",
",",
"sentence",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"assert",
"result",
"result",
"=",
"await",
"async_setup_component",
"(",
... | [
130,
0
] | [
150,
54
] | python | en | ['en', 'en', 'en'] | True |
test_turn_off_intent | (hass, sentence) | Test calling the turn on intent. | Test calling the turn on intent. | async def test_turn_off_intent(hass, sentence):
"""Test calling the turn on intent."""
result = await async_setup_component(hass, "homeassistant", {})
assert result
result = await async_setup_component(hass, "conversation", {})
assert result
hass.states.async_set("light.kitchen", "on")
cal... | [
"async",
"def",
"test_turn_off_intent",
"(",
"hass",
",",
"sentence",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"assert",
"result",
"result",
"=",
"await",
"async_setup_component",
"(",
... | [
154,
0
] | [
174,
54
] | python | en | ['en', 'en', 'en'] | True |
test_toggle_intent | (hass, sentence) | Test calling the turn on intent. | Test calling the turn on intent. | async def test_toggle_intent(hass, sentence):
"""Test calling the turn on intent."""
result = await async_setup_component(hass, "homeassistant", {})
assert result
result = await async_setup_component(hass, "conversation", {})
assert result
hass.states.async_set("light.kitchen", "on")
calls... | [
"async",
"def",
"test_toggle_intent",
"(",
"hass",
",",
"sentence",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"assert",
"result",
"result",
"=",
"await",
"async_setup_component",
"(",
... | [
178,
0
] | [
198,
54
] | python | en | ['en', 'en', 'en'] | True |
test_http_api | (hass, hass_client) | Test the HTTP conversation API. | Test the HTTP conversation API. | async def test_http_api(hass, hass_client):
"""Test the HTTP conversation API."""
assert await async_setup_component(hass, "homeassistant", {})
assert await async_setup_component(hass, "conversation", {})
assert await async_setup_component(hass, "intent", {})
client = await hass_client()
hass.s... | [
"async",
"def",
"test_http_api",
"(",
"hass",
",",
"hass_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"conversation\"",
"... | [
201,
0
] | [
220,
54
] | python | en | ['en', 'sd', 'en'] | True |
test_http_api_wrong_data | (hass, hass_client) | Test the HTTP conversation API. | Test the HTTP conversation API. | async def test_http_api_wrong_data(hass, hass_client):
"""Test the HTTP conversation API."""
result = await async_setup_component(hass, "homeassistant", {})
assert result
result = await async_setup_component(hass, "conversation", {})
assert result
client = await hass_client()
resp = await... | [
"async",
"def",
"test_http_api_wrong_data",
"(",
"hass",
",",
"hass_client",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"assert",
"result",
"result",
"=",
"await",
"async_setup_component",
... | [
223,
0
] | [
237,
29
] | python | en | ['en', 'sd', 'en'] | True |
test_custom_agent | (hass, hass_client, hass_admin_user) | Test a custom conversation agent. | Test a custom conversation agent. | async def test_custom_agent(hass, hass_client, hass_admin_user):
"""Test a custom conversation agent."""
calls = []
class MyAgent(conversation.AbstractConversationAgent):
"""Test Agent."""
async def async_process(self, text, context, conversation_id):
"""Process some text."""
... | [
"async",
"def",
"test_custom_agent",
"(",
"hass",
",",
"hass_client",
",",
"hass_admin_user",
")",
":",
"calls",
"=",
"[",
"]",
"class",
"MyAgent",
"(",
"conversation",
".",
"AbstractConversationAgent",
")",
":",
"\"\"\"Test Agent.\"\"\"",
"async",
"def",
"async_p... | [
240,
0
] | [
274,
40
] | python | en | ['pt', 'lb', 'en'] | False |
always_mock_weather | (mock_weather) | Mock the Met weather provider. | Mock the Met weather provider. | def always_mock_weather(mock_weather): # noqa: F811
"""Mock the Met weather provider."""
pass | [
"def",
"always_mock_weather",
"(",
"mock_weather",
")",
":",
"# noqa: F811",
"pass"
] | [
19,
0
] | [
21,
8
] | python | en | ['en', 'nl', 'en'] | True |
auth_active | (hass) | Ensure auth is always active. | Ensure auth is always active. | def auth_active(hass):
"""Ensure auth is always active."""
hass.loop.run_until_complete(
register_auth_provider(hass, {"type": "homeassistant"})
) | [
"def",
"auth_active",
"(",
"hass",
")",
":",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"register_auth_provider",
"(",
"hass",
",",
"{",
"\"type\"",
":",
"\"homeassistant\"",
"}",
")",
")"
] | [
25,
0
] | [
29,
5
] | python | en | ['en', 'en', 'en'] | True |
rpi_fixture | (hass, aioclient_mock, mock_supervisor) | Mock core info with rpi. | Mock core info with rpi. | async def rpi_fixture(hass, aioclient_mock, mock_supervisor):
"""Mock core info with rpi."""
aioclient_mock.get(
"http://127.0.0.1/core/info",
json={
"result": "ok",
"data": {"version_latest": "1.0.0", "machine": "raspberrypi3"},
},
)
assert await async_se... | [
"async",
"def",
"rpi_fixture",
"(",
"hass",
",",
"aioclient_mock",
",",
"mock_supervisor",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://127.0.0.1/core/info\"",
",",
"json",
"=",
"{",
"\"result\"",
":",
"\"ok\"",
",",
"\"data\"",
":",
"{",
"\"version_la... | [
33,
0
] | [
43,
38
] | python | en | ['en', 'en', 'en'] | True |
no_rpi_fixture | (hass, aioclient_mock, mock_supervisor) | Mock core info with rpi. | Mock core info with rpi. | async def no_rpi_fixture(hass, aioclient_mock, mock_supervisor):
"""Mock core info with rpi."""
aioclient_mock.get(
"http://127.0.0.1/core/info",
json={
"result": "ok",
"data": {"version_latest": "1.0.0", "machine": "odroid-n2"},
},
)
assert await async_se... | [
"async",
"def",
"no_rpi_fixture",
"(",
"hass",
",",
"aioclient_mock",
",",
"mock_supervisor",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://127.0.0.1/core/info\"",
",",
"json",
"=",
"{",
"\"result\"",
":",
"\"ok\"",
",",
"\"data\"",
":",
"{",
"\"version... | [
47,
0
] | [
57,
38
] | python | en | ['en', 'en', 'en'] | True |
mock_supervisor_fixture | (hass, aioclient_mock) | Mock supervisor. | Mock supervisor. | async def mock_supervisor_fixture(hass, aioclient_mock):
"""Mock supervisor."""
aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"})
aioclient_mock.post("http://127.0.0.1/supervisor/options", json={"result": "ok"})
with patch.dict(os.environ, {"HASSIO": "127.0.0.1"}), pat... | [
"async",
"def",
"mock_supervisor_fixture",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"\"http://127.0.0.1/homeassistant/options\"",
",",
"json",
"=",
"{",
"\"result\"",
":",
"\"ok\"",
"}",
")",
"aioclient_mock",
".",
"post",
... | [
61,
0
] | [
86,
13
] | python | en | ['es', 'no', 'en'] | False |
test_onboarding_progress | (hass, hass_storage, aiohttp_client) | Test fetching progress. | Test fetching progress. | async def test_onboarding_progress(hass, hass_storage, aiohttp_client):
"""Test fetching progress."""
mock_storage(hass_storage, {"done": ["hello"]})
assert await async_setup_component(hass, "onboarding", {})
await hass.async_block_till_done()
client = await aiohttp_client(hass.http.app)
with... | [
"async",
"def",
"test_onboarding_progress",
"(",
"hass",
",",
"hass_storage",
",",
"aiohttp_client",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"\"hello\"",
"]",
"}",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass... | [
89,
0
] | [
105,
54
] | python | en | ['en', 'ny', 'en'] | True |
test_onboarding_user_already_done | (hass, hass_storage, aiohttp_client) | Test creating a new user when user step already done. | Test creating a new user when user step already done. | async def test_onboarding_user_already_done(hass, hass_storage, aiohttp_client):
"""Test creating a new user when user step already done."""
mock_storage(hass_storage, {"done": [views.STEP_USER]})
with patch.object(onboarding, "STEPS", ["hello", "world"]):
assert await async_setup_component(hass, "... | [
"async",
"def",
"test_onboarding_user_already_done",
"(",
"hass",
",",
"hass_storage",
",",
"aiohttp_client",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"views",
".",
"STEP_USER",
"]",
"}",
")",
"with",
"patch",
".",
"object... | [
108,
0
] | [
129,
40
] | python | en | ['en', 'en', 'en'] | True |
test_onboarding_user | (hass, hass_storage, aiohttp_client) | Test creating a new user. | Test creating a new user. | async def test_onboarding_user(hass, hass_storage, aiohttp_client):
"""Test creating a new user."""
assert await async_setup_component(hass, "person", {})
assert await async_setup_component(hass, "onboarding", {})
await hass.async_block_till_done()
client = await aiohttp_client(hass.http.app)
... | [
"async",
"def",
"test_onboarding_user",
"(",
"hass",
",",
"hass_storage",
",",
"aiohttp_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"person\"",
",",
"{",
"}",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",... | [
132,
0
] | [
189,
5
] | python | en | ['en', 'en', 'en'] | True |
test_onboarding_user_invalid_name | (hass, hass_storage, aiohttp_client) | Test not providing name. | Test not providing name. | async def test_onboarding_user_invalid_name(hass, hass_storage, aiohttp_client):
"""Test not providing name."""
mock_storage(hass_storage, {"done": []})
assert await async_setup_component(hass, "onboarding", {})
await hass.async_block_till_done()
client = await aiohttp_client(hass.http.app)
r... | [
"async",
"def",
"test_onboarding_user_invalid_name",
"(",
"hass",
",",
"hass_storage",
",",
"aiohttp_client",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"]",
"}",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
"... | [
192,
0
] | [
211,
29
] | python | en | ['en', 'sq', 'en'] | True |
test_onboarding_user_race | (hass, hass_storage, aiohttp_client) | Test race condition on creating new user. | Test race condition on creating new user. | async def test_onboarding_user_race(hass, hass_storage, aiohttp_client):
"""Test race condition on creating new user."""
mock_storage(hass_storage, {"done": ["hello"]})
assert await async_setup_component(hass, "onboarding", {})
await hass.async_block_till_done()
client = await aiohttp_client(hass.... | [
"async",
"def",
"test_onboarding_user_race",
"(",
"hass",
",",
"hass_storage",
",",
"aiohttp_client",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"\"hello\"",
"]",
"}",
")",
"assert",
"await",
"async_setup_component",
"(",
"has... | [
214,
0
] | [
246,
70
] | python | en | ['en', 'en', 'en'] | True |
test_onboarding_integration | (hass, hass_storage, hass_client) | Test finishing integration step. | Test finishing integration step. | async def test_onboarding_integration(hass, hass_storage, hass_client):
"""Test finishing integration step."""
mock_storage(hass_storage, {"done": [const.STEP_USER]})
assert await async_setup_component(hass, "onboarding", {})
await hass.async_block_till_done()
client = await hass_client()
res... | [
"async",
"def",
"test_onboarding_integration",
"(",
"hass",
",",
"hass_storage",
",",
"hass_client",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"const",
".",
"STEP_USER",
"]",
"}",
")",
"assert",
"await",
"async_setup_componen... | [
249,
0
] | [
287,
50
] | python | en | ['en', 'da', 'en'] | True |
test_onboarding_integration_invalid_redirect_uri | (
hass, hass_storage, hass_client
) | Test finishing integration step. | Test finishing integration step. | async def test_onboarding_integration_invalid_redirect_uri(
hass, hass_storage, hass_client
):
"""Test finishing integration step."""
mock_storage(hass_storage, {"done": [const.STEP_USER]})
assert await async_setup_component(hass, "onboarding", {})
await hass.async_block_till_done()
client = a... | [
"async",
"def",
"test_onboarding_integration_invalid_redirect_uri",
"(",
"hass",
",",
"hass_storage",
",",
"hass_client",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"const",
".",
"STEP_USER",
"]",
"}",
")",
"assert",
"await",
... | [
290,
0
] | [
313,
50
] | python | en | ['en', 'da', 'en'] | True |
test_onboarding_integration_requires_auth | (hass, hass_storage, aiohttp_client) | Test finishing integration step. | Test finishing integration step. | async def test_onboarding_integration_requires_auth(hass, hass_storage, aiohttp_client):
"""Test finishing integration step."""
mock_storage(hass_storage, {"done": [const.STEP_USER]})
assert await async_setup_component(hass, "onboarding", {})
await hass.async_block_till_done()
client = await aioht... | [
"async",
"def",
"test_onboarding_integration_requires_auth",
"(",
"hass",
",",
"hass_storage",
",",
"aiohttp_client",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"const",
".",
"STEP_USER",
"]",
"}",
")",
"assert",
"await",
"asy... | [
316,
0
] | [
329,
29
] | python | en | ['en', 'da', 'en'] | True |
test_onboarding_core_sets_up_met | (hass, hass_storage, hass_client) | Test finishing the core step. | Test finishing the core step. | async def test_onboarding_core_sets_up_met(hass, hass_storage, hass_client):
"""Test finishing the core step."""
mock_storage(hass_storage, {"done": [const.STEP_USER]})
assert await async_setup_component(hass, "onboarding", {})
await hass.async_block_till_done()
client = await hass_client()
r... | [
"async",
"def",
"test_onboarding_core_sets_up_met",
"(",
"hass",
",",
"hass_storage",
",",
"hass_client",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"const",
".",
"STEP_USER",
"]",
"}",
")",
"assert",
"await",
"async_setup_com... | [
332,
0
] | [
346,
60
] | python | en | ['en', 'en', 'en'] | True |
test_onboarding_core_sets_up_rpi_power | (
hass, hass_storage, hass_client, aioclient_mock, rpi
) | Test that the core step sets up rpi_power on RPi. | Test that the core step sets up rpi_power on RPi. | async def test_onboarding_core_sets_up_rpi_power(
hass, hass_storage, hass_client, aioclient_mock, rpi
):
"""Test that the core step sets up rpi_power on RPi."""
mock_storage(hass_storage, {"done": [const.STEP_USER]})
await async_setup_component(hass, "persistent_notification", {})
assert await asy... | [
"async",
"def",
"test_onboarding_core_sets_up_rpi_power",
"(",
"hass",
",",
"hass_storage",
",",
"hass_client",
",",
"aioclient_mock",
",",
"rpi",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"const",
".",
"STEP_USER",
"]",
"}",... | [
349,
0
] | [
371,
26
] | python | en | ['en', 'en', 'en'] | True |
test_onboarding_core_no_rpi_power | (
hass, hass_storage, hass_client, aioclient_mock, no_rpi
) | Test that the core step do not set up rpi_power on non RPi. | Test that the core step do not set up rpi_power on non RPi. | async def test_onboarding_core_no_rpi_power(
hass, hass_storage, hass_client, aioclient_mock, no_rpi
):
"""Test that the core step do not set up rpi_power on non RPi."""
mock_storage(hass_storage, {"done": [const.STEP_USER]})
await async_setup_component(hass, "persistent_notification", {})
assert a... | [
"async",
"def",
"test_onboarding_core_no_rpi_power",
"(",
"hass",
",",
"hass_storage",
",",
"hass_client",
",",
"aioclient_mock",
",",
"no_rpi",
")",
":",
"mock_storage",
"(",
"hass_storage",
",",
"{",
"\"done\"",
":",
"[",
"const",
".",
"STEP_USER",
"]",
"}",
... | [
374,
0
] | [
396,
30
] | python | en | ['en', 'en', 'en'] | True |
mocked_opnsense | () | Mock for pyopnense.diagnostics. | Mock for pyopnense.diagnostics. | def mocked_opnsense():
"""Mock for pyopnense.diagnostics."""
with mock.patch.object(opnsense, "diagnostics") as mocked_opn:
yield mocked_opn | [
"def",
"mocked_opnsense",
"(",
")",
":",
"with",
"mock",
".",
"patch",
".",
"object",
"(",
"opnsense",
",",
"\"diagnostics\"",
")",
"as",
"mocked_opn",
":",
"yield",
"mocked_opn"
] | [
13,
0
] | [
16,
24
] | python | en | ['en', 'it', 'en'] | True |
test_get_scanner | (hass, mocked_opnsense, mock_device_tracker_conf) | Test creating an opnsense scanner. | Test creating an opnsense scanner. | async def test_get_scanner(hass, mocked_opnsense, mock_device_tracker_conf):
"""Test creating an opnsense scanner."""
interface_client = mock.MagicMock()
mocked_opnsense.InterfaceClient.return_value = interface_client
interface_client.get_arp.return_value = [
{
"hostname": "",
... | [
"async",
"def",
"test_get_scanner",
"(",
"hass",
",",
"mocked_opnsense",
",",
"mock_device_tracker_conf",
")",
":",
"interface_client",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"mocked_opnsense",
".",
"InterfaceClient",
".",
"return_value",
"=",
"interface_client",
... | [
19,
0
] | [
63,
35
] | python | en | ['en', 'lb', 'en'] | True |
checkCopyright | (f) |
Checks for copyright headers and their years
|
Checks for copyright headers and their years
| def checkCopyright(f):
"""
Checks for copyright headers and their years
"""
errs = []
thisYear = datetime.datetime.now().year
lineNum = 0
crFound = False
yearMatched = False
fp = open(f, "r")
for line in fp.readlines():
lineNum += 1
start, end = getCopyrightYears(... | [
"def",
"checkCopyright",
"(",
"f",
")",
":",
"errs",
"=",
"[",
"]",
"thisYear",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"year",
"lineNum",
"=",
"0",
"crFound",
"=",
"False",
"yearMatched",
"=",
"False",
"fp",
"=",
"open",
"(",
... | [
50,
0
] | [
79,
15
] | python | en | ['en', 'error', 'th'] | False |
checkCopyrightForAll | () |
Checks for copyright headers in all the modified files. In case of local
repo, this script will just look for uncommitted files and in case of CI
it compares between branches "$PR_TARGET_BRANCH" and "current-pr-branch"
|
Checks for copyright headers in all the modified files. In case of local
repo, this script will just look for uncommitted files and in case of CI
it compares between branches "$PR_TARGET_BRANCH" and "current-pr-branch"
| def checkCopyrightForAll():
"""
Checks for copyright headers in all the modified files. In case of local
repo, this script will just look for uncommitted files and in case of CI
it compares between branches "$PR_TARGET_BRANCH" and "current-pr-branch"
"""
files = gitutils.modifiedFiles(filter=che... | [
"def",
"checkCopyrightForAll",
"(",
")",
":",
"files",
"=",
"gitutils",
".",
"modifiedFiles",
"(",
"filter",
"=",
"checkThisFile",
")",
"errors",
"=",
"[",
"]",
"for",
"f",
"in",
"files",
":",
"errors",
"+=",
"checkCopyright",
"(",
"f",
")",
"if",
"len",... | [
82,
0
] | [
99,
39
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass, config) | Set up the Flu Near You component. | Set up the Flu Near You component. | async def async_setup(hass, config):
"""Set up the Flu Near You component."""
hass.data[DOMAIN] = {DATA_COORDINATOR: {}}
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"DATA_COORDINATOR",
":",
"{",
"}",
"}",
"return",
"True"
] | [
27,
0
] | [
30,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up Flu Near You as config entry. | Set up Flu Near You as config entry. | async def async_setup_entry(hass, config_entry):
"""Set up Flu Near You as config entry."""
hass.data[DOMAIN][DATA_COORDINATOR][config_entry.entry_id] = {}
websession = aiohttp_client.async_get_clientsession(hass)
client = Client(websession)
latitude = config_entry.data.get(CONF_LATITUDE, hass.con... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_COORDINATOR",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"=",
"{",
"}",
"websession",
"=",
"aiohttp_client",
".",
"asy... | [
33,
0
] | [
74,
15
] | python | en | ['en', 'pt', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload an Flu Near You config entry. | Unload an Flu Near You config entry. | async def async_unload_entry(hass, config_entry):
"""Unload an Flu Near You config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(config_entry, component)
for component in PLATFORMS
]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"config_entry",
",",
"compo... | [
77,
0
] | [
90,
20
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistantType, config: Dict) | Set up the Roku integration. | Set up the Roku integration. | async def async_setup(hass: HomeAssistantType, config: Dict) -> bool:
"""Set up the Roku integration."""
hass.data.setdefault(DOMAIN, {})
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"Dict",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"return",
"True"
] | [
39,
0
] | [
42,
15
] | python | en | ['en', 'su', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Set up Roku from a config entry. | Set up Roku from a config entry. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Set up Roku from a config entry."""
coordinator = RokuDataUpdateCoordinator(hass, host=entry.data[CONF_HOST])
await coordinator.async_refresh()
if not coordinator.last_update_success:
raise ConfigEntryNotReady
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"coordinator",
"=",
"RokuDataUpdateCoordinator",
"(",
"hass",
",",
"host",
"=",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
... | [
45,
0
] | [
60,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"asyn... | [
63,
0
] | [
77,
20
] | python | en | ['en', 'es', 'en'] | True |
roku_exception_handler | (func) | Decorate Roku calls to handle Roku exceptions. | Decorate Roku calls to handle Roku exceptions. | def roku_exception_handler(func):
"""Decorate Roku calls to handle Roku exceptions."""
async def handler(self, *args, **kwargs):
try:
await func(self, *args, **kwargs)
except RokuConnectionError as error:
if self.available:
_LOGGER.error("Error communicat... | [
"def",
"roku_exception_handler",
"(",
"func",
")",
":",
"async",
"def",
"handler",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"await",
"func",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",... | [
80,
0
] | [
93,
18
] | python | en | ['en', 'en', 'en'] | True |
RokuDataUpdateCoordinator.__init__ | (
self,
hass: HomeAssistantType,
*,
host: str,
) | Initialize global Roku data updater. | Initialize global Roku data updater. | def __init__(
self,
hass: HomeAssistantType,
*,
host: str,
):
"""Initialize global Roku data updater."""
self.roku = Roku(host=host, session=async_get_clientsession(hass))
self.full_update_interval = timedelta(minutes=15)
self.last_full_update = None
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
",",
"*",
",",
"host",
":",
"str",
",",
")",
":",
"self",
".",
"roku",
"=",
"Roku",
"(",
"host",
"=",
"host",
",",
"session",
"=",
"async_get_clientsession",
"(",
"hass",
")",
")"... | [
99,
4
] | [
116,
9
] | python | co | ['en', 'co', 'it'] | False |
RokuDataUpdateCoordinator._async_update_data | (self) | Fetch data from Roku. | Fetch data from Roku. | async def _async_update_data(self) -> Device:
"""Fetch data from Roku."""
full_update = self.last_full_update is None or utcnow() >= (
self.last_full_update + self.full_update_interval
)
try:
data = await self.roku.update(full_update=full_update)
if ... | [
"async",
"def",
"_async_update_data",
"(",
"self",
")",
"->",
"Device",
":",
"full_update",
"=",
"self",
".",
"last_full_update",
"is",
"None",
"or",
"utcnow",
"(",
")",
">=",
"(",
"self",
".",
"last_full_update",
"+",
"self",
".",
"full_update_interval",
")... | [
118,
4
] | [
132,
80
] | python | en | ['en', 'en', 'en'] | True |
RokuEntity.__init__ | (
self, *, device_id: str, name: str, coordinator: RokuDataUpdateCoordinator
) | Initialize the Roku entity. | Initialize the Roku entity. | def __init__(
self, *, device_id: str, name: str, coordinator: RokuDataUpdateCoordinator
) -> None:
"""Initialize the Roku entity."""
super().__init__(coordinator)
self._device_id = device_id
self._name = name | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"device_id",
":",
"str",
",",
"name",
":",
"str",
",",
"coordinator",
":",
"RokuDataUpdateCoordinator",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_d... | [
138,
4
] | [
144,
25
] | python | en | ['en', 'pl', 'en'] | True |
RokuEntity.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> str:
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
147,
4
] | [
149,
25
] | python | en | ['en', 'en', 'en'] | True |
RokuEntity.device_info | (self) | Return device information about this Roku device. | Return device information about this Roku device. | def device_info(self) -> Dict[str, Any]:
"""Return device information about this Roku device."""
if self._device_id is None:
return None
return {
ATTR_IDENTIFIERS: {(DOMAIN, self._device_id)},
ATTR_NAME: self.name,
ATTR_MANUFACTURER: self.coordina... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"self",
".",
"_device_id",
"is",
"None",
":",
"return",
"None",
"return",
"{",
"ATTR_IDENTIFIERS",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device_id",
... | [
152,
4
] | [
163,
9
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discover_info=None) | Set up the CMUS platform. | Set up the CMUS platform. | def setup_platform(hass, config, add_entities, discover_info=None):
"""Set up the CMUS platform."""
host = config.get(CONF_HOST)
password = config.get(CONF_PASSWORD)
port = config[CONF_PORT]
name = config[CONF_NAME]
try:
cmus_remote = CmusDevice(host, password, port, name)
except e... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discover_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"password",
"=",
"config",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"port",
"="... | [
58,
0
] | [
71,
37
] | python | en | ['en', 'lv', 'en'] | True |
CmusDevice.__init__ | (self, server, password, port, name) | Initialize the CMUS device. | Initialize the CMUS device. | def __init__(self, server, password, port, name):
"""Initialize the CMUS device."""
if server:
self.cmus = remote.PyCmus(server=server, password=password, port=port)
auto_name = f"cmus-{server}"
else:
self.cmus = remote.PyCmus()
auto_name = "cmus-... | [
"def",
"__init__",
"(",
"self",
",",
"server",
",",
"password",
",",
"port",
",",
"name",
")",
":",
"if",
"server",
":",
"self",
".",
"cmus",
"=",
"remote",
".",
"PyCmus",
"(",
"server",
"=",
"server",
",",
"password",
"=",
"password",
",",
"port",
... | [
78,
4
] | [
88,
24
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.update | (self) | Get the latest data and update the state. | Get the latest data and update the state. | def update(self):
"""Get the latest data and update the state."""
status = self.cmus.get_status_dict()
if not status:
_LOGGER.warning("Received no status from cmus")
else:
self.status = status | [
"def",
"update",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"cmus",
".",
"get_status_dict",
"(",
")",
"if",
"not",
"status",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Received no status from cmus\"",
")",
"else",
":",
"self",
".",
"status",
"=",
"s... | [
90,
4
] | [
96,
32
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.