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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
_expand_mask | (mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0) |
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
|
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
| def _expand_mask(mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0):
"""
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
"""
src_len = shape_list(mask)[1]
tgt_len = tgt_len if tgt_len is not None else src_len
one_cst = tf.consta... | [
"def",
"_expand_mask",
"(",
"mask",
":",
"tf",
".",
"Tensor",
",",
"tgt_len",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"src_len",
"=",
"shape_list",
"(",
"mask",
")",
"[",
"1",
"]",... | [
93,
0
] | [
103,
53
] | python | en | ['en', 'error', 'th'] | False |
TFLEDLearnedPositionalEmbedding.call | (self, input_shape: tf.TensorShape, past_key_values_length: int = 0) | Input is expected to be of size [bsz x seqlen]. | Input is expected to be of size [bsz x seqlen]. | def call(self, input_shape: tf.TensorShape, past_key_values_length: int = 0):
"""Input is expected to be of size [bsz x seqlen]."""
bsz, seq_len = input_shape[:2]
positions = tf.range(past_key_values_length, seq_len + past_key_values_length, delta=1, name="range")
return super().call(po... | [
"def",
"call",
"(",
"self",
",",
"input_shape",
":",
"tf",
".",
"TensorShape",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"seq_len",
"=",
"input_shape",
"[",
":",
"2",
"]",
"positions",
"=",
"tf",
".",
"range",
"(",
"p... | [
114,
4
] | [
119,
38
] | python | en | ['en', 'en', 'en'] | True |
TFLEDEncoderSelfAttention.call | (
self,
inputs,
training=False,
) |
LongformerSelfAttention expects `len(hidden_states)` to be multiple of `attention_window`. Padding to
`attention_window` happens in LongformerModel.forward to avoid redoing the padding on each layer.
The `attention_mask` is changed in :meth:`LongformerModel.forward` from 0, 1, 2 to:
... |
LongformerSelfAttention expects `len(hidden_states)` to be multiple of `attention_window`. Padding to
`attention_window` happens in LongformerModel.forward to avoid redoing the padding on each layer. | def call(
self,
inputs,
training=False,
):
"""
LongformerSelfAttention expects `len(hidden_states)` to be multiple of `attention_window`. Padding to
`attention_window` happens in LongformerModel.forward to avoid redoing the padding on each layer.
The `attenti... | [
"def",
"call",
"(",
"self",
",",
"inputs",
",",
"training",
"=",
"False",
",",
")",
":",
"# retrieve input args",
"(",
"hidden_states",
",",
"attention_mask",
",",
"layer_head_mask",
",",
"is_index_masked",
",",
"is_index_global_attn",
",",
"is_global_attn",
",",
... | [
182,
4
] | [
371,
22
] | python | en | ['en', 'error', 'th'] | False |
TFLEDEncoderSelfAttention._sliding_chunks_query_key_matmul | (self, query, key, window_overlap) |
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained Longformer) with an
overlap of size window_overlap
|
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained Longformer) with an
overlap of size window_overlap
| def _sliding_chunks_query_key_matmul(self, query, key, window_overlap):
"""
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained Longformer) with an
o... | [
"def",
"_sliding_chunks_query_key_matmul",
"(",
"self",
",",
"query",
",",
"key",
",",
"window_overlap",
")",
":",
"batch_size",
",",
"seq_len",
",",
"num_heads",
",",
"head_dim",
"=",
"shape_list",
"(",
"query",
")",
"if",
"tf",
".",
"executing_eagerly",
"(",... | [
373,
4
] | [
485,
40
] | python | en | ['en', 'error', 'th'] | False |
TFLEDEncoderSelfAttention._sliding_chunks_matmul_attn_probs_value | (self, attn_probs, value, window_overlap) |
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
|
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
| def _sliding_chunks_matmul_attn_probs_value(self, attn_probs, value, window_overlap):
"""
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
"""
batch_size, seq_len, num_heads, head_dim = shape... | [
"def",
"_sliding_chunks_matmul_attn_probs_value",
"(",
"self",
",",
"attn_probs",
",",
"value",
",",
"window_overlap",
")",
":",
"batch_size",
",",
"seq_len",
",",
"num_heads",
",",
"head_dim",
"=",
"shape_list",
"(",
"value",
")",
"if",
"tf",
".",
"executing_ea... | [
517,
4
] | [
592,
22
] | python | en | ['en', 'error', 'th'] | False |
TFLEDEncoderSelfAttention._pad_and_transpose_last_two_dims | (hidden_states_padded, paddings) | pads rows and then flips rows and columns | pads rows and then flips rows and columns | def _pad_and_transpose_last_two_dims(hidden_states_padded, paddings):
"""pads rows and then flips rows and columns"""
hidden_states_padded = tf.pad(
hidden_states_padded, paddings
) # padding value is not important because it will be overwritten
batch_size, chunk_size, seq_l... | [
"def",
"_pad_and_transpose_last_two_dims",
"(",
"hidden_states_padded",
",",
"paddings",
")",
":",
"hidden_states_padded",
"=",
"tf",
".",
"pad",
"(",
"hidden_states_padded",
",",
"paddings",
")",
"# padding value is not important because it will be overwritten",
"batch_size",
... | [
595,
4
] | [
603,
35
] | python | en | ['en', 'en', 'en'] | True |
TFLEDEncoderSelfAttention._pad_and_diagonalize | (chunked_hidden_states) |
shift every row 1 step right, converting columns into diagonals.
Example::
chunked_hidden_states: [ 0.4983, 2.6918, -0.0071, 1.0492,
-1.8348, 0.7672, 0.2986, 0.0285,
-0.7584, 0.4206, -0.0405, 0.1599,
... |
shift every row 1 step right, converting columns into diagonals. | def _pad_and_diagonalize(chunked_hidden_states):
"""
shift every row 1 step right, converting columns into diagonals.
Example::
chunked_hidden_states: [ 0.4983, 2.6918, -0.0071, 1.0492,
-1.8348, 0.7672, 0.2986, 0.0285,
... | [
"def",
"_pad_and_diagonalize",
"(",
"chunked_hidden_states",
")",
":",
"total_num_heads",
",",
"num_chunks",
",",
"window_overlap",
",",
"hidden_dim",
"=",
"shape_list",
"(",
"chunked_hidden_states",
")",
"paddings",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"[",
"[... | [
606,
4
] | [
640,
36
] | python | en | ['en', 'error', 'th'] | False |
TFLEDEncoderSelfAttention._chunk | (hidden_states, window_overlap) | convert into overlapping chunks. Chunk size = 2w, overlap size = w | convert into overlapping chunks. Chunk size = 2w, overlap size = w | def _chunk(hidden_states, window_overlap):
"""convert into overlapping chunks. Chunk size = 2w, overlap size = w"""
batch_size, seq_length, hidden_dim = shape_list(hidden_states)
num_output_chunks = 2 * (seq_length // (2 * window_overlap)) - 1
# define frame size and frame stride (simil... | [
"def",
"_chunk",
"(",
"hidden_states",
",",
"window_overlap",
")",
":",
"batch_size",
",",
"seq_length",
",",
"hidden_dim",
"=",
"shape_list",
"(",
"hidden_states",
")",
"num_output_chunks",
"=",
"2",
"*",
"(",
"seq_length",
"//",
"(",
"2",
"*",
"window_overla... | [
643,
4
] | [
668,
36
] | python | en | ['en', 'en', 'en'] | True |
TFLEDEncoderSelfAttention._get_global_attn_indices | (is_index_global_attn) | compute global attn indices required throughout forward pass | compute global attn indices required throughout forward pass | def _get_global_attn_indices(is_index_global_attn):
""" compute global attn indices required throughout forward pass """
# helper variable
num_global_attn_indices = tf.math.count_nonzero(is_index_global_attn, axis=1)
num_global_attn_indices = tf.cast(num_global_attn_indices, dtype=tf.con... | [
"def",
"_get_global_attn_indices",
"(",
"is_index_global_attn",
")",
":",
"# helper variable",
"num_global_attn_indices",
"=",
"tf",
".",
"math",
".",
"count_nonzero",
"(",
"is_index_global_attn",
",",
"axis",
"=",
"1",
")",
"num_global_attn_indices",
"=",
"tf",
".",
... | [
671,
4
] | [
699,
9
] | python | en | ['en', 'en', 'en'] | True |
TFLEDDecoderAttention.call | (
self,
hidden_states: tf.Tensor,
key_value_states: Optional[tf.Tensor] = None,
past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None,
attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
training=False,
) | Input shape: Batch x Time x Channel | Input shape: Batch x Time x Channel | def call(
self,
hidden_states: tf.Tensor,
key_value_states: Optional[tf.Tensor] = None,
past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None,
attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
training=False,
) -> Tupl... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
":",
"tf",
".",
"Tensor",
",",
"key_value_states",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"past_key_value",
":",
"Optional",
"[",
"Tuple",
"[",
"Tuple",
"[",
"tf",
".",
"Tenso... | [
992,
4
] | [
1102,
56
] | python | en | ['en', 'pl', 'en'] | True |
TFLEDEncoderLayer.call | (
self,
hidden_states: tf.Tensor,
attention_mask: tf.Tensor,
layer_head_mask: tf.Tensor,
is_index_masked: tf.Tensor,
is_index_global_attn: tf.Tensor,
is_global_attn: bool,
training=False,
) |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
laye... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
laye... | def call(
self,
hidden_states: tf.Tensor,
attention_mask: tf.Tensor,
layer_head_mask: tf.Tensor,
is_index_masked: tf.Tensor,
is_index_global_attn: tf.Tensor,
is_global_attn: bool,
training=False,
):
"""
Args:
hidden_states (... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
":",
"tf",
".",
"Tensor",
",",
"attention_mask",
":",
"tf",
".",
"Tensor",
",",
"layer_head_mask",
":",
"tf",
".",
"Tensor",
",",
"is_index_masked",
":",
"tf",
".",
"Tensor",
",",
"is_index_global_attn",
":... | [
1118,
4
] | [
1162,
51
] | python | en | ['en', 'error', 'th'] | False |
TFLEDDecoderLayer.call | (
self,
hidden_states,
attention_mask: Optional[tf.Tensor] = None,
encoder_hidden_states: Optional[tf.Tensor] = None,
encoder_attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
encoder_layer_head_mask: Optional[tf.Tensor] = No... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
enco... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
enco... | def call(
self,
hidden_states,
attention_mask: Optional[tf.Tensor] = None,
encoder_hidden_states: Optional[tf.Tensor] = None,
encoder_attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
encoder_layer_head_mask: Optional[tf.Tens... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
",",
"attention_mask",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_hidden_states",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_attention_mask",
... | [
1193,
4
] | [
1268,
9
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass: HomeAssistant, config: dict) | Set up the xbox component. | Set up the xbox component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the xbox component."""
hass.data[DOMAIN] = {}
if DOMAIN not in config:
return True
config_flow.OAuth2FlowHandler.async_register_implementation(
hass,
config_entry_oauth2_flow.LocalOAuth2Implementation(
... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"config_flow",
".",
"OAuth2Flo... | [
52,
0
] | [
71,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up xbox from a config entry. | Set up xbox from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up xbox from a config entry."""
implementation = (
await config_entry_oauth2_flow.async_get_config_entry_implementation(
hass, entry
)
)
session = config_entry_oauth2_flow.OAuth2Session(hass, entry, ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"implementation",
"=",
"(",
"await",
"config_entry_oauth2_flow",
".",
"async_get_config_entry_implementation",
"(",
"hass",
",",
"entry",
")",
")",
... | [
74,
0
] | [
108,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""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",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
111,
0
] | [
127,
20
] | python | en | ['en', 'es', 'en'] | True |
_build_presence_data | (person: Person) | Build presence data from a person. | Build presence data from a person. | def _build_presence_data(person: Person) -> PresenceData:
"""Build presence data from a person."""
active_app: Optional[PresenceDetail] = None
try:
active_app = next(
presence for presence in person.presence_details if presence.is_primary
)
except StopIteration:
pass
... | [
"def",
"_build_presence_data",
"(",
"person",
":",
"Person",
")",
"->",
"PresenceData",
":",
"active_app",
":",
"Optional",
"[",
"PresenceDetail",
"]",
"=",
"None",
"try",
":",
"active_app",
"=",
"next",
"(",
"presence",
"for",
"presence",
"in",
"person",
".... | [
246,
0
] | [
268,
5
] | python | en | ['en', 'en', 'en'] | True |
XboxUpdateCoordinator.__init__ | (
self,
hass: HomeAssistantType,
client: XboxLiveClient,
consoles: SmartglassConsoleList,
) | Initialize. | Initialize. | def __init__(
self,
hass: HomeAssistantType,
client: XboxLiveClient,
consoles: SmartglassConsoleList,
) -> None:
"""Initialize."""
super().__init__(
hass,
_LOGGER,
name=DOMAIN,
update_interval=timedelta(seconds=10),
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
",",
"client",
":",
"XboxLiveClient",
",",
"consoles",
":",
"SmartglassConsoleList",
",",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
",",
"_LOGGER",
",",
... | [
166,
4
] | [
181,
55
] | python | en | ['en', 'en', 'it'] | False |
XboxUpdateCoordinator._async_update_data | (self) | Fetch the latest console status. | Fetch the latest console status. | async def _async_update_data(self) -> XboxData:
"""Fetch the latest console status."""
# Update Console Status
new_console_data: Dict[str, ConsoleData] = {}
for console in self.consoles.result:
current_state: Optional[ConsoleData] = self.data.consoles.get(console.id)
... | [
"async",
"def",
"_async_update_data",
"(",
"self",
")",
"->",
"XboxData",
":",
"# Update Console Status",
"new_console_data",
":",
"Dict",
"[",
"str",
",",
"ConsoleData",
"]",
"=",
"{",
"}",
"for",
"console",
"in",
"self",
".",
"consoles",
".",
"result",
":"... | [
183,
4
] | [
243,
56
] | python | en | ['en', 'en', 'en'] | True |
async_get_service | (hass, config, discovery_info=None) | Get the notification service. | Get the notification service. | async def async_get_service(hass, config, discovery_info=None):
"""Get the notification service."""
if discovery_info is None:
return
return NetgearNotifyService(hass, discovery_info) | [
"async",
"def",
"async_get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"return",
"NetgearNotifyService",
"(",
"hass",
",",
"discovery_info",
")"
] | [
13,
0
] | [
18,
53
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the demo light platform. | Set up the demo light platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the demo light platform."""
async_add_entities(
[
DemoLight(
unique_id="light_1",
name="Bed Light",
state=False,
available=True,
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"[",
"DemoLight",
"(",
"unique_id",
"=",
"\"light_1\"",
",",
"name",
"=",
"\"Bed Light\"",
","... | [
30,
0
] | [
58,
5
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Demo config entry. | Set up the Demo config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"await",
"async_setup_platform",
"(",
"hass",
",",
"{",
"}",
",",
"async_add_entities",
")"
] | [
61,
0
] | [
63,
60
] | python | en | ['en', 'en', 'en'] | True |
DemoLight.__init__ | (
self,
unique_id,
name,
state,
available=False,
hs_color=None,
ct=None,
brightness=180,
white=200,
effect_list=None,
effect=None,
) | Initialize the light. | Initialize the light. | def __init__(
self,
unique_id,
name,
state,
available=False,
hs_color=None,
ct=None,
brightness=180,
white=200,
effect_list=None,
effect=None,
):
"""Initialize the light."""
self._unique_id = unique_id
se... | [
"def",
"__init__",
"(",
"self",
",",
"unique_id",
",",
"name",
",",
"state",
",",
"available",
"=",
"False",
",",
"hs_color",
"=",
"None",
",",
"ct",
"=",
"None",
",",
"brightness",
"=",
"180",
",",
"white",
"=",
"200",
",",
"effect_list",
"=",
"None... | [
69,
4
] | [
96,
44
] | python | en | ['en', 'en', 'en'] | True |
DemoLight.device_info | (self) | Return device info. | Return device info. | def device_info(self):
"""Return device info."""
return {
"identifiers": {
# Serial numbers are unique identifiers within a specific domain
(DOMAIN, self.unique_id)
},
"name": self.name,
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"# Serial numbers are unique identifiers within a specific domain",
"(",
"DOMAIN",
",",
"self",
".",
"unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"... | [
99,
4
] | [
107,
9
] | python | en | ['es', 'hr', 'en'] | False |
DemoLight.should_poll | (self) | No polling needed for a demo light. | No polling needed for a demo light. | def should_poll(self) -> bool:
"""No polling needed for a demo light."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
110,
4
] | [
112,
20
] | python | en | ['en', 'en', 'en'] | True |
DemoLight.name | (self) | Return the name of the light if any. | Return the name of the light if any. | def name(self) -> str:
"""Return the name of the light if any."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
115,
4
] | [
117,
25
] | python | en | ['en', 'en', 'en'] | True |
DemoLight.unique_id | (self) | Return unique ID for light. | Return unique ID for light. | def unique_id(self):
"""Return unique ID for light."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
120,
4
] | [
122,
30
] | python | en | ['fr', 'la', 'en'] | False |
DemoLight.available | (self) | Return availability. | Return availability. | def available(self) -> bool:
"""Return availability."""
# This demo light is always available, but well-behaving components
# should implement this to inform Home Assistant accordingly.
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"# This demo light is always available, but well-behaving components",
"# should implement this to inform Home Assistant accordingly.",
"return",
"self",
".",
"_available"
] | [
125,
4
] | [
129,
30
] | python | en | ['fr', 'ga', 'en'] | False |
DemoLight.brightness | (self) | Return the brightness of this light between 0..255. | Return the brightness of this light between 0..255. | def brightness(self) -> int:
"""Return the brightness of this light between 0..255."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_brightness"
] | [
132,
4
] | [
134,
31
] | python | en | ['en', 'en', 'en'] | True |
DemoLight.hs_color | (self) | Return the hs color value. | Return the hs color value. | def hs_color(self) -> tuple:
"""Return the hs color value."""
if self._color_mode == "hs":
return self._hs_color
return None | [
"def",
"hs_color",
"(",
"self",
")",
"->",
"tuple",
":",
"if",
"self",
".",
"_color_mode",
"==",
"\"hs\"",
":",
"return",
"self",
".",
"_hs_color",
"return",
"None"
] | [
137,
4
] | [
141,
19
] | python | en | ['en', 'en', 'en'] | True |
DemoLight.color_temp | (self) | Return the CT color temperature. | Return the CT color temperature. | def color_temp(self) -> int:
"""Return the CT color temperature."""
if self._color_mode == "ct":
return self._ct
return None | [
"def",
"color_temp",
"(",
"self",
")",
"->",
"int",
":",
"if",
"self",
".",
"_color_mode",
"==",
"\"ct\"",
":",
"return",
"self",
".",
"_ct",
"return",
"None"
] | [
144,
4
] | [
148,
19
] | python | en | ['en', 'la', 'en'] | True |
DemoLight.white_value | (self) | Return the white value of this light between 0..255. | Return the white value of this light between 0..255. | def white_value(self) -> int:
"""Return the white value of this light between 0..255."""
return self._white | [
"def",
"white_value",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_white"
] | [
151,
4
] | [
153,
26
] | python | en | ['en', 'en', 'en'] | True |
DemoLight.effect_list | (self) | Return the list of supported effects. | Return the list of supported effects. | def effect_list(self) -> list:
"""Return the list of supported effects."""
return self._effect_list | [
"def",
"effect_list",
"(",
"self",
")",
"->",
"list",
":",
"return",
"self",
".",
"_effect_list"
] | [
156,
4
] | [
158,
32
] | python | en | ['en', 'en', 'en'] | True |
DemoLight.effect | (self) | Return the current effect. | Return the current effect. | def effect(self) -> str:
"""Return the current effect."""
return self._effect | [
"def",
"effect",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_effect"
] | [
161,
4
] | [
163,
27
] | python | en | ['en', 'en', 'en'] | True |
DemoLight.is_on | (self) | Return true if light is on. | Return true if light is on. | def is_on(self) -> bool:
"""Return true if light is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state"
] | [
166,
4
] | [
168,
26
] | python | en | ['en', 'et', 'en'] | True |
DemoLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self) -> int:
"""Flag supported features."""
return self._features | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_features"
] | [
171,
4
] | [
173,
29
] | python | en | ['da', 'en', 'en'] | True |
DemoLight.async_turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | async def async_turn_on(self, **kwargs) -> None:
"""Turn the light on."""
self._state = True
if ATTR_HS_COLOR in kwargs:
self._color_mode = "hs"
self._hs_color = kwargs[ATTR_HS_COLOR]
if ATTR_COLOR_TEMP in kwargs:
self._color_mode = "ct"
... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"self",
".",
"_state",
"=",
"True",
"if",
"ATTR_HS_COLOR",
"in",
"kwargs",
":",
"self",
".",
"_color_mode",
"=",
"\"hs\"",
"self",
".",
"_hs_color",
"=",
"kw... | [
175,
4
] | [
198,
35
] | python | en | ['en', 'et', 'en'] | True |
DemoLight.async_turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | async def async_turn_off(self, **kwargs) -> None:
"""Turn the light off."""
self._state = False
# As we have disabled polling, we need to inform
# Home Assistant about updates in our state ourselves.
self.async_write_ha_state() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"self",
".",
"_state",
"=",
"False",
"# As we have disabled polling, we need to inform",
"# Home Assistant about updates in our state ourselves.",
"self",
".",
"async_write_ha_... | [
200,
4
] | [
206,
35
] | python | en | ['en', 'zh', 'en'] | True |
valid_isy_commands | (value: Any) | Validate the command is valid. | Validate the command is valid. | def valid_isy_commands(value: Any) -> str:
"""Validate the command is valid."""
value = str(value).upper()
if value in COMMAND_FRIENDLY_NAME:
return value
raise vol.Invalid("Invalid ISY Command.") | [
"def",
"valid_isy_commands",
"(",
"value",
":",
"Any",
")",
"->",
"str",
":",
"value",
"=",
"str",
"(",
"value",
")",
".",
"upper",
"(",
")",
"if",
"value",
"in",
"COMMAND_FRIENDLY_NAME",
":",
"return",
"value",
"raise",
"vol",
".",
"Invalid",
"(",
"\"... | [
86,
0
] | [
91,
45
] | python | en | ['en', 'en', 'en'] | True |
async_setup_services | (hass: HomeAssistantType) | Create and register services for the ISY integration. | Create and register services for the ISY integration. | def async_setup_services(hass: HomeAssistantType):
"""Create and register services for the ISY integration."""
existing_services = hass.services.async_services().get(DOMAIN)
if existing_services and any(
service in INTEGRATION_SERVICES for service in existing_services
):
# Integration-le... | [
"def",
"async_setup_services",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"existing_services",
"=",
"hass",
".",
"services",
".",
"async_services",
"(",
")",
".",
"get",
"(",
"DOMAIN",
")",
"if",
"existing_services",
"and",
"any",
"(",
"service",
"in",
... | [
160,
0
] | [
378,
5
] | python | en | ['en', 'en', 'en'] | True |
async_unload_services | (hass: HomeAssistantType) | Unload services for the ISY integration. | Unload services for the ISY integration. | def async_unload_services(hass: HomeAssistantType):
"""Unload services for the ISY integration."""
if hass.data[DOMAIN]:
# There is still another config entry for this domain, don't remove services.
return
existing_services = hass.services.async_services().get(DOMAIN)
if not existing_se... | [
"def",
"async_unload_services",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"if",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
":",
"# There is still another config entry for this domain, don't remove services.",
"return",
"existing_services",
"=",
"hass",
".",
"services... | [
382,
0
] | [
402,
80
] | python | en | ['en', 'en', 'en'] | True |
async_setup_light_services | (hass: HomeAssistantType) | Create device-specific services for the ISY Integration. | Create device-specific services for the ISY Integration. | def async_setup_light_services(hass: HomeAssistantType):
"""Create device-specific services for the ISY Integration."""
platform = entity_platform.current_platform.get()
platform.async_register_entity_service(
SERVICE_SET_ON_LEVEL, SERVICE_SET_VALUE_SCHEMA, SERVICE_SET_ON_LEVEL
)
platform.a... | [
"def",
"async_setup_light_services",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"platform",
"=",
"entity_platform",
".",
"current_platform",
".",
"get",
"(",
")",
"platform",
".",
"async_register_entity_service",
"(",
"SERVICE_SET_ON_LEVEL",
",",
"SERVICE_SET_VALU... | [
406,
0
] | [
415,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Ted5000 sensor. | Set up the Ted5000 sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Ted5000 sensor."""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
name = config.get(CONF_NAME)
url = f"http://{host}:{port}/api/LiveData.xml"
gateway = Ted5000Gateway(url)
# Get MUT information to... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
")",
"name",
"=",
"co... | [
30,
0
] | [
48,
15
] | python | en | ['en', 'da', 'en'] | True |
Ted5000Sensor.__init__ | (self, gateway, name, mtu, unit) | Initialize the sensor. | Initialize the sensor. | def __init__(self, gateway, name, mtu, unit):
"""Initialize the sensor."""
units = {POWER_WATT: "power", VOLT: "voltage"}
self._gateway = gateway
self._name = "{} mtu{} {}".format(name, mtu, units[unit])
self._mtu = mtu
self._unit = unit
self.update() | [
"def",
"__init__",
"(",
"self",
",",
"gateway",
",",
"name",
",",
"mtu",
",",
"unit",
")",
":",
"units",
"=",
"{",
"POWER_WATT",
":",
"\"power\"",
",",
"VOLT",
":",
"\"voltage\"",
"}",
"self",
".",
"_gateway",
"=",
"gateway",
"self",
".",
"_name",
"=... | [
54,
4
] | [
61,
21
] | python | en | ['en', 'en', 'en'] | True |
Ted5000Sensor.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"
] | [
64,
4
] | [
66,
25
] | python | en | ['en', 'mi', 'en'] | True |
Ted5000Sensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit"
] | [
69,
4
] | [
71,
25
] | python | en | ['en', 'en', 'en'] | True |
Ted5000Sensor.state | (self) | Return the state of the resources. | Return the state of the resources. | def state(self):
"""Return the state of the resources."""
try:
return self._gateway.data[self._mtu][self._unit]
except KeyError:
pass | [
"def",
"state",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_gateway",
".",
"data",
"[",
"self",
".",
"_mtu",
"]",
"[",
"self",
".",
"_unit",
"]",
"except",
"KeyError",
":",
"pass"
] | [
74,
4
] | [
79,
16
] | python | en | ['en', 'en', 'en'] | True |
Ted5000Sensor.update | (self) | Get the latest data from REST API. | Get the latest data from REST API. | def update(self):
"""Get the latest data from REST API."""
self._gateway.update() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_gateway",
".",
"update",
"(",
")"
] | [
81,
4
] | [
83,
30
] | python | en | ['en', 'en', 'en'] | True |
Ted5000Gateway.__init__ | (self, url) | Initialize the data object. | Initialize the data object. | def __init__(self, url):
"""Initialize the data object."""
self.url = url
self.data = {} | [
"def",
"__init__",
"(",
"self",
",",
"url",
")",
":",
"self",
".",
"url",
"=",
"url",
"self",
".",
"data",
"=",
"{",
"}"
] | [
89,
4
] | [
92,
22
] | python | en | ['en', 'en', 'en'] | True |
Ted5000Gateway.update | (self) | Get the latest data from the Ted5000 XML API. | Get the latest data from the Ted5000 XML API. | def update(self):
"""Get the latest data from the Ted5000 XML API."""
try:
request = requests.get(self.url, timeout=10)
except requests.exceptions.RequestException as err:
_LOGGER.error("No connection to endpoint: %s", err)
else:
doc = xmltodict.parse... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"url",
",",
"timeout",
"=",
"10",
")",
"except",
"requests",
".",
"exceptions",
".",
"RequestException",
"as",
"err",
":",
"_LOGGER",
".",
"... | [
95,
4
] | [
110,
72
] | python | en | ['en', 'en', 'en'] | True |
test_duplicate_error | (hass) | Test that errors are shown when duplicate entries are added. | Test that errors are shown when duplicate entries are added. | async def test_duplicate_error(hass):
"""Test that errors are shown when duplicate entries are added."""
geography_conf = {
CONF_API_KEY: "abcde12345",
CONF_LATITUDE: 51.528308,
CONF_LONGITUDE: -0.3817765,
}
MockConfigEntry(
domain=DOMAIN, unique_id="51.528308, -0.381776... | [
"async",
"def",
"test_duplicate_error",
"(",
"hass",
")",
":",
"geography_conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"abcde12345\"",
",",
"CONF_LATITUDE",
":",
"51.528308",
",",
"CONF_LONGITUDE",
":",
"-",
"0.3817765",
",",
"}",
"MockConfigEntry",
"(",
"domain",
"=... | [
26,
0
] | [
62,
51
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_identifier | (hass) | Test that an invalid API key or Node/Pro ID throws an error. | Test that an invalid API key or Node/Pro ID throws an error. | async def test_invalid_identifier(hass):
"""Test that an invalid API key or Node/Pro ID throws an error."""
geography_conf = {
CONF_API_KEY: "abcde12345",
CONF_LATITUDE: 51.528308,
CONF_LONGITUDE: -0.3817765,
}
with patch(
"pyairvisual.air_quality.AirQuality.nearest_city... | [
"async",
"def",
"test_invalid_identifier",
"(",
"hass",
")",
":",
"geography_conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"abcde12345\"",
",",
"CONF_LATITUDE",
":",
"51.528308",
",",
"CONF_LONGITUDE",
":",
"-",
"0.3817765",
",",
"}",
"with",
"patch",
"(",
"\"pyairvis... | [
65,
0
] | [
87,
68
] | python | en | ['en', 'en', 'en'] | True |
test_migration | (hass) | Test migrating from version 1 to the current version. | Test migrating from version 1 to the current version. | async def test_migration(hass):
"""Test migrating from version 1 to the current version."""
conf = {
CONF_API_KEY: "abcde12345",
CONF_GEOGRAPHIES: [
{CONF_LATITUDE: 51.528308, CONF_LONGITUDE: -0.3817765},
{CONF_LATITUDE: 35.48847, CONF_LONGITUDE: 137.5263065},
],
... | [
"async",
"def",
"test_migration",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"abcde12345\"",
",",
"CONF_GEOGRAPHIES",
":",
"[",
"{",
"CONF_LATITUDE",
":",
"51.528308",
",",
"CONF_LONGITUDE",
":",
"-",
"0.3817765",
"}",
",",
"{",
"CONF_LA... | [
90,
0
] | [
133,
5
] | python | en | ['en', 'en', 'en'] | True |
test_node_pro_error | (hass) | Test that an invalid Node/Pro ID shows an error. | Test that an invalid Node/Pro ID shows an error. | async def test_node_pro_error(hass):
"""Test that an invalid Node/Pro ID shows an error."""
node_pro_conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PASSWORD: "my_password"}
with patch(
"pyairvisual.node.NodeSamba.async_connect",
side_effect=NodeProError,
):
result = await hass.c... | [
"async",
"def",
"test_node_pro_error",
"(",
"hass",
")",
":",
"node_pro_conf",
"=",
"{",
"CONF_IP_ADDRESS",
":",
"\"192.168.1.100\"",
",",
"CONF_PASSWORD",
":",
"\"my_password\"",
"}",
"with",
"patch",
"(",
"\"pyairvisual.node.NodeSamba.async_connect\"",
",",
"side_effe... | [
136,
0
] | [
151,
70
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow | (hass) | Test config flow options. | Test config flow options. | async def test_options_flow(hass):
"""Test config flow options."""
geography_conf = {
CONF_API_KEY: "abcde12345",
CONF_LATITUDE: 51.528308,
CONF_LONGITUDE: -0.3817765,
}
config_entry = MockConfigEntry(
domain=DOMAIN,
unique_id="51.528308, -0.3817765",
dat... | [
"async",
"def",
"test_options_flow",
"(",
"hass",
")",
":",
"geography_conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"abcde12345\"",
",",
"CONF_LATITUDE",
":",
"51.528308",
",",
"CONF_LONGITUDE",
":",
"-",
"0.3817765",
",",
"}",
"config_entry",
"=",
"MockConfigEntry",
... | [
154,
0
] | [
184,
64
] | python | en | ['en', 'fr', 'en'] | True |
test_step_geography | (hass) | Test the geograph (cloud API) step. | Test the geograph (cloud API) step. | async def test_step_geography(hass):
"""Test the geograph (cloud API) step."""
conf = {
CONF_API_KEY: "abcde12345",
CONF_LATITUDE: 51.528308,
CONF_LONGITUDE: -0.3817765,
}
with patch(
"homeassistant.components.airvisual.async_setup_entry", return_value=True
), patch(... | [
"async",
"def",
"test_step_geography",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"abcde12345\"",
",",
"CONF_LATITUDE",
":",
"51.528308",
",",
"CONF_LONGITUDE",
":",
"-",
"0.3817765",
",",
"}",
"with",
"patch",
"(",
"\"homeassistant.componen... | [
187,
0
] | [
214,
9
] | python | en | ['en', 'en', 'en'] | True |
test_step_node_pro | (hass) | Test the Node/Pro step. | Test the Node/Pro step. | async def test_step_node_pro(hass):
"""Test the Node/Pro step."""
conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PASSWORD: "my_password"}
with patch(
"homeassistant.components.airvisual.async_setup_entry", return_value=True
), patch("pyairvisual.node.NodeSamba.async_connect"), patch(
"p... | [
"async",
"def",
"test_step_node_pro",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_IP_ADDRESS",
":",
"\"192.168.1.100\"",
",",
"CONF_PASSWORD",
":",
"\"my_password\"",
"}",
"with",
"patch",
"(",
"\"homeassistant.components.airvisual.async_setup_entry\"",
",",
"return_... | [
217,
0
] | [
240,
9
] | python | en | ['en', 'en', 'en'] | True |
test_step_reauth | (hass) | Test that the reauth step works. | Test that the reauth step works. | async def test_step_reauth(hass):
"""Test that the reauth step works."""
geography_conf = {
CONF_API_KEY: "abcde12345",
CONF_LATITUDE: 51.528308,
CONF_LONGITUDE: -0.3817765,
}
MockConfigEntry(
domain=DOMAIN, unique_id="51.528308, -0.3817765", data=geography_conf
).ad... | [
"async",
"def",
"test_step_reauth",
"(",
"hass",
")",
":",
"geography_conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"abcde12345\"",
",",
"CONF_LATITUDE",
":",
"51.528308",
",",
"CONF_LONGITUDE",
":",
"-",
"0.3817765",
",",
"}",
"MockConfigEntry",
"(",
"domain",
"=",
... | [
243,
0
] | [
273,
56
] | python | en | ['en', 'en', 'en'] | True |
test_step_user | (hass) | Test the user ("pick the integration type") step. | Test the user ("pick the integration type") step. | async def test_step_user(hass):
"""Test the user ("pick the integration type") step."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user"
result = aw... | [
"async",
"def",
"test_step_user",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
")",
"assert",
"result",
"[",
... | [
276,
0
] | [
301,
42
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: Dict) | Set up the component. | Set up the component. | async def async_setup(hass: HomeAssistant, config: Dict) -> bool:
"""Set up the component."""
hass.data.setdefault(DOMAIN, {})
if len(hass.config_entries.async_entries(DOMAIN)) > 0:
return True
if DOMAIN in config and CONF_API_KEY in config[DOMAIN]:
persistent_notification.async_create... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"Dict",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"if",
"len",
"(",
"hass",
".",
"config_entries",
".",
"as... | [
53,
0
] | [
68,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Cloudflare from a config entry. | Set up Cloudflare from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Cloudflare from a config entry."""
cfupdate = CloudflareUpdater(
async_get_clientsession(hass),
entry.data[CONF_API_TOKEN],
entry.data[CONF_ZONE],
entry.data[CONF_RECORDS],
)
try:
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"cfupdate",
"=",
"CloudflareUpdater",
"(",
"async_get_clientsession",
"(",
"hass",
")",
",",
"entry",
".",
"data",
"[",
"CONF_API_... | [
71,
0
] | [
111,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload Cloudflare config entry. | Unload Cloudflare config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload Cloudflare config entry."""
hass.data[DOMAIN][entry.entry_id][DATA_UNDO_UPDATE_INTERVAL]()
hass.data[DOMAIN].pop(entry.entry_id)
return True | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"[",
"DATA_UNDO_UPDATE_INTERVAL",
"]",
"(",
")",... | [
114,
0
] | [
119,
15
] | python | en | ['en', 'en', 'en'] | True |
test_cached_event_message | (hass) | Test that we cache event messages. | Test that we cache event messages. | async def test_cached_event_message(hass):
"""Test that we cache event messages."""
events = []
@callback
def _event_listener(event):
events.append(event)
hass.bus.async_listen(EVENT_STATE_CHANGED, _event_listener)
hass.states.async_set("light.window", "on")
hass.states.async_set... | [
"async",
"def",
"test_cached_event_message",
"(",
"hass",
")",
":",
"events",
"=",
"[",
"]",
"@",
"callback",
"def",
"_event_listener",
"(",
"event",
")",
":",
"events",
".",
"append",
"(",
"event",
")",
"hass",
".",
"bus",
".",
"async_listen",
"(",
"EVE... | [
11,
0
] | [
46,
35
] | python | en | ['en', 'en', 'en'] | True |
test_cached_event_message_with_different_idens | (hass) | Test that we cache event messages when the subscrition idens differ. | Test that we cache event messages when the subscrition idens differ. | async def test_cached_event_message_with_different_idens(hass):
"""Test that we cache event messages when the subscrition idens differ."""
events = []
@callback
def _event_listener(event):
events.append(event)
hass.bus.async_listen(EVENT_STATE_CHANGED, _event_listener)
hass.states.as... | [
"async",
"def",
"test_cached_event_message_with_different_idens",
"(",
"hass",
")",
":",
"events",
"=",
"[",
"]",
"@",
"callback",
"def",
"_event_listener",
"(",
"event",
")",
":",
"events",
".",
"append",
"(",
"event",
")",
"hass",
".",
"bus",
".",
"async_l... | [
49,
0
] | [
77,
35
] | python | en | ['en', 'en', 'en'] | True |
test_message_to_json | (caplog) | Test we can serialize websocket messages. | Test we can serialize websocket messages. | async def test_message_to_json(caplog):
"""Test we can serialize websocket messages."""
json_str = message_to_json({"id": 1, "message": "xyz"})
assert json_str == '{"id": 1, "message": "xyz"}'
json_str2 = message_to_json({"id": 1, "message": _Unserializeable()})
assert (
json_str2
... | [
"async",
"def",
"test_message_to_json",
"(",
"caplog",
")",
":",
"json_str",
"=",
"message_to_json",
"(",
"{",
"\"id\"",
":",
"1",
",",
"\"message\"",
":",
"\"xyz\"",
"}",
")",
"assert",
"json_str",
"==",
"'{\"id\": 1, \"message\": \"xyz\"}'",
"json_str2",
"=",
... | [
80,
0
] | [
93,
55
] | python | en | ['en', 'da', 'en'] | True |
test_create_doorbell | (hass, aiohttp_client) | Test creation of a doorbell. | Test creation of a doorbell. | async def test_create_doorbell(hass, aiohttp_client):
"""Test creation of a doorbell."""
doorbell_one = await _mock_doorbell_from_fixture(hass, "get_doorbell.json")
with patch.object(
doorbell_one, "async_get_doorbell_image", create=False, return_value="image"
):
await _create_august_wi... | [
"async",
"def",
"test_create_doorbell",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"doorbell_one",
"=",
"await",
"_mock_doorbell_from_fixture",
"(",
"hass",
",",
"\"get_doorbell.json\"",
")",
"with",
"patch",
".",
"object",
"(",
"doorbell_one",
",",
"\"async_get_... | [
11,
0
] | [
33,
30
] | python | en | ['en', 'lb', 'en'] | True |
test_onewiredirect_setup_valid_device | (hass, device_id) | Test that sysbus config entry works correctly. | Test that sysbus config entry works correctly. | async def test_onewiredirect_setup_valid_device(hass, device_id):
"""Test that sysbus config entry works correctly."""
entity_registry = mock_registry(hass)
device_registry = mock_device_registry(hass)
mock_device_sensor = MOCK_DEVICE_SENSORS[device_id]
glob_result = [f"/{DEFAULT_SYSBUS_MOUNT_DIR}... | [
"async",
"def",
"test_onewiredirect_setup_valid_device",
"(",
"hass",
",",
"device_id",
")",
":",
"entity_registry",
"=",
"mock_registry",
"(",
"hass",
")",
"device_registry",
"=",
"mock_device_registry",
"(",
"hass",
")",
"mock_device_sensor",
"=",
"MOCK_DEVICE_SENSORS... | [
128,
0
] | [
173,
55
] | python | en | ['en', 'en', 'en'] | True |
test_reload_platform | (hass) | Test the polling of only updated entities. | Test the polling of only updated entities. | async def test_reload_platform(hass):
"""Test the polling of only updated entities."""
component_setup = Mock(return_value=True)
setup_called = []
async def setup_platform(*args):
setup_called.append(args)
mock_integration(hass, MockModule(DOMAIN, setup=component_setup))
mock_integrat... | [
"async",
"def",
"test_reload_platform",
"(",
"hass",
")",
":",
"component_setup",
"=",
"Mock",
"(",
"return_value",
"=",
"True",
")",
"setup_called",
"=",
"[",
"]",
"async",
"def",
"setup_platform",
"(",
"*",
"args",
")",
":",
"setup_called",
".",
"append",
... | [
31,
0
] | [
72,
78
] | python | en | ['en', 'en', 'en'] | True |
test_setup_reload_service | (hass) | Test setting up a reload service. | Test setting up a reload service. | async def test_setup_reload_service(hass):
"""Test setting up a reload service."""
component_setup = Mock(return_value=True)
setup_called = []
async def setup_platform(*args):
setup_called.append(args)
mock_integration(hass, MockModule(DOMAIN, setup=component_setup))
mock_integration(... | [
"async",
"def",
"test_setup_reload_service",
"(",
"hass",
")",
":",
"component_setup",
"=",
"Mock",
"(",
"return_value",
"=",
"True",
")",
"setup_called",
"=",
"[",
"]",
"async",
"def",
"setup_platform",
"(",
"*",
"args",
")",
":",
"setup_called",
".",
"appe... | [
75,
0
] | [
115,
33
] | python | en | ['en', 'en', 'en'] | True |
test_setup_reload_service_when_async_process_component_config_fails | (hass) | Test setting up a reload service with the config processing failing. | Test setting up a reload service with the config processing failing. | async def test_setup_reload_service_when_async_process_component_config_fails(hass):
"""Test setting up a reload service with the config processing failing."""
component_setup = Mock(return_value=True)
setup_called = []
async def setup_platform(*args):
setup_called.append(args)
mock_integ... | [
"async",
"def",
"test_setup_reload_service_when_async_process_component_config_fails",
"(",
"hass",
")",
":",
"component_setup",
"=",
"Mock",
"(",
"return_value",
"=",
"True",
")",
"setup_called",
"=",
"[",
"]",
"async",
"def",
"setup_platform",
"(",
"*",
"args",
")... | [
118,
0
] | [
160,
33
] | python | en | ['en', 'en', 'en'] | True |
test_setup_reload_service_with_platform_that_provides_async_reset_platform | (
hass,
) | Test setting up a reload service using a platform that has its own async_reset_platform. | Test setting up a reload service using a platform that has its own async_reset_platform. | async def test_setup_reload_service_with_platform_that_provides_async_reset_platform(
hass,
):
"""Test setting up a reload service using a platform that has its own async_reset_platform."""
component_setup = AsyncMock(return_value=True)
setup_called = []
async_reset_platform_called = []
async ... | [
"async",
"def",
"test_setup_reload_service_with_platform_that_provides_async_reset_platform",
"(",
"hass",
",",
")",
":",
"component_setup",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"setup_called",
"=",
"[",
"]",
"async_reset_platform_called",
"=",
"[",
... | [
163,
0
] | [
213,
48
] | python | en | ['en', 'en', 'en'] | True |
test_async_integration_yaml_config | (hass) | Test loading yaml config for an integration. | Test loading yaml config for an integration. | async def test_async_integration_yaml_config(hass):
"""Test loading yaml config for an integration."""
mock_integration(hass, MockModule(DOMAIN))
yaml_path = path.join(
_get_fixtures_base_path(),
"fixtures",
f"helpers/{DOMAIN}_configuration.yaml",
)
with patch.object(config,... | [
"async",
"def",
"test_async_integration_yaml_config",
"(",
"hass",
")",
":",
"mock_integration",
"(",
"hass",
",",
"MockModule",
"(",
"DOMAIN",
")",
")",
"yaml_path",
"=",
"path",
".",
"join",
"(",
"_get_fixtures_base_path",
"(",
")",
",",
"\"fixtures\"",
",",
... | [
216,
0
] | [
228,
75
] | python | en | ['en', 'en', 'en'] | True |
test_async_integration_missing_yaml_config | (hass) | Test loading missing yaml config for an integration. | Test loading missing yaml config for an integration. | async def test_async_integration_missing_yaml_config(hass):
"""Test loading missing yaml config for an integration."""
mock_integration(hass, MockModule(DOMAIN))
yaml_path = path.join(
_get_fixtures_base_path(),
"fixtures",
"helpers/does_not_exist_configuration.yaml",
)
with... | [
"async",
"def",
"test_async_integration_missing_yaml_config",
"(",
"hass",
")",
":",
"mock_integration",
"(",
"hass",
",",
"MockModule",
"(",
"DOMAIN",
")",
")",
"yaml_path",
"=",
"path",
".",
"join",
"(",
"_get_fixtures_base_path",
"(",
")",
",",
"\"fixtures\"",
... | [
231,
0
] | [
243,
57
] | python | en | ['en', 'en', 'en'] | True |
test_reproducing_states | (hass) | Test reproducing input_boolean states. | Test reproducing input_boolean states. | async def test_reproducing_states(hass):
"""Test reproducing input_boolean states."""
assert await async_setup_component(
hass,
"input_boolean",
{
"input_boolean": {
"initial_on": {"initial": True},
"initial_off": {"initial": False},
... | [
"async",
"def",
"test_reproducing_states",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"input_boolean\"",
",",
"{",
"\"input_boolean\"",
":",
"{",
"\"initial_on\"",
":",
"{",
"\"initial\"",
":",
"True",
"}",
",",
"\"ini... | [
5,
0
] | [
38,
69
] | python | en | ['en', 'en', 'en'] | True |
async_get_code | (hass, aiohttp_client) | Return authorization code for link user tests. | Return authorization code for link user tests. | async def async_get_code(hass, aiohttp_client):
"""Return authorization code for link user tests."""
config = [
{
"name": "Example",
"type": "insecure_example",
"users": [
{"username": "test-user", "password": "test-pass", "name": "Test Name"}
... | [
"async",
"def",
"async_get_code",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"config",
"=",
"[",
"{",
"\"name\"",
":",
"\"Example\"",
",",
"\"type\"",
":",
"\"insecure_example\"",
",",
"\"users\"",
":",
"[",
"{",
"\"username\"",
":",
"\"test-user\"",
",",
... | [
6,
0
] | [
56,
5
] | python | en | ['nb', 'en', 'en'] | True |
test_link_user | (hass, aiohttp_client) | Test linking a user to new credentials. | Test linking a user to new credentials. | async def test_link_user(hass, aiohttp_client):
"""Test linking a user to new credentials."""
info = await async_get_code(hass, aiohttp_client)
client = info["client"]
code = info["code"]
# Link user
resp = await client.post(
"/auth/link_user",
json={"client_id": CLIENT_ID, "cod... | [
"async",
"def",
"test_link_user",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"info",
"=",
"await",
"async_get_code",
"(",
"hass",
",",
"aiohttp_client",
")",
"client",
"=",
"info",
"[",
"\"client\"",
"]",
"code",
"=",
"info",
"[",
"\"code\"",
"]",
"# Li... | [
59,
0
] | [
73,
45
] | python | en | ['en', 'en', 'en'] | True |
test_link_user_invalid_client_id | (hass, aiohttp_client) | Test linking a user to new credentials. | Test linking a user to new credentials. | async def test_link_user_invalid_client_id(hass, aiohttp_client):
"""Test linking a user to new credentials."""
info = await async_get_code(hass, aiohttp_client)
client = info["client"]
code = info["code"]
# Link user
resp = await client.post(
"/auth/link_user",
json={"client_id... | [
"async",
"def",
"test_link_user_invalid_client_id",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"info",
"=",
"await",
"async_get_code",
"(",
"hass",
",",
"aiohttp_client",
")",
"client",
"=",
"info",
"[",
"\"client\"",
"]",
"code",
"=",
"info",
"[",
"\"code\... | [
76,
0
] | [
90,
45
] | python | en | ['en', 'en', 'en'] | True |
test_link_user_invalid_code | (hass, aiohttp_client) | Test linking a user to new credentials. | Test linking a user to new credentials. | async def test_link_user_invalid_code(hass, aiohttp_client):
"""Test linking a user to new credentials."""
info = await async_get_code(hass, aiohttp_client)
client = info["client"]
# Link user
resp = await client.post(
"/auth/link_user",
json={"client_id": CLIENT_ID, "code": "invali... | [
"async",
"def",
"test_link_user_invalid_code",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"info",
"=",
"await",
"async_get_code",
"(",
"hass",
",",
"aiohttp_client",
")",
"client",
"=",
"info",
"[",
"\"client\"",
"]",
"# Link user",
"resp",
"=",
"await",
"c... | [
93,
0
] | [
106,
45
] | python | en | ['en', 'en', 'en'] | True |
test_link_user_invalid_auth | (hass, aiohttp_client) | Test linking a user to new credentials. | Test linking a user to new credentials. | async def test_link_user_invalid_auth(hass, aiohttp_client):
"""Test linking a user to new credentials."""
info = await async_get_code(hass, aiohttp_client)
client = info["client"]
code = info["code"]
# Link user
resp = await client.post(
"/auth/link_user",
json={"client_id": CL... | [
"async",
"def",
"test_link_user_invalid_auth",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"info",
"=",
"await",
"async_get_code",
"(",
"hass",
",",
"aiohttp_client",
")",
"client",
"=",
"info",
"[",
"\"client\"",
"]",
"code",
"=",
"info",
"[",
"\"code\"",
... | [
109,
0
] | [
123,
45
] | python | en | ['en', 'en', 'en'] | True |
test_form | (hass, requests_mock) | Test we get the form. | Test we get the form. | async def test_form(hass, requests_mock):
"""Test we get the form."""
hass.config.latitude = TEST_LATITUDE_WAVERTREE
hass.config.longitude = TEST_LONGITUDE_WAVERTREE
# all metoffice test data encapsulated in here
mock_json = json.loads(load_fixture("metoffice.json"))
all_sites = json.dumps(mock... | [
"async",
"def",
"test_form",
"(",
"hass",
",",
"requests_mock",
")",
":",
"hass",
".",
"config",
".",
"latitude",
"=",
"TEST_LATITUDE_WAVERTREE",
"hass",
".",
"config",
".",
"longitude",
"=",
"TEST_LONGITUDE_WAVERTREE",
"# all metoffice test data encapsulated in here",
... | [
18,
0
] | [
55,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_already_configured | (hass, requests_mock) | Test we handle duplicate entries. | Test we handle duplicate entries. | async def test_form_already_configured(hass, requests_mock):
"""Test we handle duplicate entries."""
hass.config.latitude = TEST_LATITUDE_WAVERTREE
hass.config.longitude = TEST_LONGITUDE_WAVERTREE
# all metoffice test data encapsulated in here
mock_json = json.loads(load_fixture("metoffice.json"))
... | [
"async",
"def",
"test_form_already_configured",
"(",
"hass",
",",
"requests_mock",
")",
":",
"hass",
".",
"config",
".",
"latitude",
"=",
"TEST_LATITUDE_WAVERTREE",
"hass",
".",
"config",
".",
"longitude",
"=",
"TEST_LONGITUDE_WAVERTREE",
"# all metoffice test data enca... | [
58,
0
] | [
87,
51
] | python | en | ['fr', 'en', 'en'] | True |
test_form_cannot_connect | (hass, requests_mock) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_cannot_connect(hass, requests_mock):
"""Test we handle cannot connect error."""
hass.config.latitude = TEST_LATITUDE_WAVERTREE
hass.config.longitude = TEST_LONGITUDE_WAVERTREE
requests_mock.get("/public/data/val/wxfcs/all/json/sitelist/", text="")
result = await hass.config_ent... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
",",
"requests_mock",
")",
":",
"hass",
".",
"config",
".",
"latitude",
"=",
"TEST_LATITUDE_WAVERTREE",
"hass",
".",
"config",
".",
"longitude",
"=",
"TEST_LONGITUDE_WAVERTREE",
"requests_mock",
".",
"get",
... | [
90,
0
] | [
107,
58
] | python | en | ['en', 'en', 'en'] | True |
test_form_unknown_error | (hass, mock_simple_manager_fail) | Test we handle unknown error. | Test we handle unknown error. | async def test_form_unknown_error(hass, mock_simple_manager_fail):
"""Test we handle unknown error."""
mock_instance = mock_simple_manager_fail.return_value
mock_instance.get_nearest_forecast_site.side_effect = ValueError
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"sou... | [
"async",
"def",
"test_form_unknown_error",
"(",
"hass",
",",
"mock_simple_manager_fail",
")",
":",
"mock_instance",
"=",
"mock_simple_manager_fail",
".",
"return_value",
"mock_instance",
".",
"get_nearest_forecast_site",
".",
"side_effect",
"=",
"ValueError",
"result",
"=... | [
110,
0
] | [
125,
51
] | python | en | ['en', 'de', 'en'] | True |
async_get_actions | (hass: HomeAssistant, device_id: str) | List device actions for Climate devices. | List device actions for Climate devices. | async def async_get_actions(hass: HomeAssistant, device_id: str) -> List[dict]:
"""List device actions for Climate devices."""
registry = await entity_registry.async_get_registry(hass)
actions = []
# Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_de... | [
"async",
"def",
"async_get_actions",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"actions",
"=",
"[",
"... | [
40,
0
] | [
74,
18
] | python | en | ['fr', 'en', 'en'] | True |
async_call_action_from_config | (
hass: HomeAssistant, config: dict, variables: dict, context: Optional[Context]
) | Execute a device action. | Execute a device action. | async def async_call_action_from_config(
hass: HomeAssistant, config: dict, variables: dict, context: Optional[Context]
) -> None:
"""Execute a device action."""
config = ACTION_SCHEMA(config)
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
if config[CONF_TYPE] == "set_hvac_mode":
... | [
"async",
"def",
"async_call_action_from_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
",",
"variables",
":",
"dict",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
")",
"->",
"None",
":",
"config",
"=",
"ACTION_SCHEMA",
"(",
... | [
77,
0
] | [
94,
5
] | python | en | ['ro', 'en', 'en'] | True |
async_get_action_capabilities | (hass, config) | List action capabilities. | List action capabilities. | async def async_get_action_capabilities(hass, config):
"""List action capabilities."""
state = hass.states.get(config[CONF_ENTITY_ID])
action_type = config[CONF_TYPE]
fields = {}
if action_type == "set_hvac_mode":
hvac_modes = state.attributes[const.ATTR_HVAC_MODES] if state else []
... | [
"async",
"def",
"async_get_action_capabilities",
"(",
"hass",
",",
"config",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"config",
"[",
"CONF_ENTITY_ID",
"]",
")",
"action_type",
"=",
"config",
"[",
"CONF_TYPE",
"]",
"fields",
"=",
"{",... | [
97,
0
] | [
114,
47
] | python | en | ['ro', 'ga', 'en'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Perform the setup for Envisalink sensor devices. | Perform the setup for Envisalink sensor devices. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Perform the setup for Envisalink sensor devices."""
configured_partitions = discovery_info["partitions"]
devices = []
for part_num in configured_partitions:
device_config_data = PARTITION_SCHEMA(configured... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"configured_partitions",
"=",
"discovery_info",
"[",
"\"partitions\"",
"]",
"devices",
"=",
"[",
"]",
"for",
"part_num",
... | [
19,
0
] | [
36,
31
] | python | en | ['en', 'da', 'en'] | True |
EnvisalinkSensor.__init__ | (self, hass, partition_name, partition_number, info, controller) | Initialize the sensor. | Initialize the sensor. | def __init__(self, hass, partition_name, partition_number, info, controller):
"""Initialize the sensor."""
self._icon = "mdi:alarm"
self._partition_number = partition_number
_LOGGER.debug("Setting up sensor for partition: %s", partition_name)
super().__init__(f"{partition_name} ... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"partition_name",
",",
"partition_number",
",",
"info",
",",
"controller",
")",
":",
"self",
".",
"_icon",
"=",
"\"mdi:alarm\"",
"self",
".",
"_partition_number",
"=",
"partition_number",
"_LOGGER",
".",
"debug... | [
42,
4
] | [
48,
70
] | python | en | ['en', 'en', 'en'] | True |
EnvisalinkSensor.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
async_dispatcher_connect(self.hass, SIGNAL_KEYPAD_UPDATE, self._update_callback)
async_dispatcher_connect(
self.hass, SIGNAL_PARTITION_UPDATE, self._update_callback
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_KEYPAD_UPDATE",
",",
"self",
".",
"_update_callback",
")",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_PARTITION_U... | [
50,
4
] | [
55,
9
] | python | en | ['en', 'no', 'en'] | False |
EnvisalinkSensor.icon | (self) | Return the icon if any. | Return the icon if any. | def icon(self):
"""Return the icon if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
58,
4
] | [
60,
25
] | python | en | ['en', 'en', 'en'] | True |
EnvisalinkSensor.state | (self) | Return the overall state. | Return the overall state. | def state(self):
"""Return the overall state."""
return self._info["status"]["alpha"] | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_info",
"[",
"\"status\"",
"]",
"[",
"\"alpha\"",
"]"
] | [
63,
4
] | [
65,
44
] | python | en | ['en', 'en', 'en'] | True |
EnvisalinkSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self._info["status"] | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_info",
"[",
"\"status\"",
"]"
] | [
68,
4
] | [
70,
35
] | python | en | ['en', 'en', 'en'] | True |
EnvisalinkSensor._update_callback | (self, partition) | Update the partition state in HA, if needed. | Update the partition state in HA, if needed. | def _update_callback(self, partition):
"""Update the partition state in HA, if needed."""
if partition is None or int(partition) == self._partition_number:
self.async_write_ha_state() | [
"def",
"_update_callback",
"(",
"self",
",",
"partition",
")",
":",
"if",
"partition",
"is",
"None",
"or",
"int",
"(",
"partition",
")",
"==",
"self",
".",
"_partition_number",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
73,
4
] | [
76,
39
] | python | en | ['en', 'en', 'en'] | True |
test_controlling_state_via_mqtt | (hass, mqtt_mock, setup_tasmota) | Test state update via MQTT. | Test state update via MQTT. | async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
"""Test state update via MQTT."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["swc"][0] = 1
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFIX}/{mac}/config",
json.dumps(config),
... | [
"async",
"def",
"test_controlling_state_via_mqtt",
"(",
"hass",
",",
"mqtt_mock",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"swc\"",
"]",
"[",
"0",
"]",
"=",
"1",
"mac",
"=",
"confi... | [
40,
0
] | [
95,
35
] | python | en | ['en', 'co', 'en'] | True |
test_controlling_state_via_mqtt_switchname | (hass, mqtt_mock, setup_tasmota) | Test state update via MQTT. | Test state update via MQTT. | async def test_controlling_state_via_mqtt_switchname(hass, mqtt_mock, setup_tasmota):
"""Test state update via MQTT."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["swc"][0] = 1
config["swn"][0] = "Custom Name"
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREF... | [
"async",
"def",
"test_controlling_state_via_mqtt_switchname",
"(",
"hass",
",",
"mqtt_mock",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"swc\"",
"]",
"[",
"0",
"]",
"=",
"1",
"config",
... | [
98,
0
] | [
154,
35
] | python | en | ['en', 'co', 'en'] | True |
test_pushon_controlling_state_via_mqtt | (hass, mqtt_mock, setup_tasmota) | Test state update via MQTT. | Test state update via MQTT. | async def test_pushon_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
"""Test state update via MQTT."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["swc"][0] = 13
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFIX}/{mac}/config",
json.dumps(co... | [
"async",
"def",
"test_pushon_controlling_state_via_mqtt",
"(",
"hass",
",",
"mqtt_mock",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"swc\"",
"]",
"[",
"0",
"]",
"=",
"13",
"mac",
"=",
... | [
157,
0
] | [
202,
35
] | python | en | ['en', 'co', 'en'] | True |
test_friendly_names | (hass, mqtt_mock, setup_tasmota) | Test state update via MQTT. | Test state update via MQTT. | async def test_friendly_names(hass, mqtt_mock, setup_tasmota):
"""Test state update via MQTT."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["swc"][0] = 1
config["swc"][1] = 1
config["swn"][1] = "Beer"
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFIX}/{... | [
"async",
"def",
"test_friendly_names",
"(",
"hass",
",",
"mqtt_mock",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"swc\"",
"]",
"[",
"0",
"]",
"=",
"1",
"config",
"[",
"\"swc\"",
"]... | [
205,
0
] | [
226,
58
] | python | en | ['en', 'co', 'en'] | True |
test_off_delay | (hass, mqtt_mock, setup_tasmota) | Test off_delay option. | Test off_delay option. | async def test_off_delay(hass, mqtt_mock, setup_tasmota):
"""Test off_delay option."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["swc"][0] = 13 # PUSHON: 1s off_delay
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFIX}/{mac}/config",
json.dumps(config)... | [
"async",
"def",
"test_off_delay",
"(",
"hass",
",",
"mqtt_mock",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"swc\"",
"]",
"[",
"0",
"]",
"=",
"13",
"# PUSHON: 1s off_delay",
"mac",
"... | [
229,
0
] | [
274,
47
] | python | en | ['en', 'en', 'en'] | True |
test_availability_when_connection_lost | (
hass, mqtt_client_mock, mqtt_mock, setup_tasmota
) | Test availability after MQTT disconnection. | Test availability after MQTT disconnection. | async def test_availability_when_connection_lost(
hass, mqtt_client_mock, mqtt_mock, setup_tasmota
):
"""Test availability after MQTT disconnection."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["swc"][0] = 1
config["swn"][0] = "Test"
await help_test_availability_when_connection_lost(
... | [
"async",
"def",
"test_availability_when_connection_lost",
"(",
"hass",
",",
"mqtt_client_mock",
",",
"mqtt_mock",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"swc\"",
"]",
"[",
"0",
"]",
... | [
277,
0
] | [
286,
5
] | python | en | ['en', 'en', 'en'] | True |
test_availability | (hass, mqtt_mock, setup_tasmota) | Test availability. | Test availability. | async def test_availability(hass, mqtt_mock, setup_tasmota):
"""Test availability."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["swc"][0] = 1
config["swn"][0] = "Test"
await help_test_availability(hass, mqtt_mock, binary_sensor.DOMAIN, config) | [
"async",
"def",
"test_availability",
"(",
"hass",
",",
"mqtt_mock",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"swc\"",
"]",
"[",
"0",
"]",
"=",
"1",
"config",
"[",
"\"swn\"",
"]",... | [
289,
0
] | [
294,
79
] | python | en | ['fr', 'ga', 'en'] | False |
test_availability_discovery_update | (hass, mqtt_mock, setup_tasmota) | Test availability discovery update. | Test availability discovery update. | async def test_availability_discovery_update(hass, mqtt_mock, setup_tasmota):
"""Test availability discovery update."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["swc"][0] = 1
config["swn"][0] = "Test"
await help_test_availability_discovery_update(
hass, mqtt_mock, binary_sensor.DOMAIN, ... | [
"async",
"def",
"test_availability_discovery_update",
"(",
"hass",
",",
"mqtt_mock",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"swc\"",
"]",
"[",
"0",
"]",
"=",
"1",
"config",
"[",
... | [
297,
0
] | [
304,
5
] | 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.