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
test_turn_on
(hass, light_devices)
Test the light turns of successfully.
Test the light turns of successfully.
async def test_turn_on(hass, light_devices): """Test the light turns of successfully.""" # Arrange await setup_platform(hass, LIGHT_DOMAIN, devices=light_devices) # Act await hass.services.async_call( "light", "turn_on", {ATTR_ENTITY_ID: "light.color_dimmer_1"}, blocking=True ) # Ass...
[ "async", "def", "test_turn_on", "(", "hass", ",", "light_devices", ")", ":", "# Arrange", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ",", "devices", "=", "light_devices", ")", "# Act", "await", "hass", ".", "services", ".", "async_call", "(",...
[ 155, 0 ]
[ 166, 30 ]
python
en
['en', 'en', 'en']
True
test_turn_on_with_brightness
(hass, light_devices)
Test the light turns on to the specified brightness.
Test the light turns on to the specified brightness.
async def test_turn_on_with_brightness(hass, light_devices): """Test the light turns on to the specified brightness.""" # Arrange await setup_platform(hass, LIGHT_DOMAIN, devices=light_devices) # Act await hass.services.async_call( "light", "turn_on", { ATTR_ENTIT...
[ "async", "def", "test_turn_on_with_brightness", "(", "hass", ",", "light_devices", ")", ":", "# Arrange", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ",", "devices", "=", "light_devices", ")", "# Act", "await", "hass", ".", "services", ".", "asy...
[ 169, 0 ]
[ 189, 50 ]
python
en
['en', 'en', 'en']
True
test_turn_on_with_minimal_brightness
(hass, light_devices)
Test lights set to lowest brightness when converted scale would be zero. SmartThings light brightness is a percentage (0-100), but Home Assistant uses a 0-255 scale. This tests if a really low value (1-2) is passed, we don't set the level to zero, which turns off the lights in SmartThings.
Test lights set to lowest brightness when converted scale would be zero.
async def test_turn_on_with_minimal_brightness(hass, light_devices): """ Test lights set to lowest brightness when converted scale would be zero. SmartThings light brightness is a percentage (0-100), but Home Assistant uses a 0-255 scale. This tests if a really low value (1-2) is passed, we don't ...
[ "async", "def", "test_turn_on_with_minimal_brightness", "(", "hass", ",", "light_devices", ")", ":", "# Arrange", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ",", "devices", "=", "light_devices", ")", "# Act", "await", "hass", ".", "services", "."...
[ 192, 0 ]
[ 214, 49 ]
python
en
['en', 'error', 'th']
False
test_turn_on_with_color
(hass, light_devices)
Test the light turns on with color.
Test the light turns on with color.
async def test_turn_on_with_color(hass, light_devices): """Test the light turns on with color.""" # Arrange await setup_platform(hass, LIGHT_DOMAIN, devices=light_devices) # Act await hass.services.async_call( "light", "turn_on", {ATTR_ENTITY_ID: "light.color_dimmer_2", ATTR_...
[ "async", "def", "test_turn_on_with_color", "(", "hass", ",", "light_devices", ")", ":", "# Arrange", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ",", "devices", "=", "light_devices", ")", "# Act", "await", "hass", ".", "services", ".", "async_ca...
[ 217, 0 ]
[ 232, 55 ]
python
en
['en', 'en', 'en']
True
test_turn_on_with_color_temp
(hass, light_devices)
Test the light turns on with color temp.
Test the light turns on with color temp.
async def test_turn_on_with_color_temp(hass, light_devices): """Test the light turns on with color temp.""" # Arrange await setup_platform(hass, LIGHT_DOMAIN, devices=light_devices) # Act await hass.services.async_call( "light", "turn_on", {ATTR_ENTITY_ID: "light.color_dimmer...
[ "async", "def", "test_turn_on_with_color_temp", "(", "hass", ",", "light_devices", ")", ":", "# Arrange", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ",", "devices", "=", "light_devices", ")", "# Act", "await", "hass", ".", "services", ".", "asy...
[ 235, 0 ]
[ 250, 51 ]
python
en
['en', 'en', 'en']
True
test_update_from_signal
(hass, device_factory)
Test the light updates when receiving a signal.
Test the light updates when receiving a signal.
async def test_update_from_signal(hass, device_factory): """Test the light updates when receiving a signal.""" # Arrange device = device_factory( "Color Dimmer 2", capabilities=[ Capability.switch, Capability.switch_level, Capability.color_control, ...
[ "async", "def", "test_update_from_signal", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Color Dimmer 2\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "switch_level", ",...
[ 253, 0 ]
[ 280, 30 ]
python
en
['en', 'lb', 'en']
True
test_unload_config_entry
(hass, device_factory)
Test the light is removed when the config entry is unloaded.
Test the light is removed when the config entry is unloaded.
async def test_unload_config_entry(hass, device_factory): """Test the light is removed when the config entry is unloaded.""" # Arrange device = device_factory( "Color Dimmer 2", capabilities=[ Capability.switch, Capability.switch_level, Capability.color_co...
[ "async", "def", "test_unload_config_entry", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Color Dimmer 2\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "switch_level", "...
[ 283, 0 ]
[ 306, 54 ]
python
en
['en', 'en', 'en']
True
check_task
(task: str)
Checks an incoming task string, to validate it's correct and return the default Pipeline and Model classes, and default models if they exist. Args: task (:obj:`str`): The task defining which pipeline will be returned. Currently accepted tasks are: - :obj:`"feature-extracti...
Checks an incoming task string, to validate it's correct and return the default Pipeline and Model classes, and default models if they exist.
def check_task(task: str) -> Tuple[Dict, Any]: """ Checks an incoming task string, to validate it's correct and return the default Pipeline and Model classes, and default models if they exist. Args: task (:obj:`str`): The task defining which pipeline will be returned. Currently acce...
[ "def", "check_task", "(", "task", ":", "str", ")", "->", "Tuple", "[", "Dict", ",", "Any", "]", ":", "if", "task", "in", "SUPPORTED_TASKS", ":", "targeted_task", "=", "SUPPORTED_TASKS", "[", "task", "]", "return", "targeted_task", ",", "None", "if", "tas...
[ 198, 0 ]
[ 237, 5 ]
python
en
['en', 'error', 'th']
False
pipeline
( task: str, model: Optional = None, config: Optional[Union[str, PretrainedConfig]] = None, tokenizer: Optional[Union[str, PreTrainedTokenizer]] = None, framework: Optional[str] = None, revision: Optional[str] = None, use_fast: bool = True, model_kwargs: Dict[str, Any] = {}, **kwargs...
Utility factory method to build a :class:`~transformers.Pipeline`. Pipelines are made of: - A :doc:`tokenizer <tokenizer>` in charge of mapping raw textual input to token. - A :doc:`model <model>` to make predictions from the inputs. - Some (optional) post processing for enhancing mod...
Utility factory method to build a :class:`~transformers.Pipeline`.
def pipeline( task: str, model: Optional = None, config: Optional[Union[str, PretrainedConfig]] = None, tokenizer: Optional[Union[str, PreTrainedTokenizer]] = None, framework: Optional[str] = None, revision: Optional[str] = None, use_fast: bool = True, model_kwargs: Dict[str, Any] = {}, ...
[ "def", "pipeline", "(", "task", ":", "str", ",", "model", ":", "Optional", "=", "None", ",", "config", ":", "Optional", "[", "Union", "[", "str", ",", "PretrainedConfig", "]", "]", "=", "None", ",", "tokenizer", ":", "Optional", "[", "Union", "[", "s...
[ 240, 0 ]
[ 421, 118 ]
python
en
['en', 'error', 'th']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the eight sleep sensors.
Set up the eight sleep sensors.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the eight sleep sensors.""" if discovery_info is None: return name = "Eight" sensors = discovery_info[CONF_SENSORS] eight = hass.data[DATA_EIGHT] if hass.config.units.is_metric: uni...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "name", "=", "\"Eight\"", "sensors", "=", "discovery_info", "[", "...
[ 41, 0 ]
[ 65, 41 ]
python
en
['en', 'et', 'en']
True
EightHeatSensor.__init__
(self, name, eight, sensor)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, eight, sensor): """Initialize the sensor.""" super().__init__(eight) self._sensor = sensor self._mapped_name = NAME_MAP.get(self._sensor, self._sensor) self._name = f"{name} {self._mapped_name}" self._state = None self._side = self._sens...
[ "def", "__init__", "(", "self", ",", "name", ",", "eight", ",", "sensor", ")", ":", "super", "(", ")", ".", "__init__", "(", "eight", ")", "self", ".", "_sensor", "=", "sensor", "self", ".", "_mapped_name", "=", "NAME_MAP", ".", "get", "(", "self", ...
[ 71, 4 ]
[ 89, 9 ]
python
en
['en', 'en', 'en']
True
EightHeatSensor.name
(self)
Return the name of the sensor, if any.
Return the name of the sensor, if any.
def name(self): """Return the name of the sensor, if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 92, 4 ]
[ 94, 25 ]
python
en
['en', 'en', 'en']
True
EightHeatSensor.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" ]
[ 97, 4 ]
[ 99, 26 ]
python
en
['en', 'en', 'en']
True
EightHeatSensor.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 PERCENTAGE
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "PERCENTAGE" ]
[ 102, 4 ]
[ 104, 25 ]
python
en
['en', 'en', 'en']
True
EightHeatSensor.async_update
(self)
Retrieve latest state.
Retrieve latest state.
async def async_update(self): """Retrieve latest state.""" _LOGGER.debug("Updating Heat sensor: %s", self._sensor) self._state = self._usrobj.heating_level
[ "async", "def", "async_update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating Heat sensor: %s\"", ",", "self", ".", "_sensor", ")", "self", ".", "_state", "=", "self", ".", "_usrobj", ".", "heating_level" ]
[ 106, 4 ]
[ 109, 48 ]
python
en
['es', 'sk', 'en']
False
EightHeatSensor.device_state_attributes
(self)
Return device state attributes.
Return device state attributes.
def device_state_attributes(self): """Return device state attributes.""" return { ATTR_TARGET_HEAT: self._usrobj.target_heating_level, ATTR_ACTIVE_HEAT: self._usrobj.now_heating, ATTR_DURATION_HEAT: self._usrobj.heating_remaining, }
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_TARGET_HEAT", ":", "self", ".", "_usrobj", ".", "target_heating_level", ",", "ATTR_ACTIVE_HEAT", ":", "self", ".", "_usrobj", ".", "now_heating", ",", "ATTR_DURATION_HEAT", ":", "self", ...
[ 112, 4 ]
[ 118, 9 ]
python
en
['es', 'en', 'en']
True
EightUserSensor.__init__
(self, name, eight, sensor, units)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, eight, sensor, units): """Initialize the sensor.""" super().__init__(eight) self._sensor = sensor self._sensor_root = self._sensor.split("_", 1)[1] self._mapped_name = NAME_MAP.get(self._sensor, self._sensor) self._name = f"{name} {self._mapped_n...
[ "def", "__init__", "(", "self", ",", "name", ",", "eight", ",", "sensor", ",", "units", ")", ":", "super", "(", ")", ".", "__init__", "(", "eight", ")", "self", ".", "_sensor", "=", "sensor", "self", ".", "_sensor_root", "=", "self", ".", "_sensor", ...
[ 124, 4 ]
[ 145, 9 ]
python
en
['en', 'en', 'en']
True
EightUserSensor.name
(self)
Return the name of the sensor, if any.
Return the name of the sensor, if any.
def name(self): """Return the name of the sensor, if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 148, 4 ]
[ 150, 25 ]
python
en
['en', 'en', 'en']
True
EightUserSensor.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" ]
[ 153, 4 ]
[ 155, 26 ]
python
en
['en', 'en', 'en']
True
EightUserSensor.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.""" if ( "current_sleep" in self._sensor or "last_sleep" in self._sensor or "current_sleep_fitness" in self._sensor ): return "Score" if "bed_temp" in self._sensor:...
[ "def", "unit_of_measurement", "(", "self", ")", ":", "if", "(", "\"current_sleep\"", "in", "self", ".", "_sensor", "or", "\"last_sleep\"", "in", "self", ".", "_sensor", "or", "\"current_sleep_fitness\"", "in", "self", ".", "_sensor", ")", ":", "return", "\"Sco...
[ 158, 4 ]
[ 170, 19 ]
python
en
['en', 'en', 'en']
True
EightUserSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" if "bed_temp" in self._sensor: return "mdi:thermometer"
[ "def", "icon", "(", "self", ")", ":", "if", "\"bed_temp\"", "in", "self", ".", "_sensor", ":", "return", "\"mdi:thermometer\"" ]
[ 173, 4 ]
[ 176, 36 ]
python
en
['en', 'en', 'en']
True
EightUserSensor.async_update
(self)
Retrieve latest state.
Retrieve latest state.
async def async_update(self): """Retrieve latest state.""" _LOGGER.debug("Updating User sensor: %s", self._sensor) if "current" in self._sensor: if "fitness" in self._sensor: self._state = self._usrobj.current_sleep_fitness_score self._attr = self._usr...
[ "async", "def", "async_update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating User sensor: %s\"", ",", "self", ".", "_sensor", ")", "if", "\"current\"", "in", "self", ".", "_sensor", ":", "if", "\"fitness\"", "in", "self", ".", "_sensor", ...
[ 178, 4 ]
[ 201, 62 ]
python
en
['es', 'sk', 'en']
False
EightUserSensor.device_state_attributes
(self)
Return device state attributes.
Return device state attributes.
def device_state_attributes(self): """Return device state attributes.""" if self._attr is None: # Skip attributes if sensor type doesn't support return None if "fitness" in self._sensor_root: state_attr = { ATTR_FIT_DATE: self._attr["date"], ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_attr", "is", "None", ":", "# Skip attributes if sensor type doesn't support", "return", "None", "if", "\"fitness\"", "in", "self", ".", "_sensor_root", ":", "state_attr", "=", "{", "ATTR...
[ 204, 4 ]
[ 288, 25 ]
python
en
['es', 'en', 'en']
True
EightRoomSensor.__init__
(self, name, eight, sensor, units)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, eight, sensor, units): """Initialize the sensor.""" super().__init__(eight) self._sensor = sensor self._mapped_name = NAME_MAP.get(self._sensor, self._sensor) self._name = f"{name} {self._mapped_name}" self._state = None self._attr = None...
[ "def", "__init__", "(", "self", ",", "name", ",", "eight", ",", "sensor", ",", "units", ")", ":", "super", "(", ")", ".", "__init__", "(", "eight", ")", "self", ".", "_sensor", "=", "sensor", "self", ".", "_mapped_name", "=", "NAME_MAP", ".", "get", ...
[ 294, 4 ]
[ 303, 27 ]
python
en
['en', 'en', 'en']
True
EightRoomSensor.name
(self)
Return the name of the sensor, if any.
Return the name of the sensor, if any.
def name(self): """Return the name of the sensor, if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 306, 4 ]
[ 308, 25 ]
python
en
['en', 'en', 'en']
True
EightRoomSensor.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" ]
[ 311, 4 ]
[ 313, 26 ]
python
en
['en', 'en', 'en']
True
EightRoomSensor.async_update
(self)
Retrieve latest state.
Retrieve latest state.
async def async_update(self): """Retrieve latest state.""" _LOGGER.debug("Updating Room sensor: %s", self._sensor) temp = self._eight.room_temperature() try: if self._units == "si": self._state = round(temp, 2) else: self._state = r...
[ "async", "def", "async_update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating Room sensor: %s\"", ",", "self", ".", "_sensor", ")", "temp", "=", "self", ".", "_eight", ".", "room_temperature", "(", ")", "try", ":", "if", "self", ".", "...
[ 315, 4 ]
[ 325, 30 ]
python
en
['es', 'sk', 'en']
False
EightRoomSensor.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.""" if self._units == "si": return TEMP_CELSIUS return TEMP_FAHRENHEIT
[ "def", "unit_of_measurement", "(", "self", ")", ":", "if", "self", ".", "_units", "==", "\"si\"", ":", "return", "TEMP_CELSIUS", "return", "TEMP_FAHRENHEIT" ]
[ 328, 4 ]
[ 332, 30 ]
python
en
['en', 'en', 'en']
True
EightRoomSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return "mdi:thermometer"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:thermometer\"" ]
[ 335, 4 ]
[ 337, 32 ]
python
en
['en', 'en', 'en']
True
COCOCaptionsDataset.__init__
(self, ann_file, image_set, root_path, data_path, seq_len=64, with_precomputed_visual_feat=False, mask_raw_pixels=True, with_rel_task=True, with_mlm_task=True, with_mvrc_task=True, transform=None, test_mode=False, zip_mode=False, cache_mode=False, cach...
Conceptual Captions Dataset :param ann_file: annotation jsonl file :param image_set: image folder name, e.g., 'vcr1images' :param root_path: root path to cache database loaded from annotation file :param data_path: path to vcr dataset :param transform: transform ...
Conceptual Captions Dataset
def __init__(self, ann_file, image_set, root_path, data_path, seq_len=64, with_precomputed_visual_feat=False, mask_raw_pixels=True, with_rel_task=True, with_mlm_task=True, with_mvrc_task=True, transform=None, test_mode=False, zip_mode=False, cache_mode...
[ "def", "__init__", "(", "self", ",", "ann_file", ",", "image_set", ",", "root_path", ",", "data_path", ",", "seq_len", "=", "64", ",", "with_precomputed_visual_feat", "=", "False", ",", "mask_raw_pixels", "=", "True", ",", "with_rel_task", "=", "True", ",", ...
[ 19, 4 ]
[ 110, 56 ]
python
en
['en', 'error', 'th']
False
async_setup_platform
(hass, _, add_entities, discovery_info=None)
Add lights from the main Qwikswitch component.
Add lights from the main Qwikswitch component.
async def async_setup_platform(hass, _, add_entities, discovery_info=None): """Add lights from the main Qwikswitch component.""" if discovery_info is None: return qsusb = hass.data[QWIKSWITCH] devs = [QSLight(qsid, qsusb) for qsid in discovery_info[QWIKSWITCH]] add_entities(devs)
[ "async", "def", "async_setup_platform", "(", "hass", ",", "_", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "qsusb", "=", "hass", ".", "data", "[", "QWIKSWITCH", "]", "devs", "=", ...
[ 6, 0 ]
[ 13, 22 ]
python
en
['en', 'en', 'en']
True
QSLight.brightness
(self)
Return the brightness of this light (0-255).
Return the brightness of this light (0-255).
def brightness(self): """Return the brightness of this light (0-255).""" return self.device.value if self.device.is_dimmer else None
[ "def", "brightness", "(", "self", ")", ":", "return", "self", ".", "device", ".", "value", "if", "self", ".", "device", ".", "is_dimmer", "else", "None" ]
[ 20, 4 ]
[ 22, 67 ]
python
en
['en', 'sn', 'en']
True
QSLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_BRIGHTNESS if self.device.is_dimmer else 0
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS", "if", "self", ".", "device", ".", "is_dimmer", "else", "0" ]
[ 25, 4 ]
[ 27, 65 ]
python
en
['da', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the GC100 devices.
Set up the GC100 devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the GC100 devices.""" binary_sensors = [] ports = config.get(CONF_PORTS) for port in ports: for port_addr, port_name in port.items(): binary_sensors.append( GC100BinarySensor(port_name, por...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "binary_sensors", "=", "[", "]", "ports", "=", "config", ".", "get", "(", "CONF_PORTS", ")", "for", "port", "in", "ports", ":", "for",...
[ 16, 0 ]
[ 25, 38 ]
python
en
['en', 'en', 'en']
True
GC100BinarySensor.__init__
(self, name, port_addr, gc100)
Initialize the GC100 binary sensor.
Initialize the GC100 binary sensor.
def __init__(self, name, port_addr, gc100): """Initialize the GC100 binary sensor.""" self._name = name or DEVICE_DEFAULT_NAME self._port_addr = port_addr self._gc100 = gc100 self._state = None # Subscribe to be notified about state changes (PUSH) self._gc100.sub...
[ "def", "__init__", "(", "self", ",", "name", ",", "port_addr", ",", "gc100", ")", ":", "self", ".", "_name", "=", "name", "or", "DEVICE_DEFAULT_NAME", "self", ".", "_port_addr", "=", "port_addr", "self", ".", "_gc100", "=", "gc100", "self", ".", "_state"...
[ 31, 4 ]
[ 39, 62 ]
python
en
['en', 'zh-Latn', 'en']
True
GC100BinarySensor.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" ]
[ 42, 4 ]
[ 44, 25 ]
python
en
['en', 'mi', 'en']
True
GC100BinarySensor.is_on
(self)
Return the state of the entity.
Return the state of the entity.
def is_on(self): """Return the state of the entity.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 47, 4 ]
[ 49, 26 ]
python
en
['en', 'en', 'en']
True
GC100BinarySensor.update
(self)
Update the sensor state.
Update the sensor state.
def update(self): """Update the sensor state.""" self._gc100.read_sensor(self._port_addr, self.set_state)
[ "def", "update", "(", "self", ")", ":", "self", ".", "_gc100", ".", "read_sensor", "(", "self", ".", "_port_addr", ",", "self", ".", "set_state", ")" ]
[ 51, 4 ]
[ 53, 64 ]
python
en
['en', 'co', 'en']
True
GC100BinarySensor.set_state
(self, state)
Set the current state.
Set the current state.
def set_state(self, state): """Set the current state.""" self._state = state == 1 self.schedule_update_ha_state()
[ "def", "set_state", "(", "self", ",", "state", ")", ":", "self", ".", "_state", "=", "state", "==", "1", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 55, 4 ]
[ 58, 39 ]
python
en
['en', 'en', 'en']
True
switchbox_fixture
()
Return a default switchBox switch entity mock.
Return a default switchBox switch entity mock.
def switchbox_fixture(): """Return a default switchBox switch entity mock.""" feature = mock_feature( "switches", blebox_uniapi.switch.Switch, unique_id="BleBox-switchBox-1afe34e750b8-0.relay", full_name="switchBox-0.relay", device_class="relay", is_on=False, ...
[ "def", "switchbox_fixture", "(", ")", ":", "feature", "=", "mock_feature", "(", "\"switches\"", ",", "blebox_uniapi", ".", "switch", ".", "Switch", ",", "unique_id", "=", "\"BleBox-switchBox-1afe34e750b8-0.relay\"", ",", "full_name", "=", "\"switchBox-0.relay\"", ",",...
[ 28, 0 ]
[ 42, 48 ]
python
en
['en', 'cy', 'en']
True
test_switchbox_init
(switchbox, hass, config)
Test switch default state.
Test switch default state.
async def test_switchbox_init(switchbox, hass, config): """Test switch default state.""" feature_mock, entity_id = switchbox feature_mock.async_update = AsyncMock() entry = await async_setup_entity(hass, config, entity_id) assert entry.unique_id == "BleBox-switchBox-1afe34e750b8-0.relay" stat...
[ "async", "def", "test_switchbox_init", "(", "switchbox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "switchbox", "feature_mock", ".", "async_update", "=", "AsyncMock", "(", ")", "entry", "=", "await", "async_setup_entity", "(", ...
[ 45, 0 ]
[ 68, 38 ]
python
en
['de', 'en', 'en']
True
test_switchbox_update_when_off
(switchbox, hass, config)
Test switch updating when off.
Test switch updating when off.
async def test_switchbox_update_when_off(switchbox, hass, config): """Test switch updating when off.""" feature_mock, entity_id = switchbox def initial_update(): feature_mock.is_on = False feature_mock.async_update = AsyncMock(side_effect=initial_update) await async_setup_entity(hass, con...
[ "async", "def", "test_switchbox_update_when_off", "(", "switchbox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "switchbox", "def", "initial_update", "(", ")", ":", "feature_mock", ".", "is_on", "=", "False", "feature_mock", ".",...
[ 71, 0 ]
[ 83, 35 ]
python
en
['en', 'en', 'en']
True
test_switchbox_update_when_on
(switchbox, hass, config)
Test switch updating when on.
Test switch updating when on.
async def test_switchbox_update_when_on(switchbox, hass, config): """Test switch updating when on.""" feature_mock, entity_id = switchbox def initial_update(): feature_mock.is_on = True feature_mock.async_update = AsyncMock(side_effect=initial_update) await async_setup_entity(hass, config...
[ "async", "def", "test_switchbox_update_when_on", "(", "switchbox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "switchbox", "def", "initial_update", "(", ")", ":", "feature_mock", ".", "is_on", "=", "True", "feature_mock", ".", ...
[ 86, 0 ]
[ 98, 34 ]
python
en
['en', 'en', 'en']
True
test_switchbox_on
(switchbox, hass, config)
Test turning switch on.
Test turning switch on.
async def test_switchbox_on(switchbox, hass, config): """Test turning switch on.""" feature_mock, entity_id = switchbox def initial_update(): feature_mock.is_on = False feature_mock.async_update = AsyncMock(side_effect=initial_update) await async_setup_entity(hass, config, entity_id) ...
[ "async", "def", "test_switchbox_on", "(", "switchbox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "switchbox", "def", "initial_update", "(", ")", ":", "feature_mock", ".", "is_on", "=", "False", "feature_mock", ".", "async_upd...
[ 101, 0 ]
[ 126, 34 ]
python
en
['en', 'en', 'en']
True
test_switchbox_off
(switchbox, hass, config)
Test turning switch off.
Test turning switch off.
async def test_switchbox_off(switchbox, hass, config): """Test turning switch off.""" feature_mock, entity_id = switchbox def initial_update(): feature_mock.is_on = True feature_mock.async_update = AsyncMock(side_effect=initial_update) await async_setup_entity(hass, config, entity_id) ...
[ "async", "def", "test_switchbox_off", "(", "switchbox", ",", "hass", ",", "config", ")", ":", "feature_mock", ",", "entity_id", "=", "switchbox", "def", "initial_update", "(", ")", ":", "feature_mock", ".", "is_on", "=", "True", "feature_mock", ".", "async_upd...
[ 129, 0 ]
[ 153, 35 ]
python
en
['en', 'en', 'en']
True
relay_mock
(relay_id=0)
Return a default switchBoxD switch entity mock.
Return a default switchBoxD switch entity mock.
def relay_mock(relay_id=0): """Return a default switchBoxD switch entity mock.""" return mock_only_feature( blebox_uniapi.switch.Switch, unique_id=f"BleBox-switchBoxD-1afe34e750b8-{relay_id}.relay", full_name=f"switchBoxD-{relay_id}.relay", device_class="relay", is_on=No...
[ "def", "relay_mock", "(", "relay_id", "=", "0", ")", ":", "return", "mock_only_feature", "(", "blebox_uniapi", ".", "switch", ".", "Switch", ",", "unique_id", "=", "f\"BleBox-switchBoxD-1afe34e750b8-{relay_id}.relay\"", ",", "full_name", "=", "f\"switchBoxD-{relay_id}.r...
[ 156, 0 ]
[ 165, 5 ]
python
en
['en', 'pl', 'en']
True
switchbox_d_fixture
()
Set up two mocked Switch features representing a switchBoxD.
Set up two mocked Switch features representing a switchBoxD.
def switchbox_d_fixture(): """Set up two mocked Switch features representing a switchBoxD.""" relay1 = relay_mock(0) relay2 = relay_mock(1) features = [relay1, relay2] product = setup_product_mock("switches", features) type(product).name = PropertyMock(return_value="My relays") type(produ...
[ "def", "switchbox_d_fixture", "(", ")", ":", "relay1", "=", "relay_mock", "(", "0", ")", "relay2", "=", "relay_mock", "(", "1", ")", "features", "=", "[", "relay1", ",", "relay2", "]", "product", "=", "setup_product_mock", "(", "\"switches\"", ",", "featur...
[ 169, 0 ]
[ 187, 81 ]
python
en
['en', 'en', 'en']
True
test_switchbox_d_init
(switchbox_d, hass, config)
Test switch default state.
Test switch default state.
async def test_switchbox_d_init(switchbox_d, hass, config): """Test switch default state.""" feature_mocks, entity_ids = switchbox_d feature_mocks[0].async_update = AsyncMock() feature_mocks[1].async_update = AsyncMock() entries = await async_setup_entities(hass, config, entity_ids) entry = e...
[ "async", "def", "test_switchbox_d_init", "(", "switchbox_d", ",", "hass", ",", "config", ")", ":", "feature_mocks", ",", "entity_ids", "=", "switchbox_d", "feature_mocks", "[", "0", "]", ".", "async_update", "=", "AsyncMock", "(", ")", "feature_mocks", "[", "1...
[ 190, 0 ]
[ 231, 38 ]
python
en
['de', 'en', 'en']
True
test_switchbox_d_update_when_off
(switchbox_d, hass, config)
Test switch updating when off.
Test switch updating when off.
async def test_switchbox_d_update_when_off(switchbox_d, hass, config): """Test switch updating when off.""" feature_mocks, entity_ids = switchbox_d def initial_update0(): feature_mocks[0].is_on = False feature_mocks[1].is_on = False feature_mocks[0].async_update = AsyncMock(side_effec...
[ "async", "def", "test_switchbox_d_update_when_off", "(", "switchbox_d", ",", "hass", ",", "config", ")", ":", "feature_mocks", ",", "entity_ids", "=", "switchbox_d", "def", "initial_update0", "(", ")", ":", "feature_mocks", "[", "0", "]", ".", "is_on", "=", "F...
[ 234, 0 ]
[ 248, 60 ]
python
en
['en', 'en', 'en']
True
test_switchbox_d_update_when_second_off
(switchbox_d, hass, config)
Test switch updating when off.
Test switch updating when off.
async def test_switchbox_d_update_when_second_off(switchbox_d, hass, config): """Test switch updating when off.""" feature_mocks, entity_ids = switchbox_d def initial_update0(): feature_mocks[0].is_on = True feature_mocks[1].is_on = False feature_mocks[0].async_update = AsyncMock(side...
[ "async", "def", "test_switchbox_d_update_when_second_off", "(", "switchbox_d", ",", "hass", ",", "config", ")", ":", "feature_mocks", ",", "entity_ids", "=", "switchbox_d", "def", "initial_update0", "(", ")", ":", "feature_mocks", "[", "0", "]", ".", "is_on", "=...
[ 251, 0 ]
[ 265, 60 ]
python
en
['en', 'en', 'en']
True
test_switchbox_d_turn_first_on
(switchbox_d, hass, config)
Test turning switch on.
Test turning switch on.
async def test_switchbox_d_turn_first_on(switchbox_d, hass, config): """Test turning switch on.""" feature_mocks, entity_ids = switchbox_d def initial_update0(): feature_mocks[0].is_on = False feature_mocks[1].is_on = False feature_mocks[0].async_update = AsyncMock(side_effect=initial...
[ "async", "def", "test_switchbox_d_turn_first_on", "(", "switchbox_d", ",", "hass", ",", "config", ")", ":", "feature_mocks", ",", "entity_ids", "=", "switchbox_d", "def", "initial_update0", "(", ")", ":", "feature_mocks", "[", "0", "]", ".", "is_on", "=", "Fal...
[ 268, 0 ]
[ 294, 60 ]
python
en
['en', 'en', 'en']
True
test_switchbox_d_second_on
(switchbox_d, hass, config)
Test turning switch on.
Test turning switch on.
async def test_switchbox_d_second_on(switchbox_d, hass, config): """Test turning switch on.""" feature_mocks, entity_ids = switchbox_d def initial_update0(): feature_mocks[0].is_on = False feature_mocks[1].is_on = False feature_mocks[0].async_update = AsyncMock(side_effect=initial_upd...
[ "async", "def", "test_switchbox_d_second_on", "(", "switchbox_d", ",", "hass", ",", "config", ")", ":", "feature_mocks", ",", "entity_ids", "=", "switchbox_d", "def", "initial_update0", "(", ")", ":", "feature_mocks", "[", "0", "]", ".", "is_on", "=", "False",...
[ 297, 0 ]
[ 323, 59 ]
python
en
['en', 'en', 'en']
True
test_switchbox_d_first_off
(switchbox_d, hass, config)
Test turning switch on.
Test turning switch on.
async def test_switchbox_d_first_off(switchbox_d, hass, config): """Test turning switch on.""" feature_mocks, entity_ids = switchbox_d def initial_update_any(): feature_mocks[0].is_on = True feature_mocks[1].is_on = True feature_mocks[0].async_update = AsyncMock(side_effect=initial_up...
[ "async", "def", "test_switchbox_d_first_off", "(", "switchbox_d", ",", "hass", ",", "config", ")", ":", "feature_mocks", ",", "entity_ids", "=", "switchbox_d", "def", "initial_update_any", "(", ")", ":", "feature_mocks", "[", "0", "]", ".", "is_on", "=", "True...
[ 326, 0 ]
[ 352, 59 ]
python
en
['en', 'en', 'en']
True
test_switchbox_d_second_off
(switchbox_d, hass, config)
Test turning switch on.
Test turning switch on.
async def test_switchbox_d_second_off(switchbox_d, hass, config): """Test turning switch on.""" feature_mocks, entity_ids = switchbox_d def initial_update_any(): feature_mocks[0].is_on = True feature_mocks[1].is_on = True feature_mocks[0].async_update = AsyncMock(side_effect=initial_u...
[ "async", "def", "test_switchbox_d_second_off", "(", "switchbox_d", ",", "hass", ",", "config", ")", ":", "feature_mocks", ",", "entity_ids", "=", "switchbox_d", "def", "initial_update_any", "(", ")", ":", "feature_mocks", "[", "0", "]", ".", "is_on", "=", "Tru...
[ 355, 0 ]
[ 380, 60 ]
python
en
['en', 'en', 'en']
True
test_update_failure
(feature, hass, config, caplog)
Test that update failures are logged.
Test that update failures are logged.
async def test_update_failure(feature, hass, config, caplog): """Test that update failures are logged.""" caplog.set_level(logging.ERROR) feature_mock, entity_id = feature if isinstance(feature_mock, list): feature_mock[0].async_update = AsyncMock() feature_mock[1].async_update = Asyn...
[ "async", "def", "test_update_failure", "(", "feature", ",", "hass", ",", "config", ",", "caplog", ")", ":", "caplog", ".", "set_level", "(", "logging", ".", "ERROR", ")", "feature_mock", ",", "entity_id", "=", "feature", "if", "isinstance", "(", "feature_moc...
[ 387, 0 ]
[ 403, 73 ]
python
en
['en', 'en', 'en']
True
test_reload
(hass)
Verify we can reload trend sensors.
Verify we can reload trend sensors.
async def test_reload(hass): """Verify we can reload trend sensors.""" hass.states.async_set("sensor.test_state", 1234) await setup.async_setup_component( hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": {"test_t...
[ "async", "def", "test_reload", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_state\"", ",", "1234", ")", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ...
[ 377, 0 ]
[ 414, 68 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.setup_method
(self, method)
Set up things to be run when tests are started.
Set up things to be run when tests are started.
def setup_method(self, method): """Set up things to be run when tests are started.""" self.hass = get_test_home_assistant()
[ "def", "setup_method", "(", "self", ",", "method", ")", ":", "self", ".", "hass", "=", "get_test_home_assistant", "(", ")" ]
[ 18, 4 ]
[ 20, 45 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.teardown_method
(self, method)
Stop everything that was started.
Stop everything that was started.
def teardown_method(self, method): """Stop everything that was started.""" self.hass.stop()
[ "def", "teardown_method", "(", "self", ",", "method", ")", ":", "self", ".", "hass", ".", "stop", "(", ")" ]
[ 22, 4 ]
[ 24, 24 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_up
(self)
Test up trend.
Test up trend.
def test_up(self): """Test up trend.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": { "test_trend_sensor": {"entity_id": ...
[ "def", "test_up", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"test_trend_senso...
[ 26, 4 ]
[ 47, 34 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_up_using_trendline
(self)
Test up trend using multiple samples and trendline calculation.
Test up trend using multiple samples and trendline calculation.
def test_up_using_trendline(self): """Test up trend using multiple samples and trendline calculation.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensor...
[ "def", "test_up_using_trendline", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"...
[ 49, 4 ]
[ 88, 35 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_down_using_trendline
(self)
Test down trend using multiple samples and trendline calculation.
Test down trend using multiple samples and trendline calculation.
def test_down_using_trendline(self): """Test down trend using multiple samples and trendline calculation.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "se...
[ "def", "test_down_using_trendline", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "...
[ 90, 4 ]
[ 129, 35 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_down
(self)
Test down trend.
Test down trend.
def test_down(self): """Test down trend.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": { "test_trend_sensor": {"entity_i...
[ "def", "test_down", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"test_trend_sen...
[ 131, 4 ]
[ 152, 35 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_invert_up
(self)
Test up trend with custom message.
Test up trend with custom message.
def test_invert_up(self): """Test up trend with custom message.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": { "test_tr...
[ "def", "test_invert_up", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"test_tren...
[ 154, 4 ]
[ 178, 35 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_invert_down
(self)
Test down trend with custom message.
Test down trend with custom message.
def test_invert_down(self): """Test down trend with custom message.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": { "tes...
[ "def", "test_invert_down", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"test_tr...
[ 180, 4 ]
[ 204, 34 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_attribute_up
(self)
Test attribute up trend.
Test attribute up trend.
def test_attribute_up(self): """Test attribute up trend.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": { "test_trend_sen...
[ "def", "test_attribute_up", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"test_t...
[ 206, 4 ]
[ 229, 34 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_attribute_down
(self)
Test attribute down trend.
Test attribute down trend.
def test_attribute_down(self): """Test attribute down trend.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": { "test_trend...
[ "def", "test_attribute_down", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"test...
[ 231, 4 ]
[ 255, 35 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_max_samples
(self)
Test that sample count is limited correctly.
Test that sample count is limited correctly.
def test_max_samples(self): """Test that sample count is limited correctly.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": { ...
[ "def", "test_max_samples", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"test_tr...
[ 257, 4 ]
[ 283, 52 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_non_numeric
(self)
Test up trend.
Test up trend.
def test_non_numeric(self): """Test up trend.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": { "test_trend_sensor": {"ent...
[ "def", "test_non_numeric", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"test_tr...
[ 285, 4 ]
[ 306, 35 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_missing_attribute
(self)
Test attribute down trend.
Test attribute down trend.
def test_missing_attribute(self): """Test attribute down trend.""" assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "trend", "sensors": { "test_tr...
[ "def", "test_missing_attribute", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"platform\"", ":", "\"trend\"", ",", "\"sensors\"", ":", "{", "\"t...
[ 308, 4 ]
[ 332, 35 ]
python
en
['en', 'en', 'en']
True
TestTrendBinarySensor.test_invalid_name_does_not_create
(self)
Test invalid name.
Test invalid name.
def test_invalid_name_does_not_create(self): """Test invalid name.""" with assert_setup_component(0): assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "templa...
[ "def", "test_invalid_name_does_not_create", "(", "self", ")", ":", "with", "assert_setup_component", "(", "0", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"pl...
[ 334, 4 ]
[ 349, 43 ]
python
en
['en', 'et', 'en']
True
TestTrendBinarySensor.test_invalid_sensor_does_not_create
(self)
Test invalid sensor.
Test invalid sensor.
def test_invalid_sensor_does_not_create(self): """Test invalid sensor.""" with assert_setup_component(0): assert setup.setup_component( self.hass, "binary_sensor", { "binary_sensor": { "platform": "te...
[ "def", "test_invalid_sensor_does_not_create", "(", "self", ")", ":", "with", "assert_setup_component", "(", "0", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"...
[ 351, 4 ]
[ 366, 43 ]
python
en
['en', 'et', 'en']
True
TestTrendBinarySensor.test_no_sensors_does_not_create
(self)
Test no sensors.
Test no sensors.
def test_no_sensors_does_not_create(self): """Test no sensors.""" with assert_setup_component(0): assert setup.setup_component( self.hass, "binary_sensor", {"binary_sensor": {"platform": "trend"}} ) assert self.hass.states.all() == []
[ "def", "test_no_sensors_does_not_create", "(", "self", ")", ":", "with", "assert_setup_component", "(", "0", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"binary_sensor\"", ",", "{", "\"binary_sensor\"", ":", "{", "\"plat...
[ 368, 4 ]
[ 374, 43 ]
python
ca
['es', 'ca', 'pt']
False
test_one_sensor_site_running
(hass, requests_mock, legacy_patchable_time)
Test the Met Office sensor platform.
Test the Met Office sensor platform.
async def test_one_sensor_site_running(hass, requests_mock, legacy_patchable_time): """Test the Met Office sensor platform.""" # all metoffice test data encapsulated in here mock_json = json.loads(load_fixture("metoffice.json")) all_sites = json.dumps(mock_json["all_sites"]) wavertree_hourly = json....
[ "async", "def", "test_one_sensor_site_running", "(", "hass", ",", "requests_mock", ",", "legacy_patchable_time", ")", ":", "# all metoffice test data encapsulated in here", "mock_json", "=", "json", ".", "loads", "(", "load_fixture", "(", "\"metoffice.json\"", ")", ")", ...
[ 25, 0 ]
[ 60, 66 ]
python
en
['en', 'da', 'en']
True
test_two_sensor_sites_running
(hass, requests_mock, legacy_patchable_time)
Test we handle two sets of sensors running for two different sites.
Test we handle two sets of sensors running for two different sites.
async def test_two_sensor_sites_running(hass, requests_mock, legacy_patchable_time): """Test we handle two sets of sensors running for two different sites.""" # all metoffice test data encapsulated in here mock_json = json.loads(load_fixture("metoffice.json")) all_sites = json.dumps(mock_json["all_site...
[ "async", "def", "test_two_sensor_sites_running", "(", "hass", ",", "requests_mock", ",", "legacy_patchable_time", ")", ":", "# all metoffice test data encapsulated in here", "mock_json", "=", "json", ".", "loads", "(", "load_fixture", "(", "\"metoffice.json\"", ")", ")", ...
[ 67, 0 ]
[ 125, 70 ]
python
en
['en', 'en', 'en']
True
has_all_unique_files
(value)
Validate that all persistence files are unique and set if any is set.
Validate that all persistence files are unique and set if any is set.
def has_all_unique_files(value): """Validate that all persistence files are unique and set if any is set.""" persistence_files = [gateway.get(CONF_PERSISTENCE_FILE) for gateway in value] if None in persistence_files and any( name is not None for name in persistence_files ): raise vol.Inv...
[ "def", "has_all_unique_files", "(", "value", ")", ":", "persistence_files", "=", "[", "gateway", ".", "get", "(", "CONF_PERSISTENCE_FILE", ")", "for", "gateway", "in", "value", "]", "if", "None", "in", "persistence_files", "and", "any", "(", "name", "is", "n...
[ 39, 0 ]
[ 51, 16 ]
python
en
['en', 'en', 'en']
True
is_persistence_file
(value)
Validate that persistence file path ends in either .pickle or .json.
Validate that persistence file path ends in either .pickle or .json.
def is_persistence_file(value): """Validate that persistence file path ends in either .pickle or .json.""" if value.endswith((".json", ".pickle")): return value raise vol.Invalid(f"{value} does not end in either `.json` or `.pickle`")
[ "def", "is_persistence_file", "(", "value", ")", ":", "if", "value", ".", "endswith", "(", "(", "\".json\"", ",", "\".pickle\"", ")", ")", ":", "return", "value", "raise", "vol", ".", "Invalid", "(", "f\"{value} does not end in either `.json` or `.pickle`\"", ")" ...
[ 54, 0 ]
[ 58, 77 ]
python
en
['en', 'en', 'en']
True
deprecated
(key)
Mark key as deprecated in configuration.
Mark key as deprecated in configuration.
def deprecated(key): """Mark key as deprecated in configuration.""" def validator(config): """Check if key is in config, log warning and remove key.""" if key not in config: return config _LOGGER.warning( "%s option for %s is deprecated. Please remove %s from you...
[ "def", "deprecated", "(", "key", ")", ":", "def", "validator", "(", "config", ")", ":", "\"\"\"Check if key is in config, log warning and remove key.\"\"\"", "if", "key", "not", "in", "config", ":", "return", "config", "_LOGGER", ".", "warning", "(", "\"%s option fo...
[ 61, 0 ]
[ 78, 20 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the MySensors component.
Set up the MySensors component.
async def async_setup(hass, config): """Set up the MySensors component.""" gateways = await setup_gateways(hass, config) if not gateways: _LOGGER.error("No devices could be setup as gateways, check your configuration") return False hass.data[MYSENSORS_GATEWAYS] = gateways hass.asy...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "gateways", "=", "await", "setup_gateways", "(", "hass", ",", "config", ")", "if", "not", "gateways", ":", "_LOGGER", ".", "error", "(", "\"No devices could be setup as gateways, check your confi...
[ 114, 0 ]
[ 126, 15 ]
python
en
['en', 'en', 'en']
True
_get_mysensors_name
(gateway, node_id, child_id)
Return a name for a node child.
Return a name for a node child.
def _get_mysensors_name(gateway, node_id, child_id): """Return a name for a node child.""" node_name = f"{gateway.sensors[node_id].sketch_name} {node_id}" node_name = next( ( node[CONF_NODE_NAME] for conf_id, node in gateway.nodes_config.items() if node.get(CONF_N...
[ "def", "_get_mysensors_name", "(", "gateway", ",", "node_id", ",", "child_id", ")", ":", "node_name", "=", "f\"{gateway.sensors[node_id].sketch_name} {node_id}\"", "node_name", "=", "next", "(", "(", "node", "[", "CONF_NODE_NAME", "]", "for", "conf_id", ",", "node",...
[ 129, 0 ]
[ 140, 36 ]
python
en
['en', 'en', 'en']
True
setup_mysensors_platform
( hass, domain, discovery_info, device_class, device_args=None, async_add_entities=None, )
Set up a MySensors platform.
Set up a MySensors platform.
def setup_mysensors_platform( hass, domain, discovery_info, device_class, device_args=None, async_add_entities=None, ): """Set up a MySensors platform.""" # Only act if called via MySensors by discovery event. # Otherwise gateway is not set up. if not discovery_info: retu...
[ "def", "setup_mysensors_platform", "(", "hass", ",", "domain", ",", "discovery_info", ",", "device_class", ",", "device_args", "=", "None", ",", "async_add_entities", "=", "None", ",", ")", ":", "# Only act if called via MySensors by discovery event.", "# Otherwise gatewa...
[ 144, 0 ]
[ 183, 22 ]
python
en
['en', 'da', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Geizwatch sensor.
Set up the Geizwatch sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Geizwatch sensor.""" name = config.get(CONF_NAME) description = config.get(CONF_DESCRIPTION) product_id = config.get(CONF_PRODUCT_ID) domain = config.get(CONF_LOCALE) add_entities([Geizwatch(name, description, pr...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "description", "=", "config", ".", "get", "(", "CONF_DESCRIPTION", ")", "produ...
[ 30, 0 ]
[ 37, 74 ]
python
en
['en', 'pt', 'en']
True
Geizwatch.__init__
(self, name, description, product_id, domain)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, description, product_id, domain): """Initialize the sensor.""" # internal self._name = name self._geizhals = Geizhals(product_id, domain) self._device = Device() # external self.description = description self.product_id = product...
[ "def", "__init__", "(", "self", ",", "name", ",", "description", ",", "product_id", ",", "domain", ")", ":", "# internal", "self", ".", "_name", "=", "name", "self", ".", "_geizhals", "=", "Geizhals", "(", "product_id", ",", "domain", ")", "self", ".", ...
[ 43, 4 ]
[ 53, 36 ]
python
en
['en', 'en', 'en']
True
Geizwatch.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" ]
[ 56, 4 ]
[ 58, 25 ]
python
en
['en', 'mi', 'en']
True
Geizwatch.icon
(self)
Return the icon for the frontend.
Return the icon for the frontend.
def icon(self): """Return the icon for the frontend.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 61, 4 ]
[ 63, 19 ]
python
en
['en', 'en', 'en']
True
Geizwatch.state
(self)
Return the best price of the selected product.
Return the best price of the selected product.
def state(self): """Return the best price of the selected product.""" if not self._device.prices: return None return self._device.prices[0]
[ "def", "state", "(", "self", ")", ":", "if", "not", "self", ".", "_device", ".", "prices", ":", "return", "None", "return", "self", ".", "_device", ".", "prices", "[", "0", "]" ]
[ 66, 4 ]
[ 71, 37 ]
python
en
['en', 'en', 'en']
True
Geizwatch.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" while len(self._device.prices) < 4: self._device.prices.append("None") attrs = { "device_name": self._device.name, "description": self.description, "unit_of_measurement": self._d...
[ "def", "device_state_attributes", "(", "self", ")", ":", "while", "len", "(", "self", ".", "_device", ".", "prices", ")", "<", "4", ":", "self", ".", "_device", ".", "prices", ".", "append", "(", "\"None\"", ")", "attrs", "=", "{", "\"device_name\"", "...
[ 74, 4 ]
[ 88, 20 ]
python
en
['en', 'en', 'en']
True
Geizwatch.update
(self)
Get the latest price from geizhals and updates the state.
Get the latest price from geizhals and updates the state.
def update(self): """Get the latest price from geizhals and updates the state.""" self._device = self._geizhals.parse()
[ "def", "update", "(", "self", ")", ":", "self", ".", "_device", "=", "self", ".", "_geizhals", ".", "parse", "(", ")" ]
[ 91, 4 ]
[ 93, 45 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistantType, config)
Set up STT.
Set up STT.
async def async_setup(hass: HomeAssistantType, config): """Set up STT.""" providers = {} async def async_setup_platform(p_type, p_config=None, discovery_info=None): """Set up a TTS platform.""" if p_config is None: p_config = {} platform = await async_prepare_setup_plat...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistantType", ",", "config", ")", ":", "providers", "=", "{", "}", "async", "def", "async_setup_platform", "(", "p_type", ",", "p_config", "=", "None", ",", "discovery_info", "=", "None", ")", ":", "\...
[ 36, 0 ]
[ 79, 15 ]
python
en
['en', 'lb', 'en']
True
Provider.supported_languages
(self)
Return a list of supported languages.
Return a list of supported languages.
def supported_languages(self) -> List[str]: """Return a list of supported languages."""
[ "def", "supported_languages", "(", "self", ")", "->", "List", "[", "str", "]", ":" ]
[ 110, 4 ]
[ 111, 51 ]
python
en
['en', 'en', 'en']
True
Provider.supported_formats
(self)
Return a list of supported formats.
Return a list of supported formats.
def supported_formats(self) -> List[AudioFormats]: """Return a list of supported formats."""
[ "def", "supported_formats", "(", "self", ")", "->", "List", "[", "AudioFormats", "]", ":" ]
[ 115, 4 ]
[ 116, 49 ]
python
en
['en', 'en', 'en']
True
Provider.supported_codecs
(self)
Return a list of supported codecs.
Return a list of supported codecs.
def supported_codecs(self) -> List[AudioCodecs]: """Return a list of supported codecs."""
[ "def", "supported_codecs", "(", "self", ")", "->", "List", "[", "AudioCodecs", "]", ":" ]
[ 120, 4 ]
[ 121, 48 ]
python
en
['en', 'en', 'en']
True
Provider.supported_bit_rates
(self)
Return a list of supported bit rates.
Return a list of supported bit rates.
def supported_bit_rates(self) -> List[AudioBitRates]: """Return a list of supported bit rates."""
[ "def", "supported_bit_rates", "(", "self", ")", "->", "List", "[", "AudioBitRates", "]", ":" ]
[ 125, 4 ]
[ 126, 51 ]
python
en
['en', 'en', 'en']
True
Provider.supported_sample_rates
(self)
Return a list of supported sample rates.
Return a list of supported sample rates.
def supported_sample_rates(self) -> List[AudioSampleRates]: """Return a list of supported sample rates."""
[ "def", "supported_sample_rates", "(", "self", ")", "->", "List", "[", "AudioSampleRates", "]", ":" ]
[ 130, 4 ]
[ 131, 54 ]
python
en
['en', 'en', 'en']
True
Provider.supported_channels
(self)
Return a list of supported channels.
Return a list of supported channels.
def supported_channels(self) -> List[AudioChannels]: """Return a list of supported channels."""
[ "def", "supported_channels", "(", "self", ")", "->", "List", "[", "AudioChannels", "]", ":" ]
[ 135, 4 ]
[ 136, 50 ]
python
en
['en', 'en', 'en']
True
Provider.async_process_audio_stream
( self, metadata: SpeechMetadata, stream: StreamReader )
Process an audio stream to STT service. Only streaming of content are allow!
Process an audio stream to STT service.
async def async_process_audio_stream( self, metadata: SpeechMetadata, stream: StreamReader ) -> SpeechResult: """Process an audio stream to STT service. Only streaming of content are allow! """
[ "async", "def", "async_process_audio_stream", "(", "self", ",", "metadata", ":", "SpeechMetadata", ",", "stream", ":", "StreamReader", ")", "->", "SpeechResult", ":" ]
[ 139, 4 ]
[ 145, 11 ]
python
en
['en', 'lb', 'en']
True
Provider.check_metadata
(self, metadata: SpeechMetadata)
Check if given metadata supported by this provider.
Check if given metadata supported by this provider.
def check_metadata(self, metadata: SpeechMetadata) -> bool: """Check if given metadata supported by this provider.""" if ( metadata.language not in self.supported_languages or metadata.format not in self.supported_formats or metadata.codec not in self.supported_codecs...
[ "def", "check_metadata", "(", "self", ",", "metadata", ":", "SpeechMetadata", ")", "->", "bool", ":", "if", "(", "metadata", ".", "language", "not", "in", "self", ".", "supported_languages", "or", "metadata", ".", "format", "not", "in", "self", ".", "suppo...
[ 148, 4 ]
[ 159, 19 ]
python
en
['en', 'en', 'en']
True
SpeechToTextView.__init__
(self, providers: Dict[str, Provider])
Initialize a tts view.
Initialize a tts view.
def __init__(self, providers: Dict[str, Provider]) -> None: """Initialize a tts view.""" self.providers = providers
[ "def", "__init__", "(", "self", ",", "providers", ":", "Dict", "[", "str", ",", "Provider", "]", ")", "->", "None", ":", "self", ".", "providers", "=", "providers" ]
[ 169, 4 ]
[ 171, 34 ]
python
en
['en', 'en', 'en']
True
SpeechToTextView._metadata_from_header
(request: web.Request)
Extract metadata from header. X-Speech-Content: format=wav; codec=pcm; sample_rate=16000; bit_rate=16; channel=1; language=de_de
Extract metadata from header.
def _metadata_from_header(request: web.Request) -> Optional[SpeechMetadata]: """Extract metadata from header. X-Speech-Content: format=wav; codec=pcm; sample_rate=16000; bit_rate=16; channel=1; language=de_de """ try: data = request.headers[istr("X-Speech-Content")].split(";...
[ "def", "_metadata_from_header", "(", "request", ":", "web", ".", "Request", ")", "->", "Optional", "[", "SpeechMetadata", "]", ":", "try", ":", "data", "=", "request", ".", "headers", "[", "istr", "(", "\"X-Speech-Content\"", ")", "]", ".", "split", "(", ...
[ 174, 4 ]
[ 195, 23 ]
python
en
['en', 'en', 'en']
True
SpeechToTextView.post
(self, request: web.Request, provider: str)
Convert Speech (audio) to text.
Convert Speech (audio) to text.
async def post(self, request: web.Request, provider: str) -> web.Response: """Convert Speech (audio) to text.""" if provider not in self.providers: raise HTTPNotFound() stt_provider: Provider = self.providers[provider] # Get metadata metadata = self._metadata_from_he...
[ "async", "def", "post", "(", "self", ",", "request", ":", "web", ".", "Request", ",", "provider", ":", "str", ")", "->", "web", ".", "Response", ":", "if", "provider", "not", "in", "self", ".", "providers", ":", "raise", "HTTPNotFound", "(", ")", "st...
[ 197, 4 ]
[ 218, 45 ]
python
en
['en', 'lb', 'en']
True
SpeechToTextView.get
(self, request: web.Request, provider: str)
Return provider specific audio information.
Return provider specific audio information.
async def get(self, request: web.Request, provider: str) -> web.Response: """Return provider specific audio information.""" if provider not in self.providers: raise HTTPNotFound() stt_provider: Provider = self.providers[provider] return self.json( { ...
[ "async", "def", "get", "(", "self", ",", "request", ":", "web", ".", "Request", ",", "provider", ":", "str", ")", "->", "web", ".", "Response", ":", "if", "provider", "not", "in", "self", ".", "providers", ":", "raise", "HTTPNotFound", "(", ")", "stt...
[ 220, 4 ]
[ 235, 9 ]
python
de
['it', 'de', 'en']
False