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
AlexaSemantics._add_state_mapping
(self, semantics)
Add state mapping between states and interface directives.
Add state mapping between states and interface directives.
def _add_state_mapping(self, semantics): """Add state mapping between states and interface directives.""" self._state_mappings.append(semantics)
[ "def", "_add_state_mapping", "(", "self", ",", "semantics", ")", ":", "self", ".", "_state_mappings", ".", "append", "(", "semantics", ")" ]
[ 360, 4 ]
[ 362, 46 ]
python
en
['en', 'en', 'en']
True
AlexaSemantics.add_states_to_value
(self, states, value)
Add StatesToValue stateMappings.
Add StatesToValue stateMappings.
def add_states_to_value(self, states, value): """Add StatesToValue stateMappings.""" self._add_state_mapping( {"@type": self.STATES_TO_VALUE, "states": states, "value": value} )
[ "def", "add_states_to_value", "(", "self", ",", "states", ",", "value", ")", ":", "self", ".", "_add_state_mapping", "(", "{", "\"@type\"", ":", "self", ".", "STATES_TO_VALUE", ",", "\"states\"", ":", "states", ",", "\"value\"", ":", "value", "}", ")" ]
[ 364, 4 ]
[ 368, 9 ]
python
en
['es', 'en', 'en']
True
AlexaSemantics.add_states_to_range
(self, states, min_value, max_value)
Add StatesToRange stateMappings.
Add StatesToRange stateMappings.
def add_states_to_range(self, states, min_value, max_value): """Add StatesToRange stateMappings.""" self._add_state_mapping( { "@type": self.STATES_TO_RANGE, "states": states, "range": {"minimumValue": min_value, "maximumValue": max_value}, ...
[ "def", "add_states_to_range", "(", "self", ",", "states", ",", "min_value", ",", "max_value", ")", ":", "self", ".", "_add_state_mapping", "(", "{", "\"@type\"", ":", "self", ".", "STATES_TO_RANGE", ",", "\"states\"", ":", "states", ",", "\"range\"", ":", "{...
[ 370, 4 ]
[ 378, 9 ]
python
en
['en', 'ny', 'en']
True
AlexaSemantics.add_action_to_directive
(self, actions, directive, payload)
Add ActionsToDirective actionMappings.
Add ActionsToDirective actionMappings.
def add_action_to_directive(self, actions, directive, payload): """Add ActionsToDirective actionMappings.""" self._add_action_mapping( { "@type": self.ACTIONS_TO_DIRECTIVE, "actions": actions, "directive": {"name": directive, "payload": payload...
[ "def", "add_action_to_directive", "(", "self", ",", "actions", ",", "directive", ",", "payload", ")", ":", "self", ".", "_add_action_mapping", "(", "{", "\"@type\"", ":", "self", ".", "ACTIONS_TO_DIRECTIVE", ",", "\"actions\"", ":", "actions", ",", "\"directive\...
[ 380, 4 ]
[ 388, 9 ]
python
en
['en', 'en', 'en']
True
AlexaSemantics.serialize_semantics
(self)
Return semantics object serialized for an API response.
Return semantics object serialized for an API response.
def serialize_semantics(self): """Return semantics object serialized for an API response.""" semantics = {} if self._action_mappings: semantics[self.MAPPINGS_ACTION] = self._action_mappings if self._state_mappings: semantics[self.MAPPINGS_STATE] = self._state_mapp...
[ "def", "serialize_semantics", "(", "self", ")", ":", "semantics", "=", "{", "}", "if", "self", ".", "_action_mappings", ":", "semantics", "[", "self", ".", "MAPPINGS_ACTION", "]", "=", "self", ".", "_action_mappings", "if", "self", ".", "_state_mappings", ":...
[ 390, 4 ]
[ 398, 24 ]
python
en
['en', 'no', 'en']
True
test_speedtestdotnet_sensors
(hass)
Test sensors created for speedtestdotnet integration.
Test sensors created for speedtestdotnet integration.
async def test_speedtestdotnet_sensors(hass): """Test sensors created for speedtestdotnet integration.""" entry = MockConfigEntry(domain=speedtestdotnet.DOMAIN, data={}) entry.add_to_hass(hass) with patch("speedtest.Speedtest") as mock_api: mock_api.return_value.get_best_server.return_value = M...
[ "async", "def", "test_speedtestdotnet_sensors", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "speedtestdotnet", ".", "DOMAIN", ",", "data", "=", "{", "}", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "with", "patch", "...
[ 11, 0 ]
[ 29, 55 ]
python
en
['en', 'no', 'en']
True
try_connection
(broker, port, username, password, protocol="3.1")
Test if we can connect to an MQTT broker.
Test if we can connect to an MQTT broker.
def try_connection(broker, port, username, password, protocol="3.1"): """Test if we can connect to an MQTT broker.""" # pylint: disable=import-outside-toplevel import paho.mqtt.client as mqtt if protocol == "3.1": proto = mqtt.MQTTv31 else: proto = mqtt.MQTTv311 client = mqtt.C...
[ "def", "try_connection", "(", "broker", ",", "port", ",", "username", ",", "password", ",", "protocol", "=", "\"3.1\"", ")", ":", "# pylint: disable=import-outside-toplevel", "import", "paho", ".", "mqtt", ".", "client", "as", "mqtt", "if", "protocol", "==", "...
[ 328, 0 ]
[ 359, 26 ]
python
en
['en', 'en', 'en']
True
MQTTOptionsFlowHandler.__init__
(self, config_entry)
Initialize MQTT options flow.
Initialize MQTT options flow.
def __init__(self, config_entry): """Initialize MQTT options flow.""" self.config_entry = config_entry self.broker_config = {} self.options = dict(config_entry.options)
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry", "self", ".", "broker_config", "=", "{", "}", "self", ".", "options", "=", "dict", "(", "config_entry", ".", "options", ")" ]
[ 151, 4 ]
[ 155, 49 ]
python
en
['en', 'fr', 'en']
True
MQTTOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the MQTT options.
Manage the MQTT options.
async def async_step_init(self, user_input=None): """Manage the MQTT options.""" return await self.async_step_broker()
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "return", "await", "self", ".", "async_step_broker", "(", ")" ]
[ 157, 4 ]
[ 159, 45 ]
python
en
['en', 'en', 'en']
True
MQTTOptionsFlowHandler.async_step_broker
(self, user_input=None)
Manage the MQTT options.
Manage the MQTT options.
async def async_step_broker(self, user_input=None): """Manage the MQTT options.""" errors = {} current_config = self.config_entry.data yaml_config = self.hass.data.get(DATA_MQTT_CONFIG, {}) if user_input is not None: can_connect = await self.hass.async_add_executor_jo...
[ "async", "def", "async_step_broker", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "current_config", "=", "self", ".", "config_entry", ".", "data", "yaml_config", "=", "self", ".", "hass", ".", "data", ".", "get", "(", ...
[ 161, 4 ]
[ 205, 9 ]
python
en
['en', 'en', 'en']
True
MQTTOptionsFlowHandler.async_step_options
(self, user_input=None)
Manage the MQTT options.
Manage the MQTT options.
async def async_step_options(self, user_input=None): """Manage the MQTT options.""" errors = {} current_config = self.config_entry.data yaml_config = self.hass.data.get(DATA_MQTT_CONFIG, {}) options_config = {} if user_input is not None: bad_birth = False ...
[ "async", "def", "async_step_options", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "current_config", "=", "self", ".", "config_entry", ".", "data", "yaml_config", "=", "self", ".", "hass", ".", "data", ".", "get", "(", ...
[ 207, 4 ]
[ 325, 9 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Wink platform.
Set up the Wink platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink platform.""" for camera in pywink.get_cameras(): # get_cameras returns multiple device types. # Only add those that aren't sensors. try: camera.capability() except AttributeError:...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "for", "camera", "in", "pywink", ".", "get_cameras", "(", ")", ":", "# get_cameras returns multiple device types.", "# Only add those that aren't se...
[ 19, 0 ]
[ 30, 62 ]
python
en
['en', 'da', 'en']
True
WinkCameraDevice.async_added_to_hass
(self)
Call when entity is added to hass.
Call when entity is added to hass.
async def async_added_to_hass(self): """Call when entity is added to hass.""" self.hass.data[DOMAIN]["entities"]["alarm_control_panel"].append(self)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"entities\"", "]", "[", "\"alarm_control_panel\"", "]", ".", "append", "(", "self", ")" ]
[ 36, 4 ]
[ 38, 78 ]
python
en
['en', 'en', 'en']
True
WinkCameraDevice.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" wink_state = self.wink.state() if wink_state == "away": state = STATE_ALARM_ARMED_AWAY elif wink_state == "home": state = STATE_ALARM_DISARMED elif wink_state == "night": state = STATE_ALAR...
[ "def", "state", "(", "self", ")", ":", "wink_state", "=", "self", ".", "wink", ".", "state", "(", ")", "if", "wink_state", "==", "\"away\"", ":", "state", "=", "STATE_ALARM_ARMED_AWAY", "elif", "wink_state", "==", "\"home\"", ":", "state", "=", "STATE_ALAR...
[ 41, 4 ]
[ 52, 20 ]
python
en
['en', 'en', 'en']
True
WinkCameraDevice.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self) -> int: """Return the list of supported features.""" return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_ALARM_ARM_HOME", "|", "SUPPORT_ALARM_ARM_AWAY" ]
[ 55, 4 ]
[ 57, 62 ]
python
en
['en', 'en', 'en']
True
WinkCameraDevice.alarm_disarm
(self, code=None)
Send disarm command.
Send disarm command.
def alarm_disarm(self, code=None): """Send disarm command.""" self.wink.set_mode("home")
[ "def", "alarm_disarm", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "wink", ".", "set_mode", "(", "\"home\"", ")" ]
[ 59, 4 ]
[ 61, 34 ]
python
en
['en', 'pt', 'en']
True
WinkCameraDevice.alarm_arm_home
(self, code=None)
Send arm home command.
Send arm home command.
def alarm_arm_home(self, code=None): """Send arm home command.""" self.wink.set_mode("night")
[ "def", "alarm_arm_home", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "wink", ".", "set_mode", "(", "\"night\"", ")" ]
[ 63, 4 ]
[ 65, 35 ]
python
en
['en', 'pt', 'en']
True
WinkCameraDevice.alarm_arm_away
(self, code=None)
Send arm away command.
Send arm away command.
def alarm_arm_away(self, code=None): """Send arm away command.""" self.wink.set_mode("away")
[ "def", "alarm_arm_away", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "wink", ".", "set_mode", "(", "\"away\"", ")" ]
[ 67, 4 ]
[ 69, 34 ]
python
en
['en', 'en', 'en']
True
WinkCameraDevice.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return {"private": self.wink.private()}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "\"private\"", ":", "self", ".", "wink", ".", "private", "(", ")", "}" ]
[ 72, 4 ]
[ 74, 47 ]
python
en
['en', 'en', 'en']
True
test_entity_registry
(hass)
Tests that the devices are registered in the entity registry.
Tests that the devices are registered in the entity registry.
async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, SWITCH_DOMAIN) entity_registry = await hass.helpers.entity_registry.async_get_registry() entry = entity_registry.async_get(AUTOMATION_ID) assert entry.unique_id == AU...
[ "async", "def", "test_entity_registry", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "SWITCH_DOMAIN", ")", "entity_registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "entry", "=", ...
[ 24, 0 ]
[ 33, 40 ]
python
en
['en', 'en', 'en']
True
test_attributes
(hass)
Test the switch attributes are correct.
Test the switch attributes are correct.
async def test_attributes(hass): """Test the switch attributes are correct.""" await setup_platform(hass, SWITCH_DOMAIN) state = hass.states.get(DEVICE_ID) assert state.state == STATE_OFF
[ "async", "def", "test_attributes", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "SWITCH_DOMAIN", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "DEVICE_ID", ")", "assert", "state", ".", "state", "==", "STATE_OFF" ]
[ 36, 0 ]
[ 41, 35 ]
python
en
['en', 'en', 'en']
True
test_switch_on
(hass)
Test the switch can be turned on.
Test the switch can be turned on.
async def test_switch_on(hass): """Test the switch can be turned on.""" await setup_platform(hass, SWITCH_DOMAIN) with patch("abodepy.AbodeSwitch.switch_on") as mock_switch_on: assert await hass.services.async_call( SWITCH_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DEVICE_ID}, blocking=T...
[ "async", "def", "test_switch_on", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "SWITCH_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeSwitch.switch_on\"", ")", "as", "mock_switch_on", ":", "assert", "await", "hass", ".", "services", "...
[ 44, 0 ]
[ 54, 43 ]
python
en
['en', 'en', 'en']
True
test_switch_off
(hass)
Test the switch can be turned off.
Test the switch can be turned off.
async def test_switch_off(hass): """Test the switch can be turned off.""" await setup_platform(hass, SWITCH_DOMAIN) with patch("abodepy.AbodeSwitch.switch_off") as mock_switch_off: assert await hass.services.async_call( SWITCH_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DEVICE_ID}, block...
[ "async", "def", "test_switch_off", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "SWITCH_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeSwitch.switch_off\"", ")", "as", "mock_switch_off", ":", "assert", "await", "hass", ".", "services", ...
[ 57, 0 ]
[ 67, 44 ]
python
en
['en', 'en', 'en']
True
test_automation_attributes
(hass)
Test the automation attributes are correct.
Test the automation attributes are correct.
async def test_automation_attributes(hass): """Test the automation attributes are correct.""" await setup_platform(hass, SWITCH_DOMAIN) state = hass.states.get(AUTOMATION_ID) # State is set based on "enabled" key in automation JSON. assert state.state == STATE_ON
[ "async", "def", "test_automation_attributes", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "SWITCH_DOMAIN", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "AUTOMATION_ID", ")", "# State is set based on \"enabled\" key in automation J...
[ 70, 0 ]
[ 76, 34 ]
python
en
['en', 'en', 'en']
True
test_turn_automation_off
(hass)
Test the automation can be turned off.
Test the automation can be turned off.
async def test_turn_automation_off(hass): """Test the automation can be turned off.""" with patch("abodepy.AbodeAutomation.enable") as mock_trigger: await setup_platform(hass, SWITCH_DOMAIN) await hass.services.async_call( SWITCH_DOMAIN, SERVICE_TURN_OFF, {AT...
[ "async", "def", "test_turn_automation_off", "(", "hass", ")", ":", "with", "patch", "(", "\"abodepy.AbodeAutomation.enable\"", ")", "as", "mock_trigger", ":", "await", "setup_platform", "(", "hass", ",", "SWITCH_DOMAIN", ")", "await", "hass", ".", "services", ".",...
[ 79, 0 ]
[ 92, 51 ]
python
en
['en', 'en', 'en']
True
test_turn_automation_on
(hass)
Test the automation can be turned on.
Test the automation can be turned on.
async def test_turn_automation_on(hass): """Test the automation can be turned on.""" with patch("abodepy.AbodeAutomation.enable") as mock_trigger: await setup_platform(hass, SWITCH_DOMAIN) await hass.services.async_call( SWITCH_DOMAIN, SERVICE_TURN_ON, {ATTR_...
[ "async", "def", "test_turn_automation_on", "(", "hass", ")", ":", "with", "patch", "(", "\"abodepy.AbodeAutomation.enable\"", ")", "as", "mock_trigger", ":", "await", "setup_platform", "(", "hass", ",", "SWITCH_DOMAIN", ")", "await", "hass", ".", "services", ".", ...
[ 95, 0 ]
[ 108, 50 ]
python
en
['en', 'en', 'en']
True
test_trigger_automation
(hass, requests_mock)
Test the trigger automation service.
Test the trigger automation service.
async def test_trigger_automation(hass, requests_mock): """Test the trigger automation service.""" await setup_platform(hass, SWITCH_DOMAIN) with patch("abodepy.AbodeAutomation.trigger") as mock: await hass.services.async_call( ABODE_DOMAIN, SERVICE_TRIGGER_AUTOMATION, ...
[ "async", "def", "test_trigger_automation", "(", "hass", ",", "requests_mock", ")", ":", "await", "setup_platform", "(", "hass", ",", "SWITCH_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeAutomation.trigger\"", ")", "as", "mock", ":", "await", "hass", ".", ...
[ 111, 0 ]
[ 124, 33 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable )
Set up RainMachine switches based on a config entry.
Set up RainMachine switches based on a config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable ) -> None: """Set up RainMachine switches based on a config entry.""" controller = hass.data[DOMAIN][DATA_CONTROLLER][entry.entry_id] programs_coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", ")", "->", "None", ":", "controller", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_CONTROLLER", ...
[ 101, 0 ]
[ 123, 32 ]
python
en
['en', 'en', 'en']
True
RainMachineSwitch.__init__
( self, coordinator: DataUpdateCoordinator, controller: Controller, uid: int, name: str, entry: ConfigEntry, )
Initialize a generic RainMachine switch.
Initialize a generic RainMachine switch.
def __init__( self, coordinator: DataUpdateCoordinator, controller: Controller, uid: int, name: str, entry: ConfigEntry, ) -> None: """Initialize a generic RainMachine switch.""" super().__init__(coordinator, controller) self._data = coordinato...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "DataUpdateCoordinator", ",", "controller", ":", "Controller", ",", "uid", ":", "int", ",", "name", ":", "str", ",", "entry", ":", "ConfigEntry", ",", ")", "->", "None", ":", "super", "(", ")", "...
[ 129, 4 ]
[ 145, 23 ]
python
en
['en', 'co', 'en']
True
RainMachineSwitch.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._is_active and self.coordinator.last_update_success
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_is_active", "and", "self", ".", "coordinator", ".", "last_update_success" ]
[ 148, 4 ]
[ 150, 71 ]
python
en
['en', 'en', 'en']
True
RainMachineSwitch.icon
(self)
Return the icon.
Return the icon.
def icon(self) -> str: """Return the icon.""" return "mdi:water"
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "\"mdi:water\"" ]
[ 153, 4 ]
[ 155, 26 ]
python
en
['en', 'sr', 'en']
True
RainMachineSwitch.is_on
(self)
Return whether the program is running.
Return whether the program is running.
def is_on(self) -> bool: """Return whether the program is running.""" return self._is_on
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_is_on" ]
[ 158, 4 ]
[ 160, 26 ]
python
en
['en', 'no', 'en']
True
RainMachineSwitch.unique_id
(self)
Return a unique, Home Assistant friendly identifier for this entity.
Return a unique, Home Assistant friendly identifier for this entity.
def unique_id(self) -> str: """Return a unique, Home Assistant friendly identifier for this entity.""" return f"{self._unique_id}_{self._switch_type}_{self._uid}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._unique_id}_{self._switch_type}_{self._uid}\"" ]
[ 163, 4 ]
[ 165, 67 ]
python
en
['en', 'en', 'en']
True
RainMachineSwitch._async_run_switch_coroutine
(self, api_coro: Coroutine)
Run a coroutine to toggle the switch.
Run a coroutine to toggle the switch.
async def _async_run_switch_coroutine(self, api_coro: Coroutine) -> None: """Run a coroutine to toggle the switch.""" try: resp = await api_coro except RequestError as err: LOGGER.error( 'Error while toggling %s "%s": %s', self._switch_type...
[ "async", "def", "_async_run_switch_coroutine", "(", "self", ",", "api_coro", ":", "Coroutine", ")", "->", "None", ":", "try", ":", "resp", "=", "await", "api_coro", "except", "RequestError", "as", "err", ":", "LOGGER", ".", "error", "(", "'Error while toggling...
[ 167, 4 ]
[ 193, 9 ]
python
en
['en', 'en', 'en']
True
RainMachineSwitch.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" self._data = self.coordinator.data[self._uid] self._is_active = self._data["active"]
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "self", ".", "_data", "=", "self", ".", "coordinator", ".", "data", "[", "self", ".", "_uid", "]", "self", ".", "_is_active", "=", "self", ".", "_data", "[", "\"active\"", "]" ]
[ 196, 4 ]
[ 199, 46 ]
python
en
['en', 'en', 'en']
True
RainMachineProgram.zones
(self)
Return a list of active zones associated with this program.
Return a list of active zones associated with this program.
def zones(self) -> list: """Return a list of active zones associated with this program.""" return [z for z in self._data["wateringTimes"] if z["active"]]
[ "def", "zones", "(", "self", ")", "->", "list", ":", "return", "[", "z", "for", "z", "in", "self", ".", "_data", "[", "\"wateringTimes\"", "]", "if", "z", "[", "\"active\"", "]", "]" ]
[ 206, 4 ]
[ 208, 70 ]
python
en
['en', 'en', 'en']
True
RainMachineProgram.async_turn_off
(self, **kwargs)
Turn the program off.
Turn the program off.
async def async_turn_off(self, **kwargs) -> None: """Turn the program off.""" await self._async_run_switch_coroutine( self._controller.programs.stop(self._uid) )
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_async_run_switch_coroutine", "(", "self", ".", "_controller", ".", "programs", ".", "stop", "(", "self", ".", "_uid", ")", ")" ]
[ 210, 4 ]
[ 214, 9 ]
python
en
['en', 'ja', 'en']
True
RainMachineProgram.async_turn_on
(self, **kwargs)
Turn the program on.
Turn the program on.
async def async_turn_on(self, **kwargs) -> None: """Turn the program on.""" await self._async_run_switch_coroutine( self._controller.programs.start(self._uid) )
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_async_run_switch_coroutine", "(", "self", ".", "_controller", ".", "programs", ".", "start", "(", "self", ".", "_uid", ")", ")" ]
[ 216, 4 ]
[ 220, 9 ]
python
en
['en', 'et', 'en']
True
RainMachineProgram.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" super().update_from_latest_data() self._is_on = bool(self._data["status"]) if self._data.get("nextRun") is not None: next_run = datetime.strptime( f"{self._data['nextRun']} {self._data['start...
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "super", "(", ")", ".", "update_from_latest_data", "(", ")", "self", ".", "_is_on", "=", "bool", "(", "self", ".", "_data", "[", "\"status\"", "]", ")", "if", "self", ".", "_data", ...
[ 223, 4 ]
[ 245, 9 ]
python
en
['en', 'en', 'en']
True
RainMachineZone.async_turn_off
(self, **kwargs)
Turn the zone off.
Turn the zone off.
async def async_turn_off(self, **kwargs) -> None: """Turn the zone off.""" await self._async_run_switch_coroutine(self._controller.zones.stop(self._uid))
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_async_run_switch_coroutine", "(", "self", ".", "_controller", ".", "zones", ".", "stop", "(", "self", ".", "_uid", ")", ")" ]
[ 251, 4 ]
[ 253, 86 ]
python
en
['en', 'en', 'en']
True
RainMachineZone.async_turn_on
(self, **kwargs)
Turn the zone on.
Turn the zone on.
async def async_turn_on(self, **kwargs) -> None: """Turn the zone on.""" await self._async_run_switch_coroutine( self._controller.zones.start( self._uid, self._entry.options[CONF_ZONE_RUN_TIME], ) )
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_async_run_switch_coroutine", "(", "self", ".", "_controller", ".", "zones", ".", "start", "(", "self", ".", "_uid", ",", "self", ".", ...
[ 255, 4 ]
[ 262, 9 ]
python
en
['en', 'en', 'en']
True
RainMachineZone.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" super().update_from_latest_data() self._is_on = bool(self._data["state"]) self._attrs.update( { ATTR_STATUS: RUN_STATUS_MAP[self._data["state"]], ATTR_AREA: self._data.get("wa...
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "super", "(", ")", ".", "update_from_latest_data", "(", ")", "self", ".", "_is_on", "=", "bool", "(", "self", ".", "_data", "[", "\"state\"", "]", ")", "self", ".", "_attrs", ".", "...
[ 265, 4 ]
[ 288, 9 ]
python
en
['en', 'en', 'en']
True
test_setup_entry_login_error
(hass)
Test entry setup failed due to login error.
Test entry setup failed due to login error.
async def test_setup_entry_login_error(hass): """Test entry setup failed due to login error.""" entry = mock_config_entry() with patch( "homeassistant.components.ruckus_unleashed.Ruckus", side_effect=AuthenticationError, ): entry.add_to_hass(hass) result = await hass.conf...
[ "async", "def", "test_setup_entry_login_error", "(", "hass", ")", ":", "entry", "=", "mock_config_entry", "(", ")", "with", "patch", "(", "\"homeassistant.components.ruckus_unleashed.Ruckus\"", ",", "side_effect", "=", "AuthenticationError", ",", ")", ":", "entry", "....
[ 31, 0 ]
[ 42, 26 ]
python
en
['en', 'en', 'en']
True
test_setup_entry_connection_error
(hass)
Test entry setup failed due to connection error.
Test entry setup failed due to connection error.
async def test_setup_entry_connection_error(hass): """Test entry setup failed due to connection error.""" entry = mock_config_entry() with patch( "homeassistant.components.ruckus_unleashed.Ruckus", side_effect=ConnectionError, ): entry.add_to_hass(hass) await hass.config_...
[ "async", "def", "test_setup_entry_connection_error", "(", "hass", ")", ":", "entry", "=", "mock_config_entry", "(", ")", "with", "patch", "(", "\"homeassistant.components.ruckus_unleashed.Ruckus\"", ",", "side_effect", "=", "ConnectionError", ",", ")", ":", "entry", "...
[ 45, 0 ]
[ 56, 49 ]
python
en
['en', 'en', 'en']
True
test_router_device_setup
(hass)
Test a router device is created.
Test a router device is created.
async def test_router_device_setup(hass): """Test a router device is created.""" await init_integration(hass) device_info = DEFAULT_AP_INFO[API_AP][API_ID]["1"] device_registry = await hass.helpers.device_registry.async_get_registry() device = device_registry.async_get_device( identifiers=...
[ "async", "def", "test_router_device_setup", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "device_info", "=", "DEFAULT_AP_INFO", "[", "API_AP", "]", "[", "API_ID", "]", "[", "\"1\"", "]", "device_registry", "=", "await", "hass", ".", ...
[ 59, 0 ]
[ 76, 39 ]
python
en
['en', 'en', 'en']
True
test_unload_entry
(hass)
Test successful unload of entry.
Test successful unload of entry.
async def test_unload_entry(hass): """Test successful unload of entry.""" entry = await init_integration(hass) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.state == ENTRY_STATE_LOADED assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_bloc...
[ "async", "def", "test_unload_entry", "(", "hass", ")", ":", "entry", "=", "await", "init_integration", "(", "hass", ")", "assert", "len", "(", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ")", "==", "1", "assert", "entry", ".", ...
[ 79, 0 ]
[ 90, 36 ]
python
en
['en', 'en', 'en']
True
test_config_not_ready_during_setup
(hass)
Test we throw a ConfigNotReady if Coordinator update fails.
Test we throw a ConfigNotReady if Coordinator update fails.
async def test_config_not_ready_during_setup(hass): """Test we throw a ConfigNotReady if Coordinator update fails.""" entry = mock_config_entry() with patch( "homeassistant.components.ruckus_unleashed.Ruckus.connect", return_value=None, ), patch( "homeassistant.components.ruckus_...
[ "async", "def", "test_config_not_ready_during_setup", "(", "hass", ")", ":", "entry", "=", "mock_config_entry", "(", ")", "with", "patch", "(", "\"homeassistant.components.ruckus_unleashed.Ruckus.connect\"", ",", "return_value", "=", "None", ",", ")", ",", "patch", "(...
[ 93, 0 ]
[ 113, 49 ]
python
en
['en', 'en', 'en']
True
shift_tokens_right
(input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int)
Shift input ids one token to the right.
Shift input ids one token to the right.
def shift_tokens_right(input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int): """ Shift input ids one token to the right. """ shifted_input_ids = input_ids.new_zeros(input_ids.shape) shifted_input_ids[:, 1:] = input_ids[:, :-1].clone() shifted_input_ids[:, 0] = decoder_start_t...
[ "def", "shift_tokens_right", "(", "input_ids", ":", "torch", ".", "Tensor", ",", "pad_token_id", ":", "int", ",", "decoder_start_token_id", ":", "int", ")", ":", "shifted_input_ids", "=", "input_ids", ".", "new_zeros", "(", "input_ids", ".", "shape", ")", "shi...
[ 60, 0 ]
[ 72, 28 ]
python
en
['en', 'error', 'th']
False
_make_causal_mask
(input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0)
Make causal mask used for bi-directional self-attention.
Make causal mask used for bi-directional self-attention.
def _make_causal_mask(input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0): """ Make causal mask used for bi-directional self-attention. """ bsz, tgt_len = input_ids_shape mask = torch.full((tgt_len, tgt_len), float("-inf")) mask_cond = torch.arange(mask.size(-1)) ...
[ "def", "_make_causal_mask", "(", "input_ids_shape", ":", "torch", ".", "Size", ",", "dtype", ":", "torch", ".", "dtype", ",", "past_key_values_length", ":", "int", "=", "0", ")", ":", "bsz", ",", "tgt_len", "=", "input_ids_shape", "mask", "=", "torch", "."...
[ 76, 0 ]
[ 88, 91 ]
python
en
['en', 'error', 'th']
False
_expand_mask
(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None)
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: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None): """ Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`. """ bsz, src_len = mask.size() tgt_len = tgt_len if tgt_len is not None else src_len expanded_mask = mask[:, None, N...
[ "def", "_expand_mask", "(", "mask", ":", "torch", ".", "Tensor", ",", "dtype", ":", "torch", ".", "dtype", ",", "tgt_len", ":", "Optional", "[", "int", "]", "=", "None", ")", ":", "bsz", ",", "src_len", "=", "mask", ".", "size", "(", ")", "tgt_len"...
[ 92, 0 ]
[ 103, 82 ]
python
en
['en', 'error', 'th']
False
PegasusSinusoidalPositionalEmbedding._init_weight
(out: nn.Parameter)
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in the 2nd half of the vector. [dim // 2:]
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in the 2nd half of the vector. [dim // 2:]
def _init_weight(out: nn.Parameter): """ Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in the 2nd half of the vector. [dim // 2:] """ n_pos, dim = out.shape position_enc = np.array( [[pos / np.power...
[ "def", "_init_weight", "(", "out", ":", "nn", ".", "Parameter", ")", ":", "n_pos", ",", "dim", "=", "out", ".", "shape", "position_enc", "=", "np", ".", "array", "(", "[", "[", "pos", "/", "np", ".", "power", "(", "10000", ",", "2", "*", "(", "...
[ 115, 4 ]
[ 129, 18 ]
python
en
['en', 'error', 'th']
False
PegasusSinusoidalPositionalEmbedding.forward
(self, input_ids_shape: torch.Size, past_key_values_length: int = 0)
`input_ids_shape` is expected to be [bsz x seqlen].
`input_ids_shape` is expected to be [bsz x seqlen].
def forward(self, input_ids_shape: torch.Size, past_key_values_length: int = 0): """`input_ids_shape` is expected to be [bsz x seqlen].""" bsz, seq_len = input_ids_shape[:2] positions = torch.arange( past_key_values_length, past_key_values_length + seq_len, dtype=torch.long, device=s...
[ "def", "forward", "(", "self", ",", "input_ids_shape", ":", "torch", ".", "Size", ",", "past_key_values_length", ":", "int", "=", "0", ")", ":", "bsz", ",", "seq_len", "=", "input_ids_shape", "[", ":", "2", "]", "positions", "=", "torch", ".", "arange", ...
[ 132, 4 ]
[ 138, 41 ]
python
en
['en', 'en', 'en']
True
PegasusAttention.forward
( self, hidden_states: torch.Tensor, key_value_states: Optional[torch.Tensor] = None, past_key_value: Optional[Tuple[torch.Tensor]] = None, attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, output_attentions: bool = Fal...
Input shape: Batch x Time x Channel
Input shape: Batch x Time x Channel
def forward( self, hidden_states: torch.Tensor, key_value_states: Optional[torch.Tensor] = None, past_key_value: Optional[Tuple[torch.Tensor]] = None, attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, output_attentions:...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "Tensor", ",", "key_value_states", ":", "Optional", "[", "torch", ".", "Tensor", "]", "=", "None", ",", "past_key_value", ":", "Optional", "[", "Tuple", "[", "torch", ".", "Tensor", ...
[ 172, 4 ]
[ 281, 65 ]
python
en
['en', 'pl', 'en']
True
PegasusEncoderLayer.forward
( self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, layer_head_mask: torch.Tensor, output_attentions: bool = False, )
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
def forward( self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, layer_head_mask: torch.Tensor, output_attentions: bool = False, ): """ Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "Tensor", ",", "attention_mask", ":", "torch", ".", "Tensor", ",", "layer_head_mask", ":", "torch", ".", "Tensor", ",", "output_attentions", ":", "bool", "=", "False", ",", ")", ":", ...
[ 302, 4 ]
[ 350, 22 ]
python
en
['en', 'error', 'th']
False
PegasusDecoderLayer.forward
( self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor] = None, encoder_hidden_states: Optional[torch.Tensor] = None, encoder_attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, encoder_layer_head_mask...
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
def forward( self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor] = None, encoder_hidden_states: Optional[torch.Tensor] = None, encoder_attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, encoder_laye...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "Tensor", ",", "attention_mask", ":", "Optional", "[", "torch", ".", "Tensor", "]", "=", "None", ",", "encoder_hidden_states", ":", "Optional", "[", "torch", ".", "Tensor", "]", "=", ...
[ 381, 4 ]
[ 467, 22 ]
python
en
['en', 'error', 'th']
False
PegasusEncoder.forward
( self, input_ids=None, attention_mask=None, head_mask=None, inputs_embeds=None, output_attentions=None, output_hidden_states=None, return_dict=None, )
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it. Indices can be obtained using :class:`~transfor...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it.
def forward( self, input_ids=None, attention_mask=None, head_mask=None, inputs_embeds=None, output_attentions=None, output_hidden_states=None, return_dict=None, ): r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:...
[ "def", "forward", "(", "self", ",", "input_ids", "=", "None", ",", "attention_mask", "=", "None", ",", "head_mask", "=", "None", ",", "inputs_embeds", "=", "None", ",", "output_attentions", "=", "None", ",", "output_hidden_states", "=", "None", ",", "return_...
[ 657, 4 ]
[ 787, 9 ]
python
cy
['en', 'cy', 'hi']
False
PegasusDecoder.forward
( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, use_cache=None, output_attentions=None, ...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it. Indices can be obtained using :class:`~transfor...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it.
def forward( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, use_cache=None, output_attentions=Non...
[ "def", "forward", "(", "self", ",", "input_ids", "=", "None", ",", "attention_mask", "=", "None", ",", "encoder_hidden_states", "=", "None", ",", "encoder_attention_mask", "=", "None", ",", "head_mask", "=", "None", ",", "encoder_head_mask", "=", "None", ",", ...
[ 847, 4 ]
[ 1055, 9 ]
python
cy
['en', 'cy', 'hi']
False
PegasusForCausalLM.forward
( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, labels=None, use_cache=None, output_atte...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it. Indices can be obtained using :class:`~transfor...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it.
def forward( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, labels=None, use_cache=None, ...
[ "def", "forward", "(", "self", ",", "input_ids", "=", "None", ",", "attention_mask", "=", "None", ",", "encoder_hidden_states", "=", "None", ",", "encoder_attention_mask", "=", "None", ",", "head_mask", "=", "None", ",", "encoder_head_mask", "=", "None", ",", ...
[ 1389, 4 ]
[ 1524, 9 ]
python
cy
['en', 'cy', 'hi']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Zigbee Home Automation Door Lock from config entry.
Set up the Zigbee Home Automation Door Lock from config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Zigbee Home Automation Door Lock from config entry.""" entities_to_create = hass.data[DATA_ZHA][DOMAIN] unsub = async_dispatcher_connect( hass, SIGNAL_ADD_ENTITIES, functools.partial( disc...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities_to_create", "=", "hass", ".", "data", "[", "DATA_ZHA", "]", "[", "DOMAIN", "]", "unsub", "=", "async_dispatcher_connect", "(", "hass", ",", "S...
[ 32, 0 ]
[ 43, 59 ]
python
en
['en', 'en', 'en']
True
floats_list
(shape, scale=1.0, rng=None, name=None)
Creates a random float32 tensor
Creates a random float32 tensor
def floats_list(shape, scale=1.0, rng=None, name=None): """Creates a random float32 tensor""" if rng is None: rng = global_rng values = [] for batch_idx in range(shape[0]): values.append([]) for _ in range(shape[1]): values[-1].append(rng.random() * scale) retur...
[ "def", "floats_list", "(", "shape", ",", "scale", "=", "1.0", ",", "rng", "=", "None", ",", "name", "=", "None", ")", ":", "if", "rng", "is", "None", ":", "rng", "=", "global_rng", "values", "=", "[", "]", "for", "batch_idx", "in", "range", "(", ...
[ 31, 0 ]
[ 42, 17 ]
python
en
['en', 'ca', 'en']
True
XLNetConfig.__init__
( self, vocab_size=32000, d_model=1024, n_layer=24, n_head=16, d_inner=4096, ff_activation="gelu", untie_r=True, attn_type="bi", initializer_range=0.02, layer_norm_eps=1e-12, dropout=0.1, mem_len=512, reuse_l...
Constructs XLNetConfig.
Constructs XLNetConfig.
def __init__( self, vocab_size=32000, d_model=1024, n_layer=24, n_head=16, d_inner=4096, ff_activation="gelu", untie_r=True, attn_type="bi", initializer_range=0.02, layer_norm_eps=1e-12, dropout=0.1, mem_len=512, ...
[ "def", "__init__", "(", "self", ",", "vocab_size", "=", "32000", ",", "d_model", "=", "1024", ",", "n_layer", "=", "24", ",", "n_head", "=", "16", ",", "d_inner", "=", "4096", ",", "ff_activation", "=", "\"gelu\"", ",", "untie_r", "=", "True", ",", "...
[ 140, 4 ]
[ 217, 44 ]
python
en
['en', 'de', 'en']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Import the device and discontinue platform. This is for backward compatibility. Do not use this method.
Import the device and discontinue platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Import the device and discontinue platform. This is for backward compatibility. Do not use this method. """ import_device(hass, config[CONF_HOST]) _LOGGER.warning( "The remote platform is deprecate...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "import_device", "(", "hass", ",", "config", "[", "CONF_HOST", "]", ")", "_LOGGER", ".", "warning", "(", "\"The remote ...
[ 81, 0 ]
[ 90, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up a Broadlink remote.
Set up a Broadlink remote.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up a Broadlink remote.""" device = hass.data[DOMAIN].devices[config_entry.entry_id] remote = BroadlinkRemote( device, Store(hass, CODE_STORAGE_VERSION, f"broadlink_remote_{device.unique_id}_codes"), Store(has...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "device", "=", "hass", ".", "data", "[", "DOMAIN", "]", ".", "devices", "[", "config_entry", ".", "entry_id", "]", "remote", "=", "BroadlinkRemote", "...
[ 93, 0 ]
[ 107, 39 ]
python
en
['en', 'da', 'en']
True
BroadlinkRemote.__init__
(self, device, codes, flags)
Initialize the remote.
Initialize the remote.
def __init__(self, device, codes, flags): """Initialize the remote.""" self._device = device self._coordinator = device.update_manager.coordinator self._code_storage = codes self._flag_storage = flags self._codes = {} self._flags = defaultdict(int) self._s...
[ "def", "__init__", "(", "self", ",", "device", ",", "codes", ",", "flags", ")", ":", "self", ".", "_device", "=", "device", "self", ".", "_coordinator", "=", "device", ".", "update_manager", ".", "coordinator", "self", ".", "_code_storage", "=", "codes", ...
[ 113, 4 ]
[ 121, 26 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.name
(self)
Return the name of the remote.
Return the name of the remote.
def name(self): """Return the name of the remote.""" return f"{self._device.name} Remote"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._device.name} Remote\"" ]
[ 124, 4 ]
[ 126, 44 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.unique_id
(self)
Return the unique id of the remote.
Return the unique id of the remote.
def unique_id(self): """Return the unique id of the remote.""" return self._device.unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "unique_id" ]
[ 129, 4 ]
[ 131, 37 ]
python
en
['en', 'it', 'en']
True
BroadlinkRemote.is_on
(self)
Return True if the remote is on.
Return True if the remote is on.
def is_on(self): """Return True if the remote is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 134, 4 ]
[ 136, 26 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.available
(self)
Return True if the remote is available.
Return True if the remote is available.
def available(self): """Return True if the remote is available.""" return self._device.update_manager.available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "update_manager", ".", "available" ]
[ 139, 4 ]
[ 141, 52 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.should_poll
(self)
Return True if the remote has to be polled for state.
Return True if the remote has to be polled for state.
def should_poll(self): """Return True if the remote has to be polled for state.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 144, 4 ]
[ 146, 20 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_LEARN_COMMAND
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_LEARN_COMMAND" ]
[ 149, 4 ]
[ 151, 36 ]
python
en
['da', 'en', 'en']
True
BroadlinkRemote.device_info
(self)
Return device info.
Return device info.
def device_info(self): """Return device info.""" return { "identifiers": {(DOMAIN, self._device.unique_id)}, "manufacturer": self._device.api.manufacturer, "model": self._device.api.model, "name": self._device.name, "sw_version": self._device.f...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "_device", ".", "unique_id", ")", "}", ",", "\"manufacturer\"", ":", "self", ".", "_device", ".", "api", ".", "manufacturer", ",", ...
[ 154, 4 ]
[ 162, 9 ]
python
en
['es', 'hr', 'en']
False
BroadlinkRemote.get_code
(self, command, device)
Return a code and a boolean indicating a toggle command. If the command starts with `b64:`, extract the code from it. Otherwise, extract the code from the dictionary, using the device and command as keys. You need to change the flag whenever a toggle command is sent successfull...
Return a code and a boolean indicating a toggle command.
def get_code(self, command, device): """Return a code and a boolean indicating a toggle command. If the command starts with `b64:`, extract the code from it. Otherwise, extract the code from the dictionary, using the device and command as keys. You need to change the flag whene...
[ "def", "get_code", "(", "self", ",", "command", ",", "device", ")", ":", "if", "command", ".", "startswith", "(", "\"b64:\"", ")", ":", "code", ",", "is_toggle_cmd", "=", "command", "[", "4", ":", "]", ",", "False", "else", ":", "if", "device", "is",...
[ 164, 4 ]
[ 196, 53 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.get_flags
(self)
Return a dictionary of toggle flags. A toggle flag indicates whether the remote should send an alternative code.
Return a dictionary of toggle flags.
def get_flags(self): """Return a dictionary of toggle flags. A toggle flag indicates whether the remote should send an alternative code. """ return self._flags
[ "def", "get_flags", "(", "self", ")", ":", "return", "self", ".", "_flags" ]
[ 199, 4 ]
[ 205, 26 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.async_added_to_hass
(self)
Call when the remote is added to hass.
Call when the remote is added to hass.
async def async_added_to_hass(self): """Call when the remote is added to hass.""" state = await self.async_get_last_state() self._state = state is None or state.state != STATE_OFF self.async_on_remove( self._coordinator.async_add_listener(self.async_write_ha_state) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "self", ".", "_state", "=", "state", "is", "None", "or", "state", ".", "state", "!=", "STATE_OFF", "self", ".", "async_on_re...
[ 207, 4 ]
[ 214, 9 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.async_update
(self)
Update the remote.
Update the remote.
async def async_update(self): """Update the remote.""" await self._coordinator.async_request_refresh()
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "self", ".", "_coordinator", ".", "async_request_refresh", "(", ")" ]
[ 216, 4 ]
[ 218, 55 ]
python
en
['en', 'co', 'en']
True
BroadlinkRemote.async_turn_on
(self, **kwargs)
Turn on the remote.
Turn on the remote.
async def async_turn_on(self, **kwargs): """Turn on the remote.""" self._state = True self.async_write_ha_state()
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_state", "=", "True", "self", ".", "async_write_ha_state", "(", ")" ]
[ 220, 4 ]
[ 223, 35 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.async_turn_off
(self, **kwargs)
Turn off the remote.
Turn off the remote.
async def async_turn_off(self, **kwargs): """Turn off the remote.""" self._state = False self.async_write_ha_state()
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_state", "=", "False", "self", ".", "async_write_ha_state", "(", ")" ]
[ 225, 4 ]
[ 228, 35 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.async_load_storage_files
(self)
Load codes and toggle flags from storage files.
Load codes and toggle flags from storage files.
async def async_load_storage_files(self): """Load codes and toggle flags from storage files.""" try: self._codes.update(await self._code_storage.async_load() or {}) self._flags.update(await self._flag_storage.async_load() or {}) except HomeAssistantError: ret...
[ "async", "def", "async_load_storage_files", "(", "self", ")", ":", "try", ":", "self", ".", "_codes", ".", "update", "(", "await", "self", ".", "_code_storage", ".", "async_load", "(", ")", "or", "{", "}", ")", "self", ".", "_flags", ".", "update", "("...
[ 230, 4 ]
[ 239, 19 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.async_send_command
(self, command, **kwargs)
Send a list of commands to a device.
Send a list of commands to a device.
async def async_send_command(self, command, **kwargs): """Send a list of commands to a device.""" kwargs[ATTR_COMMAND] = command kwargs = SERVICE_SEND_SCHEMA(kwargs) commands = kwargs[ATTR_COMMAND] device = kwargs.get(ATTR_DEVICE) repeat = kwargs[ATTR_NUM_REPEATS] ...
[ "async", "def", "async_send_command", "(", "self", ",", "command", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "ATTR_COMMAND", "]", "=", "command", "kwargs", "=", "SERVICE_SEND_SCHEMA", "(", "kwargs", ")", "commands", "=", "kwargs", "[", "ATTR_COMMAND"...
[ 241, 4 ]
[ 286, 76 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote.async_learn_command
(self, **kwargs)
Learn a list of commands from a remote.
Learn a list of commands from a remote.
async def async_learn_command(self, **kwargs): """Learn a list of commands from a remote.""" kwargs = SERVICE_LEARN_SCHEMA(kwargs) commands = kwargs[ATTR_COMMAND] command_type = kwargs[ATTR_COMMAND_TYPE] device = kwargs[ATTR_DEVICE] toggle = kwargs[ATTR_ALTERNATIVE] ...
[ "async", "def", "async_learn_command", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "SERVICE_LEARN_SCHEMA", "(", "kwargs", ")", "commands", "=", "kwargs", "[", "ATTR_COMMAND", "]", "command_type", "=", "kwargs", "[", "ATTR_COMMAND_TYPE", "]",...
[ 288, 4 ]
[ 327, 60 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote._async_learn_ir_command
(self, command)
Learn an infrared command.
Learn an infrared command.
async def _async_learn_ir_command(self, command): """Learn an infrared command.""" try: await self._device.async_request(self._device.api.enter_learning) except (BroadlinkException, OSError) as err: _LOGGER.debug("Failed to enter learning mode: %s", err) rais...
[ "async", "def", "_async_learn_ir_command", "(", "self", ",", "command", ")", ":", "try", ":", "await", "self", ".", "_device", ".", "async_request", "(", "self", ".", "_device", ".", "api", ".", "enter_learning", ")", "except", "(", "BroadlinkException", ","...
[ 329, 4 ]
[ 362, 13 ]
python
en
['en', 'en', 'en']
True
BroadlinkRemote._async_learn_rf_command
(self, command)
Learn a radiofrequency command.
Learn a radiofrequency command.
async def _async_learn_rf_command(self, command): """Learn a radiofrequency command.""" try: await self._device.async_request(self._device.api.sweep_frequency) except (BroadlinkException, OSError) as err: _LOGGER.debug("Failed to sweep frequency: %s", err) ra...
[ "async", "def", "_async_learn_rf_command", "(", "self", ",", "command", ")", ":", "try", ":", "await", "self", ".", "_device", ".", "async_request", "(", "self", ".", "_device", ".", "api", ".", "sweep_frequency", ")", "except", "(", "BroadlinkException", ",...
[ 364, 4 ]
[ 435, 13 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable )
Set up RainMachine binary sensors based on a config entry.
Set up RainMachine binary sensors based on a config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable ) -> None: """Set up RainMachine binary sensors based on a config entry.""" controller = hass.data[DOMAIN][DATA_CONTROLLER][entry.entry_id] coordinators = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", ")", "->", "None", ":", "controller", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_CONTROLLER", ...
[ 74, 0 ]
[ 111, 5 ]
python
en
['en', 'en', 'en']
True
RainMachineBinarySensor.__init__
( self, coordinator: DataUpdateCoordinator, controller: Controller, sensor_type: str, name: str, icon: str, enabled_by_default: bool, )
Initialize the sensor.
Initialize the sensor.
def __init__( self, coordinator: DataUpdateCoordinator, controller: Controller, sensor_type: str, name: str, icon: str, enabled_by_default: bool, ) -> None: """Initialize the sensor.""" super().__init__(coordinator, controller) self._en...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "DataUpdateCoordinator", ",", "controller", ":", "Controller", ",", "sensor_type", ":", "str", ",", "name", ":", "str", ",", "icon", ":", "str", ",", "enabled_by_default", ":", "bool", ",", ")", "->"...
[ 117, 4 ]
[ 132, 26 ]
python
en
['en', 'en', 'en']
True
RainMachineBinarySensor.entity_registry_enabled_default
(self)
Determine whether an entity is enabled by default.
Determine whether an entity is enabled by default.
def entity_registry_enabled_default(self) -> bool: """Determine whether an entity is enabled by default.""" return self._enabled_by_default
[ "def", "entity_registry_enabled_default", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_enabled_by_default" ]
[ 135, 4 ]
[ 137, 39 ]
python
en
['en', 'en', 'en']
True
RainMachineBinarySensor.icon
(self)
Return the icon.
Return the icon.
def icon(self) -> str: """Return the icon.""" return self._icon
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_icon" ]
[ 140, 4 ]
[ 142, 25 ]
python
en
['en', 'sr', 'en']
True
RainMachineBinarySensor.is_on
(self)
Return the status of the sensor.
Return the status of the sensor.
def is_on(self) -> bool: """Return the status of the sensor.""" return self._state
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_state" ]
[ 145, 4 ]
[ 147, 26 ]
python
en
['en', 'id', 'en']
True
RainMachineBinarySensor.unique_id
(self)
Return a unique, Home Assistant friendly identifier for this entity.
Return a unique, Home Assistant friendly identifier for this entity.
def unique_id(self) -> str: """Return a unique, Home Assistant friendly identifier for this entity.""" return f"{self._unique_id}_{self._sensor_type}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._unique_id}_{self._sensor_type}\"" ]
[ 150, 4 ]
[ 152, 55 ]
python
en
['en', 'en', 'en']
True
CurrentRestrictionsBinarySensor.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" if self._sensor_type == TYPE_FREEZE: self._state = self.coordinator.data["freeze"] elif self._sensor_type == TYPE_HOURLY: self._state = self.coordinator.data["hourly"] elif self._sensor_type == TYP...
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_sensor_type", "==", "TYPE_FREEZE", ":", "self", ".", "_state", "=", "self", ".", "coordinator", ".", "data", "[", "\"freeze\"", "]", "elif", "self", ".", "_sensor_t...
[ 159, 4 ]
[ 172, 58 ]
python
en
['en', 'en', 'en']
True
ProvisionSettingsBinarySensor.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" if self._sensor_type == TYPE_FREEZE: self._state = self.coordinator.data["freeze"] elif self._sensor_type == TYPE_HOURLY: self._state = self.coordinator.data["hourly"] elif self._sensor_type == TYP...
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_sensor_type", "==", "TYPE_FREEZE", ":", "self", ".", "_state", "=", "self", ".", "coordinator", ".", "data", "[", "\"freeze\"", "]", "elif", "self", ".", "_sensor_t...
[ 179, 4 ]
[ 192, 58 ]
python
en
['en', 'en', 'en']
True
UniversalRestrictionsBinarySensor.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" if self._sensor_type == TYPE_FLOW_SENSOR: self._state = self.coordinator.data["system"].get("useFlowSensor")
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_sensor_type", "==", "TYPE_FLOW_SENSOR", ":", "self", ".", "_state", "=", "self", ".", "coordinator", ".", "data", "[", "\"system\"", "]", ".", "get", "(", "\"useFlo...
[ 199, 4 ]
[ 202, 78 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up Garmin Connect sensor based on a config entry.
Set up Garmin Connect sensor based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up Garmin Connect sensor based on a config entry.""" garmin_data = hass.data[DOMAIN][entry.entry_id] unique_id = entry.data[CONF_ID] try: await garmin_data.async_update() excep...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "garmin_data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", ...
[ 21, 0 ]
[ 67, 38 ]
python
en
['en', 'da', 'en']
True
GarminConnectSensor.__init__
( self, data, unique_id, sensor_type, name, unit, icon, device_class, enabled_default: bool = True, )
Initialize.
Initialize.
def __init__( self, data, unique_id, sensor_type, name, unit, icon, device_class, enabled_default: bool = True, ): """Initialize.""" self._data = data self._unique_id = unique_id self._type = sensor_type ...
[ "def", "__init__", "(", "self", ",", "data", ",", "unique_id", ",", "sensor_type", ",", "name", ",", "unit", ",", "icon", ",", "device_class", ",", "enabled_default", ":", "bool", "=", "True", ",", ")", ":", "self", ".", "_data", "=", "data", "self", ...
[ 73, 4 ]
[ 94, 26 ]
python
en
['en', 'en', 'it']
False
GarminConnectSensor.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" ]
[ 97, 4 ]
[ 99, 25 ]
python
en
['en', 'mi', 'en']
True
GarminConnectSensor.icon
(self)
Return the icon to use in the frontend.
Return the icon to use in the frontend.
def icon(self): """Return the icon to use in the frontend.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 102, 4 ]
[ 104, 25 ]
python
en
['en', 'en', 'en']
True
GarminConnectSensor.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" ]
[ 107, 4 ]
[ 109, 26 ]
python
en
['en', 'en', 'en']
True
GarminConnectSensor.unique_id
(self)
Return the unique ID for this sensor.
Return the unique ID for this sensor.
def unique_id(self) -> str: """Return the unique ID for this sensor.""" return f"{self._unique_id}_{self._type}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._unique_id}_{self._type}\"" ]
[ 112, 4 ]
[ 114, 48 ]
python
en
['en', 'la', 'en']
True
GarminConnectSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 117, 4 ]
[ 119, 25 ]
python
en
['en', 'la', 'en']
True
GarminConnectSensor.device_state_attributes
(self)
Return attributes for sensor.
Return attributes for sensor.
def device_state_attributes(self): """Return attributes for sensor.""" if not self._data.data: return {} attributes = { "source": self._data.data["source"], "last_synced": self._data.data["lastSyncTimestampGMT"], ATTR_ATTRIBUTION: ATTRIBUTION, ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "not", "self", ".", "_data", ".", "data", ":", "return", "{", "}", "attributes", "=", "{", "\"source\"", ":", "self", ".", "_data", ".", "data", "[", "\"source\"", "]", ",", "\"last_synced\""...
[ 122, 4 ]
[ 135, 25 ]
python
en
['en', 'id', 'en']
True
GarminConnectSensor.device_info
(self)
Return device information.
Return device information.
def device_info(self) -> Dict[str, Any]: """Return device information.""" return { "identifiers": {(DOMAIN, self._unique_id)}, "name": "Garmin Connect", "manufacturer": "Garmin Connect", }
[ "def", "device_info", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "_unique_id", ")", "}", ",", "\"name\"", ":", "\"Garmin Connect\"", ",", "\"manufacturer\...
[ 138, 4 ]
[ 144, 9 ]
python
da
['es', 'da', 'en']
False