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
SmartThingsThreeAxisSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" three_axis = self._device.status.attributes[Attribute.three_axis].value try: return three_axis[self._index] except (TypeError, IndexError): return None
[ "def", "state", "(", "self", ")", ":", "three_axis", "=", "self", ".", "_device", ".", "status", ".", "attributes", "[", "Attribute", ".", "three_axis", "]", ".", "value", "try", ":", "return", "three_axis", "[", "self", ".", "_index", "]", "except", "...
[ 365, 4 ]
[ 371, 23 ]
python
en
['en', 'en', 'en']
True
test_browse_media_as_dict
()
Test BrowseMediaSource conversion to media player item dict.
Test BrowseMediaSource conversion to media player item dict.
async def test_browse_media_as_dict(): """Test BrowseMediaSource conversion to media player item dict.""" base = models.BrowseMediaSource( domain=const.DOMAIN, identifier="media", media_class=MEDIA_CLASS_DIRECTORY, media_content_type="folder", title="media/", can_...
[ "async", "def", "test_browse_media_as_dict", "(", ")", ":", "base", "=", "models", ".", "BrowseMediaSource", "(", "domain", "=", "const", ".", "DOMAIN", ",", "identifier", "=", "\"media\"", ",", "media_class", "=", "MEDIA_CLASS_DIRECTORY", ",", "media_content_type...
[ 9, 0 ]
[ 43, 66 ]
python
en
['en', 'en', 'en']
True
test_browse_media_parent_no_children
()
Test BrowseMediaSource conversion to media player item dict.
Test BrowseMediaSource conversion to media player item dict.
async def test_browse_media_parent_no_children(): """Test BrowseMediaSource conversion to media player item dict.""" base = models.BrowseMediaSource( domain=const.DOMAIN, identifier="media", media_class=MEDIA_CLASS_DIRECTORY, media_content_type="folder", title="media/", ...
[ "async", "def", "test_browse_media_parent_no_children", "(", ")", ":", "base", "=", "models", ".", "BrowseMediaSource", "(", "domain", "=", "const", ".", "DOMAIN", ",", "identifier", "=", "\"media\"", ",", "media_class", "=", "MEDIA_CLASS_DIRECTORY", ",", "media_c...
[ 46, 0 ]
[ 66, 47 ]
python
en
['en', 'en', 'en']
True
test_media_source_default_name
()
Test MediaSource uses domain as default name.
Test MediaSource uses domain as default name.
async def test_media_source_default_name(): """Test MediaSource uses domain as default name.""" source = models.MediaSource(const.DOMAIN) assert source.name == const.DOMAIN
[ "async", "def", "test_media_source_default_name", "(", ")", ":", "source", "=", "models", ".", "MediaSource", "(", "const", ".", "DOMAIN", ")", "assert", "source", ".", "name", "==", "const", ".", "DOMAIN" ]
[ 69, 0 ]
[ 72, 38 ]
python
en
['gl', 'en', 'en']
True
setup_unifi_integration
( hass, config=ENTRY_CONFIG, options=ENTRY_OPTIONS, sites=SITES, site_description=DESCRIPTION, clients_response=None, devices_response=None, clients_all_response=None, wlans_response=None, dpigroup_response=None, dpiapp_response=None, known_wireless_clients=None, cont...
Create the UniFi controller.
Create the UniFi controller.
async def setup_unifi_integration( hass, config=ENTRY_CONFIG, options=ENTRY_OPTIONS, sites=SITES, site_description=DESCRIPTION, clients_response=None, devices_response=None, clients_all_response=None, wlans_response=None, dpigroup_response=None, dpiapp_response=None, know...
[ "async", "def", "setup_unifi_integration", "(", "hass", ",", "config", "=", "ENTRY_CONFIG", ",", "options", "=", "ENTRY_OPTIONS", ",", "sites", "=", "SITES", ",", "site_description", "=", "DESCRIPTION", ",", "clients_response", "=", "None", ",", "devices_response"...
[ 73, 0 ]
[ 170, 21 ]
python
en
['en', 'ro', 'en']
True
test_controller_setup
(hass)
Successful setup.
Successful setup.
async def test_controller_setup(hass): """Successful setup.""" with patch( "homeassistant.config_entries.ConfigEntries.async_forward_entry_setup", return_value=True, ) as forward_entry_setup: controller = await setup_unifi_integration(hass) entry = controller.config_entry as...
[ "async", "def", "test_controller_setup", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.config_entries.ConfigEntries.async_forward_entry_setup\"", ",", "return_value", "=", "True", ",", ")", "as", "forward_entry_setup", ":", "controller", "=", "await", "s...
[ 173, 0 ]
[ 205, 78 ]
python
en
['en', 'ro', 'en']
False
test_controller_mac
(hass)
Test that it is possible to identify controller mac.
Test that it is possible to identify controller mac.
async def test_controller_mac(hass): """Test that it is possible to identify controller mac.""" controller = await setup_unifi_integration(hass, clients_response=[CONTROLLER_HOST]) assert controller.mac == CONTROLLER_HOST["mac"]
[ "async", "def", "test_controller_mac", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "clients_response", "=", "[", "CONTROLLER_HOST", "]", ")", "assert", "controller", ".", "mac", "==", "CONTROLLER_HOST", "[", "\...
[ 208, 0 ]
[ 211, 51 ]
python
en
['en', 'en', 'en']
True
test_controller_not_accessible
(hass)
Retry to login gets scheduled when connection fails.
Retry to login gets scheduled when connection fails.
async def test_controller_not_accessible(hass): """Retry to login gets scheduled when connection fails.""" with patch( "homeassistant.components.unifi.controller.get_controller", side_effect=CannotConnect, ): await setup_unifi_integration(hass) assert hass.data[UNIFI_DOMAIN] == {...
[ "async", "def", "test_controller_not_accessible", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.unifi.controller.get_controller\"", ",", "side_effect", "=", "CannotConnect", ",", ")", ":", "await", "setup_unifi_integration", "(", "hass", ")", ...
[ 214, 0 ]
[ 221, 40 ]
python
en
['en', 'en', 'en']
True
test_controller_unknown_error
(hass)
Unknown errors are handled.
Unknown errors are handled.
async def test_controller_unknown_error(hass): """Unknown errors are handled.""" with patch( "homeassistant.components.unifi.controller.get_controller", side_effect=Exception, ): await setup_unifi_integration(hass) assert hass.data[UNIFI_DOMAIN] == {}
[ "async", "def", "test_controller_unknown_error", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.unifi.controller.get_controller\"", ",", "side_effect", "=", "Exception", ",", ")", ":", "await", "setup_unifi_integration", "(", "hass", ")", "asse...
[ 224, 0 ]
[ 231, 40 ]
python
en
['en', 'en', 'en']
True
test_reset_after_successful_setup
(hass)
Calling reset when the entry has been setup.
Calling reset when the entry has been setup.
async def test_reset_after_successful_setup(hass): """Calling reset when the entry has been setup.""" controller = await setup_unifi_integration(hass) assert len(controller.listeners) == 6 result = await controller.async_reset() await hass.async_block_till_done() assert result is True ass...
[ "async", "def", "test_reset_after_successful_setup", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ")", "assert", "len", "(", "controller", ".", "listeners", ")", "==", "6", "result", "=", "await", "controller", ".", ...
[ 234, 0 ]
[ 244, 41 ]
python
en
['en', 'en', 'en']
True
test_wireless_client_event_calls_update_wireless_devices
(hass)
Call update_wireless_devices method when receiving wireless client event.
Call update_wireless_devices method when receiving wireless client event.
async def test_wireless_client_event_calls_update_wireless_devices(hass): """Call update_wireless_devices method when receiving wireless client event.""" controller = await setup_unifi_integration(hass) with patch( "homeassistant.components.unifi.controller.UniFiController.update_wireless_clients",...
[ "async", "def", "test_wireless_client_event_calls_update_wireless_devices", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ")", "with", "patch", "(", "\"homeassistant.components.unifi.controller.UniFiController.update_wireless_clients\"",...
[ 247, 0 ]
[ 268, 55 ]
python
en
['en', 'en', 'en']
True
test_get_controller
(hass)
Successful call.
Successful call.
async def test_get_controller(hass): """Successful call.""" with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch( "aiounifi.Controller.login", return_value=True ): assert await get_controller(hass, **CONTROLLER_DATA)
[ "async", "def", "test_get_controller", "(", "hass", ")", ":", "with", "patch", "(", "\"aiounifi.Controller.check_unifi_os\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"aiounifi.Controller.login\"", ",", "return_value", "=", "True", ")", ":", "as...
[ 271, 0 ]
[ 276, 60 ]
python
co
['es', 'co', 'en']
False
test_get_controller_verify_ssl_false
(hass)
Successful call with verify ssl set to false.
Successful call with verify ssl set to false.
async def test_get_controller_verify_ssl_false(hass): """Successful call with verify ssl set to false.""" controller_data = dict(CONTROLLER_DATA) controller_data[CONF_VERIFY_SSL] = False with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch( "aiounifi.Controller.login", retu...
[ "async", "def", "test_get_controller_verify_ssl_false", "(", "hass", ")", ":", "controller_data", "=", "dict", "(", "CONTROLLER_DATA", ")", "controller_data", "[", "CONF_VERIFY_SSL", "]", "=", "False", "with", "patch", "(", "\"aiounifi.Controller.check_unifi_os\"", ",",...
[ 279, 0 ]
[ 286, 60 ]
python
en
['en', 'pt', 'en']
True
test_get_controller_login_failed
(hass)
Check that get_controller can handle a failed login.
Check that get_controller can handle a failed login.
async def test_get_controller_login_failed(hass): """Check that get_controller can handle a failed login.""" with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch( "aiounifi.Controller.login", side_effect=aiounifi.Unauthorized ), pytest.raises(AuthenticationRequired): aw...
[ "async", "def", "test_get_controller_login_failed", "(", "hass", ")", ":", "with", "patch", "(", "\"aiounifi.Controller.check_unifi_os\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"aiounifi.Controller.login\"", ",", "side_effect", "=", "aiounifi", "...
[ 289, 0 ]
[ 294, 53 ]
python
en
['en', 'en', 'en']
True
test_get_controller_controller_unavailable
(hass)
Check that get_controller can handle controller being unavailable.
Check that get_controller can handle controller being unavailable.
async def test_get_controller_controller_unavailable(hass): """Check that get_controller can handle controller being unavailable.""" with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch( "aiounifi.Controller.login", side_effect=aiounifi.RequestError ), pytest.raises(CannotConne...
[ "async", "def", "test_get_controller_controller_unavailable", "(", "hass", ")", ":", "with", "patch", "(", "\"aiounifi.Controller.check_unifi_os\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"aiounifi.Controller.login\"", ",", "side_effect", "=", "aiou...
[ 297, 0 ]
[ 302, 53 ]
python
en
['en', 'en', 'en']
True
test_get_controller_unknown_error
(hass)
Check that get_controller can handle unknown errors.
Check that get_controller can handle unknown errors.
async def test_get_controller_unknown_error(hass): """Check that get_controller can handle unknown errors.""" with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch( "aiounifi.Controller.login", side_effect=aiounifi.AiounifiException ), pytest.raises(AuthenticationRequired): ...
[ "async", "def", "test_get_controller_unknown_error", "(", "hass", ")", ":", "with", "patch", "(", "\"aiounifi.Controller.check_unifi_os\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"aiounifi.Controller.login\"", ",", "side_effect", "=", "aiounifi", ...
[ 305, 0 ]
[ 310, 53 ]
python
en
['en', 'en', 'en']
True
TokenClassificationTask.convert_examples_to_features
( examples: List[InputExample], label_list: List[str], max_seq_length: int, tokenizer: PreTrainedTokenizer, cls_token_at_end=False, cls_token="[CLS]", cls_token_segment_id=1, sep_token="[SEP]", sep_token_extra=False, pad_on_left=False, ...
Loads a data file into a list of `InputFeatures` `cls_token_at_end` define the location of the CLS token: - False (Default, BERT/XLM pattern): [CLS] + A + [SEP] + B + [SEP] - True (XLNet/GPT pattern): A + [SEP] + B + [SEP] + [CLS] `cls_token_segment_id` define the segment id asso...
Loads a data file into a list of `InputFeatures` `cls_token_at_end` define the location of the CLS token: - False (Default, BERT/XLM pattern): [CLS] + A + [SEP] + B + [SEP] - True (XLNet/GPT pattern): A + [SEP] + B + [SEP] + [CLS] `cls_token_segment_id` define the segment id asso...
def convert_examples_to_features( examples: List[InputExample], label_list: List[str], max_seq_length: int, tokenizer: PreTrainedTokenizer, cls_token_at_end=False, cls_token="[CLS]", cls_token_segment_id=1, sep_token="[SEP]", sep_token_extra=False,...
[ "def", "convert_examples_to_features", "(", "examples", ":", "List", "[", "InputExample", "]", ",", "label_list", ":", "List", "[", "str", "]", ",", "max_seq_length", ":", "int", ",", "tokenizer", ":", "PreTrainedTokenizer", ",", "cls_token_at_end", "=", "False"...
[ 77, 4 ]
[ 202, 23 ]
python
en
['en', 'en', 'en']
True
test_light_state
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the creation and values of the Elgato Key Lights.
Test the creation and values of the Elgato Key Lights.
async def test_light_state( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the creation and values of the Elgato Key Lights.""" await init_integration(hass, aioclient_mock) entity_registry = await hass.helpers.entity_registry.async_get_registry() # First segment of the...
[ "async", "def", "test_light_state", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ")", "entity_registry", "=", "await", "hass", ".", ...
[ 23, 0 ]
[ 40, 44 ]
python
en
['en', 'en', 'en']
True
test_light_change_state
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the change of state of a Elgato Key Light device.
Test the change of state of a Elgato Key Light device.
async def test_light_change_state( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the change of state of a Elgato Key Light device.""" await init_integration(hass, aioclient_mock) state = hass.states.get("light.frenck") assert state.state == STATE_ON with patch( ...
[ "async", "def", "test_light_change_state", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ")", "state", "=", "hass", ".", "states", "....
[ 43, 0 ]
[ 82, 47 ]
python
en
['en', 'en', 'en']
True
test_light_unavailable
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test error/unavailable handling of an Elgato Key Light.
Test error/unavailable handling of an Elgato Key Light.
async def test_light_unavailable( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test error/unavailable handling of an Elgato Key Light.""" await init_integration(hass, aioclient_mock) with patch( "homeassistant.components.elgato.light.Elgato.light", side_effect=E...
[ "async", "def", "test_light_unavailable", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ")", "with", "patch", "(", "\"homeassistant.compo...
[ 85, 0 ]
[ 106, 51 ]
python
en
['en', 'ja', 'en']
True
XLMConfig.__init__
( self, vocab_size=30145, emb_dim=2048, n_layers=12, n_heads=16, dropout=0.1, attention_dropout=0.1, gelu_activation=True, sinusoidal_embeddings=False, causal=False, asm=False, n_langs=1, use_lang_emb=True, m...
Constructs XLMConfig.
Constructs XLMConfig.
def __init__( self, vocab_size=30145, emb_dim=2048, n_layers=12, n_heads=16, dropout=0.1, attention_dropout=0.1, gelu_activation=True, sinusoidal_embeddings=False, causal=False, asm=False, n_langs=1, use_lang_emb=Tru...
[ "def", "__init__", "(", "self", ",", "vocab_size", "=", "30145", ",", "emb_dim", "=", "2048", ",", "n_layers", "=", "12", ",", "n_heads", "=", "16", ",", "dropout", "=", "0.1", ",", "attention_dropout", "=", "0.1", ",", "gelu_activation", "=", "True", ...
[ 149, 4 ]
[ 221, 44 ]
python
en
['en', 'en', 'en']
False
interpolate_met
(in_dat, var, in_lons, in_lats, in_elev, out_lons, out_lats, out_elev, lapse=-0.005, single_dt=False)
interpolate met data for one timestep from coarse (vcsn) grid onto higher-resolution grid using bilinear interpolation. Air temperatures are first lapsed to sea level using default lapse rate of 0.005 K per m, interpolated, then lapsed to elevation of new grid when the input is a masked array, nearest ne...
interpolate met data for one timestep from coarse (vcsn) grid onto higher-resolution grid using bilinear interpolation.
def interpolate_met(in_dat, var, in_lons, in_lats, in_elev, out_lons, out_lats, out_elev, lapse=-0.005, single_dt=False): """ interpolate met data for one timestep from coarse (vcsn) grid onto higher-resolution grid using bilinear interpolation. Air temperatures are first lapsed to sea level using default ...
[ "def", "interpolate_met", "(", "in_dat", ",", "var", ",", "in_lons", ",", "in_lats", ",", "in_elev", ",", "out_lons", ",", "out_lats", ",", "out_elev", ",", "lapse", "=", "-", "0.005", ",", "single_dt", "=", "False", ")", ":", "# X, Y = np.meshgrid(vcsn_lons...
[ 75, 0 ]
[ 175, 37 ]
python
en
['en', 'error', 'th']
False
daily_to_hourly_temp_grids
(max_temp_grid, min_temp_grid, single_dt=False)
run through and process daily data into hourly, one slice at a time. :param max_temp_grid: input data with dimension [time,y,x] :param min_temp_grid: input data with dimension [time,y,x] :return: hourly data with dimension [time*24,y,x]
run through and process daily data into hourly, one slice at a time. :param max_temp_grid: input data with dimension [time,y,x] :param min_temp_grid: input data with dimension [time,y,x] :return: hourly data with dimension [time*24,y,x]
def daily_to_hourly_temp_grids(max_temp_grid, min_temp_grid, single_dt=False): """ run through and process daily data into hourly, one slice at a time. :param max_temp_grid: input data with dimension [time,y,x] :param min_temp_grid: input data with dimension [time,y,x] :return: hourly data with dime...
[ "def", "daily_to_hourly_temp_grids", "(", "max_temp_grid", ",", "min_temp_grid", ",", "single_dt", "=", "False", ")", ":", "if", "single_dt", "==", "True", ":", "# assume is 2d and add a time dimension on the start", "max_temp_grid", "=", "max_temp_grid", ".", "reshape", ...
[ 178, 0 ]
[ 191, 22 ]
python
en
['en', 'error', 'th']
False
daily_to_hourly_swin_grids
(swin_grid, lats, lons, hourly_dt, single_dt=False)
converts daily mean SW into hourly using TOA rad, applying :param hi_res_sw_rad: daily sw in data with dimension [time,y,x] :return:
converts daily mean SW into hourly using TOA rad, applying
def daily_to_hourly_swin_grids(swin_grid, lats, lons, hourly_dt, single_dt=False): """ converts daily mean SW into hourly using TOA rad, applying :param hi_res_sw_rad: daily sw in data with dimension [time,y,x] :return: """ if single_dt == True: # assume is 2d and add a time dimension on the s...
[ "def", "daily_to_hourly_swin_grids", "(", "swin_grid", ",", "lats", ",", "lons", ",", "hourly_dt", ",", "single_dt", "=", "False", ")", ":", "if", "single_dt", "==", "True", ":", "# assume is 2d and add a time dimension on the start", "swin_grid", "=", "swin_grid", ...
[ 194, 0 ]
[ 220, 22 ]
python
en
['en', 'error', 'th']
False
load_new_vscn
(variable, dt_out, nc_file_in, point=None, nc_opt=False, single_dt=False, nc_datetimes=None)
load vcsn data from file for specified datetimes. transforms spatial dimensions so that latitude and longitude are increasing :param variable: string describing the field to take. options for newVCSN data are 'rain', 'tmax', 'tmin', 'srad' :param dt_out: array of datetimes requested :param nc_file_in: ...
load vcsn data from file for specified datetimes. transforms spatial dimensions so that latitude and longitude are increasing :param variable: string describing the field to take. options for newVCSN data are 'rain', 'tmax', 'tmin', 'srad' :param dt_out: array of datetimes requested :param nc_file_in: ...
def load_new_vscn(variable, dt_out, nc_file_in, point=None, nc_opt=False, single_dt=False, nc_datetimes=None): """ load vcsn data from file for specified datetimes. transforms spatial dimensions so that latitude and longitude are increasing :param variable: string describing the field to take. options for n...
[ "def", "load_new_vscn", "(", "variable", ",", "dt_out", ",", "nc_file_in", ",", "point", "=", "None", ",", "nc_opt", "=", "False", ",", "single_dt", "=", "False", ",", "nc_datetimes", "=", "None", ")", ":", "if", "nc_opt", ":", "nc_file", "=", "nc_file_i...
[ 223, 0 ]
[ 261, 15 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the thermoworks sensor.
Set up the thermoworks sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the thermoworks sensor.""" email = config[CONF_EMAIL] password = config[CONF_PASSWORD] monitored_variables = config[CONF_MONITORED_CONDITIONS] excluded = config[CONF_EXCLUDE] try: mgr = thermoworks_smoke.ini...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "email", "=", "config", "[", "CONF_EMAIL", "]", "password", "=", "config", "[", "CONF_PASSWORD", "]", "monitored_variables", "=", "config", ...
[ 65, 0 ]
[ 90, 30 ]
python
en
['en', 'en', 'en']
True
ThermoworksSmokeSensor.__init__
(self, sensor_type, serial, mgr)
Initialize the sensor.
Initialize the sensor.
def __init__(self, sensor_type, serial, mgr): """Initialize the sensor.""" self._name = "{name} {sensor}".format( name=mgr.name(serial), sensor=SENSOR_TYPES[sensor_type] ) self.type = sensor_type self._state = None self._attributes = {} self._unit_of_m...
[ "def", "__init__", "(", "self", ",", "sensor_type", ",", "serial", ",", "mgr", ")", ":", "self", ".", "_name", "=", "\"{name} {sensor}\"", ".", "format", "(", "name", "=", "mgr", ".", "name", "(", "serial", ")", ",", "sensor", "=", "SENSOR_TYPES", "[",...
[ 96, 4 ]
[ 108, 26 ]
python
en
['en', 'en', 'en']
True
ThermoworksSmokeSensor.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" ]
[ 111, 4 ]
[ 113, 25 ]
python
en
['en', 'mi', 'en']
True
ThermoworksSmokeSensor.unique_id
(self)
Return the unique id for the sensor.
Return the unique id for the sensor.
def unique_id(self): """Return the unique id for the sensor.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 116, 4 ]
[ 118, 30 ]
python
en
['en', 'it', 'en']
True
ThermoworksSmokeSensor.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" ]
[ 121, 4 ]
[ 123, 26 ]
python
en
['en', 'en', 'en']
True
ThermoworksSmokeSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attributes" ]
[ 126, 4 ]
[ 128, 31 ]
python
en
['en', 'en', 'en']
True
ThermoworksSmokeSensor.unit_of_measurement
(self)
Return the unit of measurement of this sensor.
Return the unit of measurement of this sensor.
def unit_of_measurement(self): """Return the unit of measurement of this sensor.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 131, 4 ]
[ 133, 40 ]
python
en
['en', 'id', 'en']
True
ThermoworksSmokeSensor.update_unit
(self)
Set the units from the data.
Set the units from the data.
def update_unit(self): """Set the units from the data.""" if PROBE_2 in self.type: self._unit_of_measurement = self.mgr.units(self.serial, PROBE_2) else: self._unit_of_measurement = self.mgr.units(self.serial, PROBE_1)
[ "def", "update_unit", "(", "self", ")", ":", "if", "PROBE_2", "in", "self", ".", "type", ":", "self", ".", "_unit_of_measurement", "=", "self", ".", "mgr", ".", "units", "(", "self", ".", "serial", ",", "PROBE_2", ")", "else", ":", "self", ".", "_uni...
[ 135, 4 ]
[ 140, 76 ]
python
en
['en', 'en', 'en']
True
ThermoworksSmokeSensor.update
(self)
Get the monitored data from firebase.
Get the monitored data from firebase.
def update(self): """Get the monitored data from firebase.""" try: values = self.mgr.data(self.serial) # set state from data based on type of sensor self._state = values.get(camelcase(self.type)) # set units self.update_unit() #...
[ "def", "update", "(", "self", ")", ":", "try", ":", "values", "=", "self", ".", "mgr", ".", "data", "(", "self", ".", "serial", ")", "# set state from data based on type of sensor", "self", ".", "_state", "=", "values", ".", "get", "(", "camelcase", "(", ...
[ 142, 4 ]
[ 180, 72 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine.configs
(self)
dict: Configurations of CIM business engine.
dict: Configurations of CIM business engine.
def configs(self): """dict: Configurations of CIM business engine.""" return self._config
[ "def", "configs", "(", "self", ")", ":", "return", "self", ".", "_config" ]
[ 90, 4 ]
[ 92, 27 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine.frame
(self)
FrameBase: Frame of current business engine.
FrameBase: Frame of current business engine.
def frame(self) -> FrameBase: """FrameBase: Frame of current business engine.""" return self._frame
[ "def", "frame", "(", "self", ")", "->", "FrameBase", ":", "return", "self", ".", "_frame" ]
[ 95, 4 ]
[ 97, 26 ]
python
en
['en', 'da', 'en']
True
CimBusinessEngine.snapshots
(self)
SnapshotList: Snapshot list of current frame.
SnapshotList: Snapshot list of current frame.
def snapshots(self) -> SnapshotList: """SnapshotList: Snapshot list of current frame.""" return self._snapshots
[ "def", "snapshots", "(", "self", ")", "->", "SnapshotList", ":", "return", "self", ".", "_snapshots" ]
[ 100, 4 ]
[ 102, 30 ]
python
en
['en', 'de', 'en']
True
CimBusinessEngine.step
(self, tick: int)
Called at each tick to generate orders and arrival events. Args: tick (int): Tick to generate orders.
Called at each tick to generate orders and arrival events.
def step(self, tick: int): """Called at each tick to generate orders and arrival events. Args: tick (int): Tick to generate orders. """ # At each tick: # 1. Generate orders for this tick. # 2. Transfer orders into events (ORDER). # 3. Check and add v...
[ "def", "step", "(", "self", ",", "tick", ":", "int", ")", ":", "# At each tick:", "# 1. Generate orders for this tick.", "# 2. Transfer orders into events (ORDER).", "# 3. Check and add vessel arrival event (atom and cascade).", "total_empty_number", "=", "sum", "(", "[", "node...
[ 104, 4 ]
[ 182, 50 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine.post_step
(self, tick: int)
Post-process after each step. Args: tick (int): Tick to process.
Post-process after each step.
def post_step(self, tick: int): """Post-process after each step. Args: tick (int): Tick to process. """ self._stream_data() if (tick + 1) % self._snapshot_resolution == 0: # Update acc_fulfillment before take snapshot. for port in self._ports...
[ "def", "post_step", "(", "self", ",", "tick", ":", "int", ")", ":", "self", ".", "_stream_data", "(", ")", "if", "(", "tick", "+", "1", ")", "%", "self", ".", "_snapshot_resolution", "==", "0", ":", "# Update acc_fulfillment before take snapshot.", "for", ...
[ 184, 4 ]
[ 207, 41 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine.reset
(self)
Reset the business engine, it will reset frame value.
Reset the business engine, it will reset frame value.
def reset(self): """Reset the business engine, it will reset frame value.""" self._snapshots.reset() self._frame.reset() self._reset_nodes() self._data_cntr.reset() # Insert departure event again. self._load_departure_events() self._total_operate_num...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_snapshots", ".", "reset", "(", ")", "self", ".", "_frame", ".", "reset", "(", ")", "self", ".", "_reset_nodes", "(", ")", "self", ".", "_data_cntr", ".", "reset", "(", ")", "# Insert departure event...
[ 209, 4 ]
[ 223, 35 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine.action_scope
(self, port_idx: int, vessel_idx: int)
Get the action scope of specified agent. Args: port_idx (int): Index of specified agent. vessel_idx (int): Index of specified vessel to take the action. Returns: ActionScope: Contains load and discharge scope.
Get the action scope of specified agent.
def action_scope(self, port_idx: int, vessel_idx: int) -> ActionScope: """Get the action scope of specified agent. Args: port_idx (int): Index of specified agent. vessel_idx (int): Index of specified vessel to take the action. Returns: ActionScope: Contains ...
[ "def", "action_scope", "(", "self", ",", "port_idx", ":", "int", ",", "vessel_idx", ":", "int", ")", "->", "ActionScope", ":", "port", "=", "self", ".", "_ports", "[", "port_idx", "]", "vessel", "=", "self", ".", "_vessels", "[", "vessel_idx", "]", "re...
[ 225, 4 ]
[ 238, 96 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine.early_discharge
(self, vessel_idx: int)
Get the early discharge number of specified vessel. Args: vessel_idx (int): Index of specified vessel.
Get the early discharge number of specified vessel.
def early_discharge(self, vessel_idx: int) -> int: """Get the early discharge number of specified vessel. Args: vessel_idx (int): Index of specified vessel. """ return self._vessels[vessel_idx].early_discharge
[ "def", "early_discharge", "(", "self", ",", "vessel_idx", ":", "int", ")", "->", "int", ":", "return", "self", ".", "_vessels", "[", "vessel_idx", "]", ".", "early_discharge" ]
[ 240, 4 ]
[ 246, 56 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine.get_metrics
(self)
Get metrics information for cim scenario. Args: dict: A dict that contains "perf", "total_shortage" and "total_cost", and can use help method to show help docs.
Get metrics information for cim scenario.
def get_metrics(self) -> DocableDict: """Get metrics information for cim scenario. Args: dict: A dict that contains "perf", "total_shortage" and "total_cost", and can use help method to show help docs. """ total_shortage = sum([p.acc_shortage for p in self._p...
[ "def", "get_metrics", "(", "self", ")", "->", "DocableDict", ":", "total_shortage", "=", "sum", "(", "[", "p", ".", "acc_shortage", "for", "p", "in", "self", ".", "_ports", "]", ")", "total_booking", "=", "sum", "(", "[", "p", ".", "acc_booking", "for"...
[ 248, 4 ]
[ 263, 9 ]
python
en
['en', 'la', 'en']
True
CimBusinessEngine.get_node_mapping
(self)
Get node name mappings related with this environment. Returns: dict: Node name to index mapping dictionary.
Get node name mappings related with this environment.
def get_node_mapping(self) -> dict: """Get node name mappings related with this environment. Returns: dict: Node name to index mapping dictionary. """ return { "ports": self._data_cntr.port_mapping, "vessels": self._data_cntr.vessel_mapping }
[ "def", "get_node_mapping", "(", "self", ")", "->", "dict", ":", "return", "{", "\"ports\"", ":", "self", ".", "_data_cntr", ".", "port_mapping", ",", "\"vessels\"", ":", "self", ".", "_data_cntr", ".", "vessel_mapping", "}" ]
[ 265, 4 ]
[ 274, 9 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine.get_event_payload_detail
(self)
dict: Event payload details of current scenario.
dict: Event payload details of current scenario.
def get_event_payload_detail(self) -> dict: """dict: Event payload details of current scenario.""" return { Events.ORDER.name: Order.summary_key, Events.RETURN_FULL.name: LadenReturnPayload.summary_key, Events.VESSEL_ARRIVAL.name: VesselStatePayload.summary_key, ...
[ "def", "get_event_payload_detail", "(", "self", ")", "->", "dict", ":", "return", "{", "Events", ".", "ORDER", ".", "name", ":", "Order", ".", "summary_key", ",", "Events", ".", "RETURN_FULL", ".", "name", ":", "LadenReturnPayload", ".", "summary_key", ",", ...
[ 276, 4 ]
[ 289, 9 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine.get_agent_idx_list
(self)
Get port index list related with this environment. Returns: list: A list of port index.
Get port index list related with this environment.
def get_agent_idx_list(self) -> list: """Get port index list related with this environment. Returns: list: A list of port index. """ return [i for i in range(self._data_cntr.port_number)]
[ "def", "get_agent_idx_list", "(", "self", ")", "->", "list", ":", "return", "[", "i", "for", "i", "in", "range", "(", "self", ".", "_data_cntr", ".", "port_number", ")", "]" ]
[ 291, 4 ]
[ 297, 62 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._register_events
(self)
Register events.
Register events.
def _register_events(self): """Register events.""" register_handler = self._event_buffer.register_event_handler register_handler(Events.RETURN_FULL, self._on_full_return) register_handler(Events.RETURN_EMPTY, self._on_empty_return) register_handler(Events.ORDER, self._on_order_g...
[ "def", "_register_events", "(", "self", ")", ":", "register_handler", "=", "self", ".", "_event_buffer", ".", "register_event_handler", "register_handler", "(", "Events", ".", "RETURN_FULL", ",", "self", ".", "_on_full_return", ")", "register_handler", "(", "Events"...
[ 336, 4 ]
[ 346, 74 ]
python
en
['da', 'en', 'en']
False
CimBusinessEngine._load_departure_events
(self)
Insert leaving event at the beginning as we already unpack the root to a loop at the beginning.
Insert leaving event at the beginning as we already unpack the root to a loop at the beginning.
def _load_departure_events(self): """Insert leaving event at the beginning as we already unpack the root to a loop at the beginning.""" for vessel_idx, stops in enumerate(self._data_cntr.vessel_stops[:]): for stop in stops: payload = VesselStatePayload(stop.port_idx, vessel_...
[ "def", "_load_departure_events", "(", "self", ")", ":", "for", "vessel_idx", ",", "stops", "in", "enumerate", "(", "self", ".", "_data_cntr", ".", "vessel_stops", "[", ":", "]", ")", ":", "for", "stop", "in", "stops", ":", "payload", "=", "VesselStatePaylo...
[ 348, 4 ]
[ 356, 56 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._init_frame
(self)
Initialize the frame based on data generator.
Initialize the frame based on data generator.
def _init_frame(self): """Initialize the frame based on data generator.""" port_num = self._data_cntr.port_number vessel_num = self._data_cntr.vessel_number stop_num = (self._data_cntr.past_stop_number, self._data_cntr.future_stop_number) self._frame = gen_ci...
[ "def", "_init_frame", "(", "self", ")", ":", "port_num", "=", "self", ".", "_data_cntr", ".", "port_number", "vessel_num", "=", "self", ".", "_data_cntr", ".", "vessel_number", "stop_num", "=", "(", "self", ".", "_data_cntr", ".", "past_stop_number", ",", "s...
[ 358, 4 ]
[ 375, 26 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._get_reachable_ports
(self, vessel_idx: int)
Get ports that specified vessel can reach (for order), return a list of tuple (port_id, arrive_tick). Args: vessel_idx (int): Index of specified vessel. Returns: Reachable port index list of specified vessel.
Get ports that specified vessel can reach (for order), return a list of tuple (port_id, arrive_tick).
def _get_reachable_ports(self, vessel_idx: int): """Get ports that specified vessel can reach (for order), return a list of tuple (port_id, arrive_tick). Args: vessel_idx (int): Index of specified vessel. Returns: Reachable port index list of specified vessel. "...
[ "def", "_get_reachable_ports", "(", "self", ",", "vessel_idx", ":", "int", ")", ":", "vessel", "=", "self", ".", "_vessels", "[", "vessel_idx", "]", "return", "self", ".", "_data_cntr", ".", "reachable_stops", "[", "vessel_idx", ",", "vessel", ".", "route_id...
[ 377, 4 ]
[ 388, 97 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._get_pending_full
(self, src_port_idx: int, dest_port_idx: int)
Get pending full number from src_port_idx to dest_port_idx.
Get pending full number from src_port_idx to dest_port_idx.
def _get_pending_full(self, src_port_idx: int, dest_port_idx: int): """Get pending full number from src_port_idx to dest_port_idx.""" return self._full_on_ports[src_port_idx, dest_port_idx]
[ "def", "_get_pending_full", "(", "self", ",", "src_port_idx", ":", "int", ",", "dest_port_idx", ":", "int", ")", ":", "return", "self", ".", "_full_on_ports", "[", "src_port_idx", ",", "dest_port_idx", "]" ]
[ 390, 4 ]
[ 392, 63 ]
python
en
['en', 'da', 'en']
True
CimBusinessEngine._set_pending_full
(self, src_port_idx: int, dest_port_idx: int, value)
Set the full number from src_port_idx to dest_port_idx.
Set the full number from src_port_idx to dest_port_idx.
def _set_pending_full(self, src_port_idx: int, dest_port_idx: int, value): """Set the full number from src_port_idx to dest_port_idx.""" assert value >= 0 self._full_on_ports[src_port_idx, dest_port_idx] = value
[ "def", "_set_pending_full", "(", "self", ",", "src_port_idx", ":", "int", ",", "dest_port_idx", ":", "int", ",", "value", ")", ":", "assert", "value", ">=", "0", "self", ".", "_full_on_ports", "[", "src_port_idx", ",", "dest_port_idx", "]", "=", "value" ]
[ 394, 4 ]
[ 398, 64 ]
python
en
['en', 'da', 'en']
True
CimBusinessEngine._on_order_generated
(self, event: CascadeEvent)
When there is an order generated, we should do: 1. Generate a LADEN_RETURN event by configured buffer time: \ The event will be inserted to the immediate_event_list ASAP if the configured buffer time is 0, \ else the event will be inserted to the event buffer directly. 2. Update port sta...
When there is an order generated, we should do: 1. Generate a LADEN_RETURN event by configured buffer time: \ The event will be inserted to the immediate_event_list ASAP if the configured buffer time is 0, \ else the event will be inserted to the event buffer directly. 2. Update port sta...
def _on_order_generated(self, event: CascadeEvent): """When there is an order generated, we should do: 1. Generate a LADEN_RETURN event by configured buffer time: \ The event will be inserted to the immediate_event_list ASAP if the configured buffer time is 0, \ else the event will be in...
[ "def", "_on_order_generated", "(", "self", ",", "event", ":", "CascadeEvent", ")", ":", "order", ":", "Order", "=", "event", ".", "payload", "src_port", "=", "self", ".", "_ports", "[", "order", ".", "src_port_idx", "]", "execute_qty", "=", "order", ".", ...
[ 400, 4 ]
[ 445, 61 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._on_full_return
(self, event: AtomEvent)
Handler for processing the event that full containers are returned from shipper. Once the full containers are returned, the containers are ready to be loaded. The workflow is: 1. First move the container from on_shipper to full (update state: on_shipper -> full). 2. Then append the container to...
Handler for processing the event that full containers are returned from shipper.
def _on_full_return(self, event: AtomEvent): """Handler for processing the event that full containers are returned from shipper. Once the full containers are returned, the containers are ready to be loaded. The workflow is: 1. First move the container from on_shipper to full (update state: on_s...
[ "def", "_on_full_return", "(", "self", ",", "event", ":", "AtomEvent", ")", ":", "payload", ":", "LadenReturnPayload", "=", "event", ".", "payload", "src_port", "=", "self", ".", "_ports", "[", "payload", ".", "src_port_idx", "]", "src_port", ".", "on_shippe...
[ 447, 4 ]
[ 464, 96 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._on_full_load
(self, event: AtomEvent)
Handler for processing event that a vessel need to load full containers from current port. When there is a vessel arrive at a port: 1. Discharge full (we ignore this action here, as we will generate a discharge event \ after a vessel have loaded any full). 2. Load full by destination id...
Handler for processing event that a vessel need to load full containers from current port.
def _on_full_load(self, event: AtomEvent): """Handler for processing event that a vessel need to load full containers from current port. When there is a vessel arrive at a port: 1. Discharge full (we ignore this action here, as we will generate a discharge event \ after a vessel have lo...
[ "def", "_on_full_load", "(", "self", ",", "event", ":", "AtomEvent", ")", ":", "arrival_obj", ":", "VesselStatePayload", "=", "event", ".", "payload", "vessel_idx", ":", "int", "=", "arrival_obj", ".", "vessel_idx", "port_idx", ":", "int", "=", "arrival_obj", ...
[ 466, 4 ]
[ 536, 59 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._on_departure
(self, event: AtomEvent)
Handler for processing event when there is a vessel leaving from port. When the vessel departing from port: 1. Update location to next stop. Args: event (AtomEvent): Departure event object.
Handler for processing event when there is a vessel leaving from port.
def _on_departure(self, event: AtomEvent): """Handler for processing event when there is a vessel leaving from port. When the vessel departing from port: 1. Update location to next stop. Args: event (AtomEvent): Departure event object. """ departure_payload...
[ "def", "_on_departure", "(", "self", ",", "event", ":", "AtomEvent", ")", ":", "departure_payload", ":", "VesselStatePayload", "=", "event", ".", "payload", "vessel_idx", "=", "departure_payload", ".", "vessel_idx", "vessel", "=", "self", ".", "_vessels", "[", ...
[ 538, 4 ]
[ 553, 32 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._on_discharge
(self, event: CascadeEvent)
Handler for processing event the there are some full need to be discharged. 1. Discharge specified qty of full from vessel into port.on_consignee. 2. Generate a empty_return event by configured buffer time: a. If buffer time is 0, then insert into immediate_event_list to process it ASAP. ...
Handler for processing event the there are some full need to be discharged.
def _on_discharge(self, event: CascadeEvent): """Handler for processing event the there are some full need to be discharged. 1. Discharge specified qty of full from vessel into port.on_consignee. 2. Generate a empty_return event by configured buffer time: a. If buffer time is 0, th...
[ "def", "_on_discharge", "(", "self", ",", "event", ":", "CascadeEvent", ")", ":", "discharge_payload", ":", "VesselDischargePayload", "=", "event", ".", "payload", "vessel_idx", "=", "discharge_payload", ".", "vessel_idx", "port_idx", "=", "discharge_payload", ".", ...
[ 555, 4 ]
[ 588, 58 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._on_empty_return
(self, event: AtomEvent)
Handler for processing event when there are some empty container return to port. Args: event (AtomEvent): Empty-return event object.
Handler for processing event when there are some empty container return to port.
def _on_empty_return(self, event: AtomEvent): """Handler for processing event when there are some empty container return to port. Args: event (AtomEvent): Empty-return event object. """ payload: EmptyReturnPayload = event.payload port = self._ports[payload.port_idx] ...
[ "def", "_on_empty_return", "(", "self", ",", "event", ":", "AtomEvent", ")", ":", "payload", ":", "EmptyReturnPayload", "=", "event", ".", "payload", "port", "=", "self", ".", "_ports", "[", "payload", ".", "port_idx", "]", "port", ".", "on_consignee", "-=...
[ 590, 4 ]
[ 600, 38 ]
python
en
['en', 'en', 'en']
True
CimBusinessEngine._on_action_received
(self, event: CascadeEvent)
Handler for processing actions from agent. Args: event (CascadeEvent): Action event object with expected payload: {vessel_id: empty_number_to_move}}.
Handler for processing actions from agent.
def _on_action_received(self, event: CascadeEvent): """Handler for processing actions from agent. Args: event (CascadeEvent): Action event object with expected payload: {vessel_id: empty_number_to_move}}. """ actions = event.payload if actions: if type(a...
[ "def", "_on_action_received", "(", "self", ",", "event", ":", "CascadeEvent", ")", ":", "actions", "=", "event", ".", "payload", "if", "actions", ":", "if", "type", "(", "actions", ")", "is", "not", "list", ":", "actions", "=", "[", "actions", "]", "fo...
[ 602, 4 ]
[ 650, 101 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the Rain Bird component.
Set up the Rain Bird component.
def setup(hass, config): """Set up the Rain Bird component.""" hass.data[DATA_RAINBIRD] = [] success = False for controller_config in config[DOMAIN]: success = success or _setup_controller(hass, controller_config, config) return success
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DATA_RAINBIRD", "]", "=", "[", "]", "success", "=", "False", "for", "controller_config", "in", "config", "[", "DOMAIN", "]", ":", "success", "=", "success", "or", "_setup_...
[ 58, 0 ]
[ 66, 18 ]
python
en
['en', 'lb', 'en']
True
_setup_controller
(hass, controller_config, config)
Set up a controller.
Set up a controller.
def _setup_controller(hass, controller_config, config): """Set up a controller.""" server = controller_config[CONF_HOST] password = controller_config[CONF_PASSWORD] controller = RainbirdController(server, password) position = len(hass.data[DATA_RAINBIRD]) try: controller.get_serial_numbe...
[ "def", "_setup_controller", "(", "hass", ",", "controller_config", ",", "config", ")", ":", "server", "=", "controller_config", "[", "CONF_HOST", "]", "password", "=", "controller_config", "[", "CONF_PASSWORD", "]", "controller", "=", "RainbirdController", "(", "s...
[ 69, 0 ]
[ 90, 15 ]
python
en
['en', 'lb', 'en']
True
Registry.register
(self, name: str)
Return decorator to register item with a specific name.
Return decorator to register item with a specific name.
def register(self, name: str) -> Callable[[CALLABLE_T], CALLABLE_T]: """Return decorator to register item with a specific name.""" def decorator(func: CALLABLE_T) -> CALLABLE_T: """Register decorated function.""" self[name] = func return func return decorato...
[ "def", "register", "(", "self", ",", "name", ":", "str", ")", "->", "Callable", "[", "[", "CALLABLE_T", "]", ",", "CALLABLE_T", "]", ":", "def", "decorator", "(", "func", ":", "CALLABLE_T", ")", "->", "CALLABLE_T", ":", "\"\"\"Register decorated function.\"\...
[ 9, 4 ]
[ 17, 24 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Bose Soundtouch platform.
Set up the Bose Soundtouch platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Bose Soundtouch platform.""" if DATA_SOUNDTOUCH not in hass.data: hass.data[DATA_SOUNDTOUCH] = [] if discovery_info: host = discovery_info["host"] port = int(discovery_info["port"]) # if devi...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "DATA_SOUNDTOUCH", "not", "in", "hass", ".", "data", ":", "hass", ".", "data", "[", "DATA_SOUNDTOUCH", "]", "=", "[", "]", "if",...
[ 96, 0 ]
[ 186, 5 ]
python
en
['en', 'cs', 'en']
True
SoundTouchDevice.__init__
(self, name, config)
Create Soundtouch Entity.
Create Soundtouch Entity.
def __init__(self, name, config): """Create Soundtouch Entity.""" self._device = soundtouch_device(config["host"], config["port"]) if name is None: self._name = self._device.config.name else: self._name = name self._status = None self._volume = No...
[ "def", "__init__", "(", "self", ",", "name", ",", "config", ")", ":", "self", ".", "_device", "=", "soundtouch_device", "(", "config", "[", "\"host\"", "]", ",", "config", "[", "\"port\"", "]", ")", "if", "name", "is", "None", ":", "self", ".", "_nam...
[ 192, 4 ]
[ 203, 25 ]
python
en
['de', 'en', 'en']
True
SoundTouchDevice.config
(self)
Return specific soundtouch configuration.
Return specific soundtouch configuration.
def config(self): """Return specific soundtouch configuration.""" return self._config
[ "def", "config", "(", "self", ")", ":", "return", "self", ".", "_config" ]
[ 206, 4 ]
[ 208, 27 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.device
(self)
Return Soundtouch device.
Return Soundtouch device.
def device(self): """Return Soundtouch device.""" return self._device
[ "def", "device", "(", "self", ")", ":", "return", "self", ".", "_device" ]
[ 211, 4 ]
[ 213, 27 ]
python
en
['de', 'en', 'en']
True
SoundTouchDevice.update
(self)
Retrieve the latest data.
Retrieve the latest data.
def update(self): """Retrieve the latest data.""" self._status = self._device.status() self._volume = self._device.volume() self._zone = self.get_zone_info()
[ "def", "update", "(", "self", ")", ":", "self", ".", "_status", "=", "self", ".", "_device", ".", "status", "(", ")", "self", ".", "_volume", "=", "self", ".", "_device", ".", "volume", "(", ")", "self", ".", "_zone", "=", "self", ".", "get_zone_in...
[ 215, 4 ]
[ 219, 41 ]
python
en
['en', 'ga', 'en']
True
SoundTouchDevice.volume_level
(self)
Volume level of the media player (0..1).
Volume level of the media player (0..1).
def volume_level(self): """Volume level of the media player (0..1).""" return self._volume.actual / 100
[ "def", "volume_level", "(", "self", ")", ":", "return", "self", ".", "_volume", ".", "actual", "/", "100" ]
[ 222, 4 ]
[ 224, 40 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.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" ]
[ 227, 4 ]
[ 229, 25 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" if self._status.source == "STANDBY": return STATE_OFF return MAP_STATUS.get(self._status.play_status, STATE_UNAVAILABLE)
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_status", ".", "source", "==", "\"STANDBY\"", ":", "return", "STATE_OFF", "return", "MAP_STATUS", ".", "get", "(", "self", ".", "_status", ".", "play_status", ",", "STATE_UNAVAILABLE", ")" ]
[ 232, 4 ]
[ 237, 74 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.source
(self)
Name of the current input source.
Name of the current input source.
def source(self): """Name of the current input source.""" return self._status.source
[ "def", "source", "(", "self", ")", ":", "return", "self", ".", "_status", ".", "source" ]
[ 240, 4 ]
[ 242, 34 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.source_list
(self)
List of available input sources.
List of available input sources.
def source_list(self): """List of available input sources.""" return [ Source.AUX.value, Source.BLUETOOTH.value, ]
[ "def", "source_list", "(", "self", ")", ":", "return", "[", "Source", ".", "AUX", ".", "value", ",", "Source", ".", "BLUETOOTH", ".", "value", ",", "]" ]
[ 245, 4 ]
[ 250, 9 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.is_volume_muted
(self)
Boolean if volume is currently muted.
Boolean if volume is currently muted.
def is_volume_muted(self): """Boolean if volume is currently muted.""" return self._volume.muted
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "_volume", ".", "muted" ]
[ 253, 4 ]
[ 255, 33 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.supported_features
(self)
Flag media player features that are supported.
Flag media player features that are supported.
def supported_features(self): """Flag media player features that are supported.""" return SUPPORT_SOUNDTOUCH
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_SOUNDTOUCH" ]
[ 258, 4 ]
[ 260, 33 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.turn_off
(self)
Turn off media player.
Turn off media player.
def turn_off(self): """Turn off media player.""" self._device.power_off()
[ "def", "turn_off", "(", "self", ")", ":", "self", ".", "_device", ".", "power_off", "(", ")" ]
[ 262, 4 ]
[ 264, 32 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.turn_on
(self)
Turn on media player.
Turn on media player.
def turn_on(self): """Turn on media player.""" self._device.power_on()
[ "def", "turn_on", "(", "self", ")", ":", "self", ".", "_device", ".", "power_on", "(", ")" ]
[ 266, 4 ]
[ 268, 31 ]
python
en
['en', 'et', 'en']
True
SoundTouchDevice.volume_up
(self)
Volume up the media player.
Volume up the media player.
def volume_up(self): """Volume up the media player.""" self._device.volume_up()
[ "def", "volume_up", "(", "self", ")", ":", "self", ".", "_device", ".", "volume_up", "(", ")" ]
[ 270, 4 ]
[ 272, 32 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.volume_down
(self)
Volume down media player.
Volume down media player.
def volume_down(self): """Volume down media player.""" self._device.volume_down()
[ "def", "volume_down", "(", "self", ")", ":", "self", ".", "_device", ".", "volume_down", "(", ")" ]
[ 274, 4 ]
[ 276, 34 ]
python
en
['en', 'sl', 'en']
True
SoundTouchDevice.set_volume_level
(self, volume)
Set volume level, range 0..1.
Set volume level, range 0..1.
def set_volume_level(self, volume): """Set volume level, range 0..1.""" self._device.set_volume(int(volume * 100))
[ "def", "set_volume_level", "(", "self", ",", "volume", ")", ":", "self", ".", "_device", ".", "set_volume", "(", "int", "(", "volume", "*", "100", ")", ")" ]
[ 278, 4 ]
[ 280, 50 ]
python
en
['fr', 'zu', 'en']
False
SoundTouchDevice.mute_volume
(self, mute)
Send mute command.
Send mute command.
def mute_volume(self, mute): """Send mute command.""" self._device.mute()
[ "def", "mute_volume", "(", "self", ",", "mute", ")", ":", "self", ".", "_device", ".", "mute", "(", ")" ]
[ 282, 4 ]
[ 284, 27 ]
python
en
['en', 'co', 'en']
True
SoundTouchDevice.media_play_pause
(self)
Simulate play pause media player.
Simulate play pause media player.
def media_play_pause(self): """Simulate play pause media player.""" self._device.play_pause()
[ "def", "media_play_pause", "(", "self", ")", ":", "self", ".", "_device", ".", "play_pause", "(", ")" ]
[ 286, 4 ]
[ 288, 33 ]
python
en
['en', 'en', 'it']
True
SoundTouchDevice.media_play
(self)
Send play command.
Send play command.
def media_play(self): """Send play command.""" self._device.play()
[ "def", "media_play", "(", "self", ")", ":", "self", ".", "_device", ".", "play", "(", ")" ]
[ 290, 4 ]
[ 292, 27 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.media_pause
(self)
Send media pause command to media player.
Send media pause command to media player.
def media_pause(self): """Send media pause command to media player.""" self._device.pause()
[ "def", "media_pause", "(", "self", ")", ":", "self", ".", "_device", ".", "pause", "(", ")" ]
[ 294, 4 ]
[ 296, 28 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.media_next_track
(self)
Send next track command.
Send next track command.
def media_next_track(self): """Send next track command.""" self._device.next_track()
[ "def", "media_next_track", "(", "self", ")", ":", "self", ".", "_device", ".", "next_track", "(", ")" ]
[ 298, 4 ]
[ 300, 33 ]
python
en
['en', 'pt', 'en']
True
SoundTouchDevice.media_previous_track
(self)
Send the previous track command.
Send the previous track command.
def media_previous_track(self): """Send the previous track command.""" self._device.previous_track()
[ "def", "media_previous_track", "(", "self", ")", ":", "self", ".", "_device", ".", "previous_track", "(", ")" ]
[ 302, 4 ]
[ 304, 37 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.media_image_url
(self)
Image url of current playing media.
Image url of current playing media.
def media_image_url(self): """Image url of current playing media.""" return self._status.image
[ "def", "media_image_url", "(", "self", ")", ":", "return", "self", ".", "_status", ".", "image" ]
[ 307, 4 ]
[ 309, 33 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" if self._status.station_name is not None: return self._status.station_name if self._status.artist is not None: return f"{self._status.artist} - {self._status.track}" return None
[ "def", "media_title", "(", "self", ")", ":", "if", "self", ".", "_status", ".", "station_name", "is", "not", "None", ":", "return", "self", ".", "_status", ".", "station_name", "if", "self", ".", "_status", ".", "artist", "is", "not", "None", ":", "ret...
[ 312, 4 ]
[ 319, 19 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.media_duration
(self)
Duration of current playing media in seconds.
Duration of current playing media in seconds.
def media_duration(self): """Duration of current playing media in seconds.""" return self._status.duration
[ "def", "media_duration", "(", "self", ")", ":", "return", "self", ".", "_status", ".", "duration" ]
[ 322, 4 ]
[ 324, 36 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.media_artist
(self)
Artist of current playing media.
Artist of current playing media.
def media_artist(self): """Artist of current playing media.""" return self._status.artist
[ "def", "media_artist", "(", "self", ")", ":", "return", "self", ".", "_status", ".", "artist" ]
[ 327, 4 ]
[ 329, 34 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.media_track
(self)
Artist of current playing media.
Artist of current playing media.
def media_track(self): """Artist of current playing media.""" return self._status.track
[ "def", "media_track", "(", "self", ")", ":", "return", "self", ".", "_status", ".", "track" ]
[ 332, 4 ]
[ 334, 33 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.media_album_name
(self)
Album name of current playing media.
Album name of current playing media.
def media_album_name(self): """Album name of current playing media.""" return self._status.album
[ "def", "media_album_name", "(", "self", ")", ":", "return", "self", ".", "_status", ".", "album" ]
[ 337, 4 ]
[ 339, 33 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.async_added_to_hass
(self)
Populate zone info which requires entity_id.
Populate zone info which requires entity_id.
async def async_added_to_hass(self): """Populate zone info which requires entity_id.""" @callback def async_update_on_start(event): """Schedule an update when all platform entities have been added.""" self.async_schedule_update_ha_state(True) self.hass.bus.async...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "@", "callback", "def", "async_update_on_start", "(", "event", ")", ":", "\"\"\"Schedule an update when all platform entities have been added.\"\"\"", "self", ".", "async_schedule_update_ha_state", "(", "True", "...
[ 341, 4 ]
[ 351, 9 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.play_media
(self, media_type, media_id, **kwargs)
Play a piece of media.
Play a piece of media.
def play_media(self, media_type, media_id, **kwargs): """Play a piece of media.""" _LOGGER.debug("Starting media with media_id: %s", media_id) if re.match(r"http?://", str(media_id)): # URL _LOGGER.debug("Playing URL %s", str(media_id)) self._device.play_url(s...
[ "def", "play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Starting media with media_id: %s\"", ",", "media_id", ")", "if", "re", ".", "match", "(", "r\"http?://\"", ",", "str", ...
[ 353, 4 ]
[ 373, 77 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.select_source
(self, source)
Select input source.
Select input source.
def select_source(self, source): """Select input source.""" if source == Source.AUX.value: _LOGGER.debug("Selecting source AUX") self._device.select_source_aux() elif source == Source.BLUETOOTH.value: _LOGGER.debug("Selecting source Bluetooth") sel...
[ "def", "select_source", "(", "self", ",", "source", ")", ":", "if", "source", "==", "Source", ".", "AUX", ".", "value", ":", "_LOGGER", ".", "debug", "(", "\"Selecting source AUX\"", ")", "self", ".", "_device", ".", "select_source_aux", "(", ")", "elif", ...
[ 375, 4 ]
[ 384, 65 ]
python
en
['fr', 'su', 'en']
False
SoundTouchDevice.create_zone
(self, slaves)
Create a zone (multi-room) and play on selected devices. :param slaves: slaves on which to play
Create a zone (multi-room) and play on selected devices.
def create_zone(self, slaves): """ Create a zone (multi-room) and play on selected devices. :param slaves: slaves on which to play """ if not slaves: _LOGGER.warning("Unable to create zone without slaves") else: _LOGGER.info("Creating zone with ...
[ "def", "create_zone", "(", "self", ",", "slaves", ")", ":", "if", "not", "slaves", ":", "_LOGGER", ".", "warning", "(", "\"Unable to create zone without slaves\"", ")", "else", ":", "_LOGGER", ".", "info", "(", "\"Creating zone with master %s\"", ",", "self", "....
[ 386, 4 ]
[ 397, 72 ]
python
en
['en', 'error', 'th']
False
SoundTouchDevice.remove_zone_slave
(self, slaves)
Remove slave(s) from and existing zone (multi-room). Zone must already exist and slaves array can not be empty. Note: If removing last slave, the zone will be deleted and you'll have to create a new one. You will not be able to add a new slave anymore :param slaves: slaves to ...
Remove slave(s) from and existing zone (multi-room).
def remove_zone_slave(self, slaves): """ Remove slave(s) from and existing zone (multi-room). Zone must already exist and slaves array can not be empty. Note: If removing last slave, the zone will be deleted and you'll have to create a new one. You will not be able to add a new ...
[ "def", "remove_zone_slave", "(", "self", ",", "slaves", ")", ":", "if", "not", "slaves", ":", "_LOGGER", ".", "warning", "(", "\"Unable to find slaves to remove\"", ")", "else", ":", "_LOGGER", ".", "info", "(", "\"Removing slaves from zone with master %s\"", ",", ...
[ 399, 4 ]
[ 422, 66 ]
python
en
['en', 'error', 'th']
False
SoundTouchDevice.add_zone_slave
(self, slaves)
Add slave(s) to and existing zone (multi-room). Zone must already exist and slaves array can not be empty. :param slaves:slaves to add
Add slave(s) to and existing zone (multi-room).
def add_zone_slave(self, slaves): """ Add slave(s) to and existing zone (multi-room). Zone must already exist and slaves array can not be empty. :param slaves:slaves to add """ if not slaves: _LOGGER.warning("Unable to find slaves to add") else: ...
[ "def", "add_zone_slave", "(", "self", ",", "slaves", ")", ":", "if", "not", "slaves", ":", "_LOGGER", ".", "warning", "(", "\"Unable to find slaves to add\"", ")", "else", ":", "_LOGGER", ".", "info", "(", "\"Adding slaves to zone with master %s\"", ",", "self", ...
[ 424, 4 ]
[ 439, 75 ]
python
en
['en', 'error', 'th']
False
SoundTouchDevice.device_state_attributes
(self)
Return entity specific state attributes.
Return entity specific state attributes.
def device_state_attributes(self): """Return entity specific state attributes.""" attributes = {} if self._zone and "master" in self._zone: attributes[ATTR_SOUNDTOUCH_ZONE] = self._zone # Compatibility with how other components expose their groups (like SONOS). ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "}", "if", "self", ".", "_zone", "and", "\"master\"", "in", "self", ".", "_zone", ":", "attributes", "[", "ATTR_SOUNDTOUCH_ZONE", "]", "=", "self", ".", "_zone", "# Compatibilit...
[ 442, 4 ]
[ 453, 25 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice.get_zone_info
(self)
Return the current zone info.
Return the current zone info.
def get_zone_info(self): """Return the current zone info.""" zone_status = self._device.zone_status() if not zone_status: return None # Due to a bug in the SoundTouch API itself client devices do NOT return their # siblings as part of the "slaves" list. Only the mast...
[ "def", "get_zone_info", "(", "self", ")", ":", "zone_status", "=", "self", ".", "_device", ".", "zone_status", "(", ")", "if", "not", "zone_status", ":", "return", "None", "# Due to a bug in the SoundTouch API itself client devices do NOT return their", "# siblings as par...
[ 455, 4 ]
[ 484, 72 ]
python
en
['en', 'en', 'en']
True
SoundTouchDevice._get_instance_by_ip
(self, ip_address)
Search and return a SoundTouchDevice instance by it's IP address.
Search and return a SoundTouchDevice instance by it's IP address.
def _get_instance_by_ip(self, ip_address): """Search and return a SoundTouchDevice instance by it's IP address.""" for instance in self.hass.data[DATA_SOUNDTOUCH]: if instance and instance.config["host"] == ip_address: return instance return None
[ "def", "_get_instance_by_ip", "(", "self", ",", "ip_address", ")", ":", "for", "instance", "in", "self", ".", "hass", ".", "data", "[", "DATA_SOUNDTOUCH", "]", ":", "if", "instance", "and", "instance", ".", "config", "[", "\"host\"", "]", "==", "ip_address...
[ 486, 4 ]
[ 491, 19 ]
python
en
['en', 'en', 'en']
True