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
EgardiaAlarm.lookupstatusfromcode
(self, statuscode)
Look at the rs_codes and returns the status from the code.
Look at the rs_codes and returns the status from the code.
def lookupstatusfromcode(self, statuscode): """Look at the rs_codes and returns the status from the code.""" status = next( ( status_group.upper() for status_group, codes in self._rs_codes.items() for code in codes if statuscode...
[ "def", "lookupstatusfromcode", "(", "self", ",", "statuscode", ")", ":", "status", "=", "next", "(", "(", "status_group", ".", "upper", "(", ")", "for", "status_group", ",", "codes", "in", "self", ".", "_rs_codes", ".", "items", "(", ")", "for", "code", ...
[ 105, 4 ]
[ 116, 21 ]
python
en
['en', 'en', 'en']
True
EgardiaAlarm.parsestatus
(self, status)
Parse the status.
Parse the status.
def parsestatus(self, status): """Parse the status.""" _LOGGER.debug("Parsing status %s", status) # Ignore the statuscode if it is IGNORE if status.lower().strip() != REPORT_SERVER_CODES_IGNORE: _LOGGER.debug("Not ignoring status %s", status) newstatus = STATES.ge...
[ "def", "parsestatus", "(", "self", ",", "status", ")", ":", "_LOGGER", ".", "debug", "(", "\"Parsing status %s\"", ",", "status", ")", "# Ignore the statuscode if it is IGNORE", "if", "status", ".", "lower", "(", ")", ".", "strip", "(", ")", "!=", "REPORT_SERV...
[ 118, 4 ]
[ 128, 44 ]
python
en
['en', 'la', 'en']
True
EgardiaAlarm.update
(self)
Update the alarm status.
Update the alarm status.
def update(self): """Update the alarm status.""" status = self._egardiasystem.getstate() self.parsestatus(status)
[ "def", "update", "(", "self", ")", ":", "status", "=", "self", ".", "_egardiasystem", ".", "getstate", "(", ")", "self", ".", "parsestatus", "(", "status", ")" ]
[ 130, 4 ]
[ 133, 32 ]
python
en
['en', 'la', 'en']
True
EgardiaAlarm.alarm_disarm
(self, code=None)
Send disarm command.
Send disarm command.
def alarm_disarm(self, code=None): """Send disarm command.""" try: self._egardiasystem.alarm_disarm() except requests.exceptions.RequestException as err: _LOGGER.error( "Egardia device exception occurred when sending disarm command: %s", er...
[ "def", "alarm_disarm", "(", "self", ",", "code", "=", "None", ")", ":", "try", ":", "self", ".", "_egardiasystem", ".", "alarm_disarm", "(", ")", "except", "requests", ".", "exceptions", ".", "RequestException", "as", "err", ":", "_LOGGER", ".", "error", ...
[ 135, 4 ]
[ 143, 13 ]
python
en
['en', 'pt', 'en']
True
EgardiaAlarm.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.""" try: self._egardiasystem.alarm_arm_home() except requests.exceptions.RequestException as err: _LOGGER.error( "Egardia device exception occurred when " "sending arm home comma...
[ "def", "alarm_arm_home", "(", "self", ",", "code", "=", "None", ")", ":", "try", ":", "self", ".", "_egardiasystem", ".", "alarm_arm_home", "(", ")", "except", "requests", ".", "exceptions", ".", "RequestException", "as", "err", ":", "_LOGGER", ".", "error...
[ 145, 4 ]
[ 154, 13 ]
python
en
['en', 'pt', 'en']
True
EgardiaAlarm.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.""" try: self._egardiasystem.alarm_arm_away() except requests.exceptions.RequestException as err: _LOGGER.error( "Egardia device exception occurred when " "sending arm away comma...
[ "def", "alarm_arm_away", "(", "self", ",", "code", "=", "None", ")", ":", "try", ":", "self", ".", "_egardiasystem", ".", "alarm_arm_away", "(", ")", "except", "requests", ".", "exceptions", ".", "RequestException", "as", "err", ":", "_LOGGER", ".", "error...
[ 156, 4 ]
[ 165, 13 ]
python
en
['en', 'en', 'en']
True
test_validating_mfa
(hass)
Test validating mfa code.
Test validating mfa code.
async def test_validating_mfa(hass): """Test validating mfa code.""" totp_auth_module = await auth_mfa_module_from_config(hass, {"type": "totp"}) await totp_auth_module.async_setup_user("test-user", {}) with patch("pyotp.TOTP.verify", return_value=True): assert await totp_auth_module.async_vali...
[ "async", "def", "test_validating_mfa", "(", "hass", ")", ":", "totp_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", "{", "\"type\"", ":", "\"totp\"", "}", ")", "await", "totp_auth_module", ".", "async_setup_user", "(", "\"test-user\"", ...
[ 13, 0 ]
[ 19, 86 ]
python
en
['en', 'sn', 'en']
True
test_validating_mfa_invalid_code
(hass)
Test validating an invalid mfa code.
Test validating an invalid mfa code.
async def test_validating_mfa_invalid_code(hass): """Test validating an invalid mfa code.""" totp_auth_module = await auth_mfa_module_from_config(hass, {"type": "totp"}) await totp_auth_module.async_setup_user("test-user", {}) with patch("pyotp.TOTP.verify", return_value=False): assert ( ...
[ "async", "def", "test_validating_mfa_invalid_code", "(", "hass", ")", ":", "totp_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", "{", "\"type\"", ":", "\"totp\"", "}", ")", "await", "totp_auth_module", ".", "async_setup_user", "(", "\"te...
[ 22, 0 ]
[ 31, 9 ]
python
en
['en', 'en', 'nl']
True
test_validating_mfa_invalid_user
(hass)
Test validating an mfa code with invalid user.
Test validating an mfa code with invalid user.
async def test_validating_mfa_invalid_user(hass): """Test validating an mfa code with invalid user.""" totp_auth_module = await auth_mfa_module_from_config(hass, {"type": "totp"}) await totp_auth_module.async_setup_user("test-user", {}) assert ( await totp_auth_module.async_validate("invalid-us...
[ "async", "def", "test_validating_mfa_invalid_user", "(", "hass", ")", ":", "totp_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", "{", "\"type\"", ":", "\"totp\"", "}", ")", "await", "totp_auth_module", ".", "async_setup_user", "(", "\"te...
[ 34, 0 ]
[ 42, 5 ]
python
en
['en', 'en', 'en']
True
test_setup_depose_user
(hass)
Test despose user.
Test despose user.
async def test_setup_depose_user(hass): """Test despose user.""" totp_auth_module = await auth_mfa_module_from_config(hass, {"type": "totp"}) result = await totp_auth_module.async_setup_user("test-user", {}) assert len(totp_auth_module._users) == 1 result2 = await totp_auth_module.async_setup_user("...
[ "async", "def", "test_setup_depose_user", "(", "hass", ")", ":", "totp_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", "{", "\"type\"", ":", "\"totp\"", "}", ")", "result", "=", "await", "totp_auth_module", ".", "async_setup_user", "("...
[ 45, 0 ]
[ 61, 44 ]
python
ca
['ca', 'la', 'fr']
False
test_login_flow_validates_mfa
(hass)
Test login flow with mfa enabled.
Test login flow with mfa enabled.
async def test_login_flow_validates_mfa(hass): """Test login flow with mfa enabled.""" hass.auth = await auth_manager_from_config( hass, [ { "type": "insecure_example", "users": [{"username": "test-user", "password": "test-pass"}], } ...
[ "async", "def", "test_login_flow_validates_mfa", "(", "hass", ")", ":", "hass", ".", "auth", "=", "await", "auth_manager_from_config", "(", "hass", ",", "[", "{", "\"type\"", ":", "\"insecure_example\"", ",", "\"users\"", ":", "[", "{", "\"username\"", ":", "\...
[ 64, 0 ]
[ 129, 47 ]
python
en
['en', 'en', 'en']
True
test_race_condition_in_data_loading
(hass)
Test race condition in the data loading.
Test race condition in the data loading.
async def test_race_condition_in_data_loading(hass): """Test race condition in the data loading.""" counter = 0 async def mock_load(_): """Mock of homeassistant.helpers.storage.Store.async_load.""" nonlocal counter counter += 1 await asyncio.sleep(0) totp_auth_module = ...
[ "async", "def", "test_race_condition_in_data_loading", "(", "hass", ")", ":", "counter", "=", "0", "async", "def", "mock_load", "(", "_", ")", ":", "\"\"\"Mock of homeassistant.helpers.storage.Store.async_load.\"\"\"", "nonlocal", "counter", "counter", "+=", "1", "await...
[ 132, 0 ]
[ 149, 34 ]
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, COVER_DOMAIN) entity_registry = await hass.helpers.entity_registry.async_get_registry() entry = entity_registry.async_get(DEVICE_ID) assert entry.unique_id == "61cbz3...
[ "async", "def", "test_entity_registry", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "COVER_DOMAIN", ")", "entity_registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "entry", "=", ...
[ 18, 0 ]
[ 24, 64 ]
python
en
['en', 'en', 'en']
True
test_attributes
(hass)
Test the cover attributes are correct.
Test the cover attributes are correct.
async def test_attributes(hass): """Test the cover attributes are correct.""" await setup_platform(hass, COVER_DOMAIN) state = hass.states.get(DEVICE_ID) assert state.state == STATE_CLOSED assert state.attributes.get(ATTR_DEVICE_ID) == "ZW:00000007" assert not state.attributes.get("battery_low"...
[ "async", "def", "test_attributes", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "COVER_DOMAIN", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "DEVICE_ID", ")", "assert", "state", ".", "state", "==", "STATE_CLOSED", "asse...
[ 27, 0 ]
[ 37, 68 ]
python
en
['en', 'en', 'en']
True
test_open
(hass)
Test the cover can be opened.
Test the cover can be opened.
async def test_open(hass): """Test the cover can be opened.""" await setup_platform(hass, COVER_DOMAIN) with patch("abodepy.AbodeCover.open_cover") as mock_open: await hass.services.async_call( COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: DEVICE_ID}, blocking=True ) ...
[ "async", "def", "test_open", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "COVER_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeCover.open_cover\"", ")", "as", "mock_open", ":", "await", "hass", ".", "services", ".", "async_call", "...
[ 40, 0 ]
[ 49, 38 ]
python
en
['en', 'en', 'en']
True
test_close
(hass)
Test the cover can be closed.
Test the cover can be closed.
async def test_close(hass): """Test the cover can be closed.""" await setup_platform(hass, COVER_DOMAIN) with patch("abodepy.AbodeCover.close_cover") as mock_close: await hass.services.async_call( COVER_DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: DEVICE_ID}, ...
[ "async", "def", "test_close", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "COVER_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeCover.close_cover\"", ")", "as", "mock_close", ":", "await", "hass", ".", "services", ".", "async_call", ...
[ 52, 0 ]
[ 64, 39 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Fritzbox smarthome switch from config_entry.
Set up the Fritzbox smarthome switch from config_entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Fritzbox smarthome switch from config_entry.""" entities = [] devices = hass.data[FRITZBOX_DOMAIN][CONF_DEVICES] fritz = hass.data[FRITZBOX_DOMAIN][CONF_CONNECTIONS][config_entry.entry_id] for device in await hass.as...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "]", "devices", "=", "hass", ".", "data", "[", "FRITZBOX_DOMAIN", "]", "[", "CONF_DEVICES", "]", "fritz", "=", "hass", ".", "d...
[ 25, 0 ]
[ 36, 32 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.__init__
(self, device, fritz)
Initialize the switch.
Initialize the switch.
def __init__(self, device, fritz): """Initialize the switch.""" self._device = device self._fritz = fritz
[ "def", "__init__", "(", "self", ",", "device", ",", "fritz", ")", ":", "self", ".", "_device", "=", "device", "self", ".", "_fritz", "=", "fritz" ]
[ 42, 4 ]
[ 45, 27 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.device_info
(self)
Return device specific attributes.
Return device specific attributes.
def device_info(self): """Return device specific attributes.""" return { "name": self.name, "identifiers": {(FRITZBOX_DOMAIN, self._device.ain)}, "manufacturer": self._device.manufacturer, "model": self._device.productname, "sw_version": self._...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"name\"", ":", "self", ".", "name", ",", "\"identifiers\"", ":", "{", "(", "FRITZBOX_DOMAIN", ",", "self", ".", "_device", ".", "ain", ")", "}", ",", "\"manufacturer\"", ":", "self", ".", "_...
[ 48, 4 ]
[ 56, 9 ]
python
en
['fr', 'it', 'en']
False
FritzboxSwitch.unique_id
(self)
Return the unique ID of the device.
Return the unique ID of the device.
def unique_id(self): """Return the unique ID of the device.""" return self._device.ain
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "ain" ]
[ 59, 4 ]
[ 61, 31 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.available
(self)
Return if switch is available.
Return if switch is available.
def available(self): """Return if switch is available.""" return self._device.present
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "present" ]
[ 64, 4 ]
[ 66, 35 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._device.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "name" ]
[ 69, 4 ]
[ 71, 32 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.is_on
(self)
Return true if the switch is on.
Return true if the switch is on.
def is_on(self): """Return true if the switch is on.""" return self._device.switch_state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "switch_state" ]
[ 74, 4 ]
[ 76, 40 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.turn_on
(self, **kwargs)
Turn the switch on.
Turn the switch on.
def turn_on(self, **kwargs): """Turn the switch on.""" self._device.set_switch_state_on()
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_device", ".", "set_switch_state_on", "(", ")" ]
[ 78, 4 ]
[ 80, 42 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.turn_off
(self, **kwargs)
Turn the switch off.
Turn the switch off.
def turn_off(self, **kwargs): """Turn the switch off.""" self._device.set_switch_state_off()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_device", ".", "set_switch_state_off", "(", ")" ]
[ 82, 4 ]
[ 84, 43 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.update
(self)
Get latest data and states from the device.
Get latest data and states from the device.
def update(self): """Get latest data and states from the device.""" try: self._device.update() except requests.exceptions.HTTPError as ex: LOGGER.warning("Fritzhome connection error: %s", ex) self._fritz.login()
[ "def", "update", "(", "self", ")", ":", "try", ":", "self", ".", "_device", ".", "update", "(", ")", "except", "requests", ".", "exceptions", ".", "HTTPError", "as", "ex", ":", "LOGGER", ".", "warning", "(", "\"Fritzhome connection error: %s\"", ",", "ex",...
[ 86, 4 ]
[ 92, 31 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.device_state_attributes
(self)
Return the state attributes of the device.
Return the state attributes of the device.
def device_state_attributes(self): """Return the state attributes of the device.""" attrs = {} attrs[ATTR_STATE_DEVICE_LOCKED] = self._device.device_lock attrs[ATTR_STATE_LOCKED] = self._device.lock if self._device.has_powermeter: attrs[ ATTR_TOTAL_CO...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attrs", "=", "{", "}", "attrs", "[", "ATTR_STATE_DEVICE_LOCKED", "]", "=", "self", ".", "_device", ".", "device_lock", "attrs", "[", "ATTR_STATE_LOCKED", "]", "=", "self", ".", "_device", ".", "lock",...
[ 95, 4 ]
[ 113, 20 ]
python
en
['en', 'en', 'en']
True
FritzboxSwitch.current_power_w
(self)
Return the current power usage in W.
Return the current power usage in W.
def current_power_w(self): """Return the current power usage in W.""" return self._device.power / 1000
[ "def", "current_power_w", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "power", "/", "1000" ]
[ 116, 4 ]
[ 118, 40 ]
python
en
['en', 'en', 'en']
True
PFLDInference.__init__
(self, lookup_table, sampled_ops, num_points=106)
Parameters ---------- lookup_table : class to manage the candidate ops, layer information and layer perf sampled_ops : list of str the searched layer names of the subnet num_points : int the number of landmarks for prediction
Parameters ---------- lookup_table : class to manage the candidate ops, layer information and layer perf sampled_ops : list of str the searched layer names of the subnet num_points : int the number of landmarks for prediction
def __init__(self, lookup_table, sampled_ops, num_points=106): """ Parameters ---------- lookup_table : class to manage the candidate ops, layer information and layer perf sampled_ops : list of str the searched layer names of the subnet num_points ...
[ "def", "__init__", "(", "self", ",", "lookup_table", ",", "sampled_ops", ",", "num_points", "=", "106", ")", ":", "super", "(", "PFLDInference", ",", "self", ")", ".", "__init__", "(", ")", "stage_names", "=", "[", "stage_name", "for", "stage_name", "in", ...
[ 23, 4 ]
[ 75, 26 ]
python
en
['en', 'error', 'th']
False
PFLDInference.forward
(self, x)
Parameters ---------- x : tensor input image Returns ------- output: tensor the predicted landmarks output: tensor the intermediate features
Parameters ---------- x : tensor input image
def forward(self, x): """ Parameters ---------- x : tensor input image Returns ------- output: tensor the predicted landmarks output: tensor the intermediate features """ x, y1 = self.stem(x) out...
[ "def", "forward", "(", "self", ",", "x", ")", ":", "x", ",", "y1", "=", "self", ".", "stem", "(", "x", ")", "out1", "=", "x", "x", "=", "self", ".", "block4_1", "(", "x", ")", "for", "i", ",", "block", "in", "enumerate", "(", "self", ".", "...
[ 91, 4 ]
[ 126, 30 ]
python
en
['en', 'error', 'th']
False
AuxiliaryNet.forward
(self, x)
Parameters ---------- x : tensor input intermediate features Returns ------- output: tensor the predicted pose angles
Parameters ---------- x : tensor input intermediate features
def forward(self, x): """ Parameters ---------- x : tensor input intermediate features Returns ------- output: tensor the predicted pose angles """ x = self.conv1(x) x = self.conv2(x) x = self.conv3(x) ...
[ "def", "forward", "(", "self", ",", "x", ")", ":", "x", "=", "self", ".", "conv1", "(", "x", ")", "x", "=", "self", ".", "conv2", "(", "x", ")", "x", "=", "self", ".", "conv3", "(", "x", ")", "x", "=", "self", ".", "conv4", "(", "x", ")",...
[ 142, 4 ]
[ 163, 16 ]
python
en
['en', 'error', 'th']
False
setup
(hass, config)
Set up the ADS component.
Set up the ADS component.
def setup(hass, config): """Set up the ADS component.""" conf = config[DOMAIN] net_id = conf[CONF_DEVICE] ip_address = conf.get(CONF_IP_ADDRESS) port = conf[CONF_PORT] client = pyads.Connection(net_id, port, ip_address) AdsHub.ADS_TYPEMAP = { ADSTYPE_BOOL: pyads.PLCTYPE_BOOL, ...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "net_id", "=", "conf", "[", "CONF_DEVICE", "]", "ip_address", "=", "conf", ".", "get", "(", "CONF_IP_ADDRESS", ")", "port", "=", "conf", "[", "CONF_PORT", ...
[ 79, 0 ]
[ 139, 15 ]
python
en
['en', 'en', 'en']
True
AdsHub.__init__
(self, ads_client)
Initialize the ADS hub.
Initialize the ADS hub.
def __init__(self, ads_client): """Initialize the ADS hub.""" self._client = ads_client self._client.open() # All ADS devices are registered here self._devices = [] self._notification_items = {} self._lock = threading.Lock()
[ "def", "__init__", "(", "self", ",", "ads_client", ")", ":", "self", ".", "_client", "=", "ads_client", "self", ".", "_client", ".", "open", "(", ")", "# All ADS devices are registered here", "self", ".", "_devices", "=", "[", "]", "self", ".", "_notificatio...
[ 151, 4 ]
[ 159, 37 ]
python
en
['en', 'en', 'en']
True
AdsHub.shutdown
(self, *args, **kwargs)
Shutdown ADS connection.
Shutdown ADS connection.
def shutdown(self, *args, **kwargs): """Shutdown ADS connection.""" _LOGGER.debug("Shutting down ADS") for notification_item in self._notification_items.values(): _LOGGER.debug( "Deleting device notification %d, %d", notification_item.hnotify, ...
[ "def", "shutdown", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Shutting down ADS\"", ")", "for", "notification_item", "in", "self", ".", "_notification_items", ".", "values", "(", ")", ":", "_LOGGER", ...
[ 161, 4 ]
[ 180, 30 ]
python
en
['en', 'de', 'en']
True
AdsHub.register_device
(self, device)
Register a new device.
Register a new device.
def register_device(self, device): """Register a new device.""" self._devices.append(device)
[ "def", "register_device", "(", "self", ",", "device", ")", ":", "self", ".", "_devices", ".", "append", "(", "device", ")" ]
[ 182, 4 ]
[ 184, 36 ]
python
en
['en', 'en', 'en']
True
AdsHub.write_by_name
(self, name, value, plc_datatype)
Write a value to the device.
Write a value to the device.
def write_by_name(self, name, value, plc_datatype): """Write a value to the device.""" with self._lock: try: return self._client.write_by_name(name, value, plc_datatype) except pyads.ADSError as err: _LOGGER.error("Error writing %s: %s", name, err...
[ "def", "write_by_name", "(", "self", ",", "name", ",", "value", ",", "plc_datatype", ")", ":", "with", "self", ".", "_lock", ":", "try", ":", "return", "self", ".", "_client", ".", "write_by_name", "(", "name", ",", "value", ",", "plc_datatype", ")", "...
[ 186, 4 ]
[ 193, 64 ]
python
en
['en', 'en', 'en']
True
AdsHub.read_by_name
(self, name, plc_datatype)
Read a value from the device.
Read a value from the device.
def read_by_name(self, name, plc_datatype): """Read a value from the device.""" with self._lock: try: return self._client.read_by_name(name, plc_datatype) except pyads.ADSError as err: _LOGGER.error("Error reading %s: %s", name, err)
[ "def", "read_by_name", "(", "self", ",", "name", ",", "plc_datatype", ")", ":", "with", "self", ".", "_lock", ":", "try", ":", "return", "self", ".", "_client", ".", "read_by_name", "(", "name", ",", "plc_datatype", ")", "except", "pyads", ".", "ADSError...
[ 195, 4 ]
[ 202, 64 ]
python
en
['en', 'en', 'en']
True
AdsHub.add_device_notification
(self, name, plc_datatype, callback)
Add a notification to the ADS devices.
Add a notification to the ADS devices.
def add_device_notification(self, name, plc_datatype, callback): """Add a notification to the ADS devices.""" attr = pyads.NotificationAttrib(ctypes.sizeof(plc_datatype)) with self._lock: try: hnotify, huser = self._client.add_device_notification( ...
[ "def", "add_device_notification", "(", "self", ",", "name", ",", "plc_datatype", ",", "callback", ")", ":", "attr", "=", "pyads", ".", "NotificationAttrib", "(", "ctypes", ".", "sizeof", "(", "plc_datatype", ")", ")", "with", "self", ".", "_lock", ":", "tr...
[ 204, 4 ]
[ 224, 17 ]
python
en
['en', 'en', 'en']
True
AdsHub._device_notification_callback
(self, notification, name)
Handle device notifications.
Handle device notifications.
def _device_notification_callback(self, notification, name): """Handle device notifications.""" contents = notification.contents hnotify = int(contents.hNotification) _LOGGER.debug("Received notification %d", hnotify) # get dynamically sized data array data_size = conte...
[ "def", "_device_notification_callback", "(", "self", ",", "notification", ",", "name", ")", ":", "contents", "=", "notification", ".", "contents", "hnotify", "=", "int", "(", "contents", ".", "hNotification", ")", "_LOGGER", ".", "debug", "(", "\"Received notifi...
[ 226, 4 ]
[ 264, 65 ]
python
en
['fr', 'en', 'en']
True
AdsEntity.__init__
(self, ads_hub, name, ads_var)
Initialize ADS binary sensor.
Initialize ADS binary sensor.
def __init__(self, ads_hub, name, ads_var): """Initialize ADS binary sensor.""" self._name = name self._unique_id = ads_var self._state_dict = {} self._state_dict[STATE_KEY_STATE] = None self._ads_hub = ads_hub self._ads_var = ads_var self._event = None
[ "def", "__init__", "(", "self", ",", "ads_hub", ",", "name", ",", "ads_var", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_unique_id", "=", "ads_var", "self", ".", "_state_dict", "=", "{", "}", "self", ".", "_state_dict", "[", "STATE_KEY_...
[ 270, 4 ]
[ 278, 26 ]
python
en
['en', 'pl', 'en']
True
AdsEntity.async_initialize_device
( self, ads_var, plctype, state_key=STATE_KEY_STATE, factor=None )
Register device notification.
Register device notification.
async def async_initialize_device( self, ads_var, plctype, state_key=STATE_KEY_STATE, factor=None ): """Register device notification.""" def update(name, value): """Handle device notifications.""" _LOGGER.debug("Variable %s changed its value to %d", name, value) ...
[ "async", "def", "async_initialize_device", "(", "self", ",", "ads_var", ",", "plctype", ",", "state_key", "=", "STATE_KEY_STATE", ",", "factor", "=", "None", ")", ":", "def", "update", "(", "name", ",", "value", ")", ":", "\"\"\"Handle device notifications.\"\"\...
[ 280, 4 ]
[ 310, 78 ]
python
en
['da', 'en', 'en']
True
AdsEntity.name
(self)
Return the default name of the binary sensor.
Return the default name of the binary sensor.
def name(self): """Return the default name of the binary sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 313, 4 ]
[ 315, 25 ]
python
en
['en', 'ceb', 'en']
True
AdsEntity.unique_id
(self)
Return an unique identifier for this entity.
Return an unique identifier for this entity.
def unique_id(self): """Return an unique identifier for this entity.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 318, 4 ]
[ 320, 30 ]
python
en
['en', 'en', 'en']
True
AdsEntity.should_poll
(self)
Return False because entity pushes its state to HA.
Return False because entity pushes its state to HA.
def should_poll(self): """Return False because entity pushes its state to HA.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 323, 4 ]
[ 325, 20 ]
python
en
['en', 'en', 'en']
True
AdsEntity.available
(self)
Return False if state has not been updated yet.
Return False if state has not been updated yet.
def available(self): """Return False if state has not been updated yet.""" return self._state_dict[STATE_KEY_STATE] is not None
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_state_dict", "[", "STATE_KEY_STATE", "]", "is", "not", "None" ]
[ 328, 4 ]
[ 330, 60 ]
python
en
['en', 'en', 'en']
True
list_available
()
Show available env configurations in package Args: None Returns: None
Show available env configurations in package
def list_available(): """ Show available env configurations in package Args: None Returns: None """ envs = get_available_envs() for env in envs: print(f'scenario: {env["scenario"]}, topology: {env["topology"]}')
[ "def", "list_available", "(", ")", ":", "envs", "=", "get_available_envs", "(", ")", "for", "env", "in", "envs", ":", "print", "(", "f'scenario: {env[\"scenario\"]}, topology: {env[\"topology\"]}'", ")" ]
[ 8, 0 ]
[ 21, 74 ]
python
en
['en', 'error', 'th']
False
list_scenarios
(**kwargs)
Show all avaiable scenarios
Show all avaiable scenarios
def list_scenarios(**kwargs): """ Show all avaiable scenarios """ for scenario in get_scenarios(): print(scenario)
[ "def", "list_scenarios", "(", "*", "*", "kwargs", ")", ":", "for", "scenario", "in", "get_scenarios", "(", ")", ":", "print", "(", "scenario", ")" ]
[ 25, 0 ]
[ 31, 23 ]
python
en
['en', 'error', 'th']
False
list_topologies
(scenario: str, **kwargs)
Show topologies for specified scenario
Show topologies for specified scenario
def list_topologies(scenario: str, **kwargs): """ Show topologies for specified scenario """ for topology in get_topologies(scenario): print(topology)
[ "def", "list_topologies", "(", "scenario", ":", "str", ",", "*", "*", "kwargs", ")", ":", "for", "topology", "in", "get_topologies", "(", "scenario", ")", ":", "print", "(", "topology", ")" ]
[ 35, 0 ]
[ 41, 23 ]
python
en
['en', 'error', 'th']
False
test_loading_file
(hass, hass_client)
Test that it loads image from disk.
Test that it loads image from disk.
async def test_loading_file(hass, hass_client): """Test that it loads image from disk.""" mock_registry(hass) with mock.patch("os.path.isfile", mock.Mock(return_value=True)), mock.patch( "os.access", mock.Mock(return_value=True) ): await async_setup_component( hass, ...
[ "async", "def", "test_loading_file", "(", "hass", ",", "hass_client", ")", ":", "mock_registry", "(", "hass", ")", "with", "mock", ".", "patch", "(", "\"os.path.isfile\"", ",", "mock", ".", "Mock", "(", "return_value", "=", "True", ")", ")", ",", "mock", ...
[ 9, 0 ]
[ 39, 26 ]
python
en
['en', 'en', 'en']
True
test_file_not_readable
(hass, caplog)
Test a warning is shown setup when file is not readable.
Test a warning is shown setup when file is not readable.
async def test_file_not_readable(hass, caplog): """Test a warning is shown setup when file is not readable.""" mock_registry(hass) with mock.patch("os.path.isfile", mock.Mock(return_value=True)), mock.patch( "os.access", mock.Mock(return_value=False) ): await async_setup_component( ...
[ "async", "def", "test_file_not_readable", "(", "hass", ",", "caplog", ")", ":", "mock_registry", "(", "hass", ")", "with", "mock", ".", "patch", "(", "\"os.path.isfile\"", ",", "mock", ".", "Mock", "(", "return_value", "=", "True", ")", ")", ",", "mock", ...
[ 42, 0 ]
[ 64, 37 ]
python
en
['en', 'en', 'en']
True
test_camera_content_type
(hass, hass_client)
Test local_file camera content_type.
Test local_file camera content_type.
async def test_camera_content_type(hass, hass_client): """Test local_file camera content_type.""" cam_config_jpg = { "name": "test_jpg", "platform": "local_file", "file_path": "/path/to/image.jpg", } cam_config_png = { "name": "test_png", "platform": "local_file",...
[ "async", "def", "test_camera_content_type", "(", "hass", ",", "hass_client", ")", ":", "cam_config_jpg", "=", "{", "\"name\"", ":", "\"test_jpg\"", ",", "\"platform\"", ":", "\"local_file\"", ",", "\"file_path\"", ":", "\"/path/to/image.jpg\"", ",", "}", "cam_config...
[ 67, 0 ]
[ 128, 24 ]
python
en
['es', 'en', 'en']
True
test_update_file_path
(hass)
Test update_file_path service.
Test update_file_path service.
async def test_update_file_path(hass): """Test update_file_path service.""" # Setup platform mock_registry(hass) with mock.patch("os.path.isfile", mock.Mock(return_value=True)), mock.patch( "os.access", mock.Mock(return_value=True) ): camera_1 = {"platform": "local_file", "file_pa...
[ "async", "def", "test_update_file_path", "(", "hass", ")", ":", "# Setup platform", "mock_registry", "(", "hass", ")", "with", "mock", ".", "patch", "(", "\"os.path.isfile\"", ",", "mock", ".", "Mock", "(", "return_value", "=", "True", ")", ")", ",", "mock",...
[ 131, 0 ]
[ 165, 69 ]
python
en
['en', 'co', 'en']
True
async_is_logged_in
(hass)
Test if user is logged in.
Test if user is logged in.
def async_is_logged_in(hass) -> bool: """Test if user is logged in.""" return DOMAIN in hass.data and hass.data[DOMAIN].is_logged_in
[ "def", "async_is_logged_in", "(", "hass", ")", "->", "bool", ":", "return", "DOMAIN", "in", "hass", ".", "data", "and", "hass", ".", "data", "[", "DOMAIN", "]", ".", "is_logged_in" ]
[ 112, 0 ]
[ 114, 65 ]
python
en
['en', 'en', 'en']
True
async_active_subscription
(hass)
Test if user has an active subscription.
Test if user has an active subscription.
def async_active_subscription(hass) -> bool: """Test if user has an active subscription.""" return async_is_logged_in(hass) and not hass.data[DOMAIN].subscription_expired
[ "def", "async_active_subscription", "(", "hass", ")", "->", "bool", ":", "return", "async_is_logged_in", "(", "hass", ")", "and", "not", "hass", ".", "data", "[", "DOMAIN", "]", ".", "subscription_expired" ]
[ 119, 0 ]
[ 121, 82 ]
python
en
['en', 'en', 'en']
True
async_create_cloudhook
(hass, webhook_id: str)
Create a cloudhook.
Create a cloudhook.
async def async_create_cloudhook(hass, webhook_id: str) -> str: """Create a cloudhook.""" if not async_is_logged_in(hass): raise CloudNotAvailable hook = await hass.data[DOMAIN].cloudhooks.async_create(webhook_id, True) return hook["cloudhook_url"]
[ "async", "def", "async_create_cloudhook", "(", "hass", ",", "webhook_id", ":", "str", ")", "->", "str", ":", "if", "not", "async_is_logged_in", "(", "hass", ")", ":", "raise", "CloudNotAvailable", "hook", "=", "await", "hass", ".", "data", "[", "DOMAIN", "...
[ 125, 0 ]
[ 131, 32 ]
python
en
['en', 'en', 'en']
True
async_delete_cloudhook
(hass, webhook_id: str)
Delete a cloudhook.
Delete a cloudhook.
async def async_delete_cloudhook(hass, webhook_id: str) -> None: """Delete a cloudhook.""" if DOMAIN not in hass.data: raise CloudNotAvailable await hass.data[DOMAIN].cloudhooks.async_delete(webhook_id)
[ "async", "def", "async_delete_cloudhook", "(", "hass", ",", "webhook_id", ":", "str", ")", "->", "None", ":", "if", "DOMAIN", "not", "in", "hass", ".", "data", ":", "raise", "CloudNotAvailable", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "clo...
[ 135, 0 ]
[ 140, 63 ]
python
en
['en', 'fy', 'en']
True
async_remote_ui_url
(hass)
Get the remote UI URL.
Get the remote UI URL.
def async_remote_ui_url(hass) -> str: """Get the remote UI URL.""" if not async_is_logged_in(hass): raise CloudNotAvailable if not hass.data[DOMAIN].client.prefs.remote_enabled: raise CloudNotAvailable if not hass.data[DOMAIN].remote.instance_domain: raise CloudNotAvailable ...
[ "def", "async_remote_ui_url", "(", "hass", ")", "->", "str", ":", "if", "not", "async_is_logged_in", "(", "hass", ")", ":", "raise", "CloudNotAvailable", "if", "not", "hass", ".", "data", "[", "DOMAIN", "]", ".", "client", ".", "prefs", ".", "remote_enable...
[ 145, 0 ]
[ 156, 64 ]
python
en
['en', 'de', 'en']
True
is_cloudhook_request
(request)
Test if a request came from a cloudhook. Async friendly.
Test if a request came from a cloudhook.
def is_cloudhook_request(request): """Test if a request came from a cloudhook. Async friendly. """ return isinstance(request, MockRequest)
[ "def", "is_cloudhook_request", "(", "request", ")", ":", "return", "isinstance", "(", "request", ",", "MockRequest", ")" ]
[ 159, 0 ]
[ 164, 43 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Initialize the Home Assistant cloud.
Initialize the Home Assistant cloud.
async def async_setup(hass, config): """Initialize the Home Assistant cloud.""" # Process configs if DOMAIN in config: kwargs = dict(config[DOMAIN]) else: kwargs = {CONF_MODE: DEFAULT_MODE} # Alexa/Google custom config alexa_conf = kwargs.pop(CONF_ALEXA, None) or ALEXA_SCHEMA({}...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "# Process configs", "if", "DOMAIN", "in", "config", ":", "kwargs", "=", "dict", "(", "config", "[", "DOMAIN", "]", ")", "else", ":", "kwargs", "=", "{", "CONF_MODE", ":", "DEFAULT_MODE...
[ 167, 0 ]
[ 234, 15 ]
python
en
['en', 'en', 'en']
True
utc_timestamp_to_timezone
(timestamp: int, timezone)
Convert utc timestamp into specified tiemzone datetime. Args: timestamp(int): UTC timestamp to convert. timezone: Target timezone.
Convert utc timestamp into specified tiemzone datetime.
def utc_timestamp_to_timezone(timestamp: int, timezone): """Convert utc timestamp into specified tiemzone datetime. Args: timestamp(int): UTC timestamp to convert. timezone: Target timezone. """ if sys.platform == "win32": # windows do not support negative timestamp, use this to...
[ "def", "utc_timestamp_to_timezone", "(", "timestamp", ":", "int", ",", "timezone", ")", ":", "if", "sys", ".", "platform", "==", "\"win32\"", ":", "# windows do not support negative timestamp, use this to support it", "return", "(", "timestamp_start", "+", "relativedelta"...
[ 13, 0 ]
[ 24, 92 ]
python
en
['en', 'de', 'en']
True
test_config_google_home_entity_id_to_number
()
Test config adheres to the type.
Test config adheres to the type.
def test_config_google_home_entity_id_to_number(): """Test config adheres to the type.""" mock_hass = Mock() mock_hass.config.path = MagicMock("path", return_value="test_path") conf = Config(mock_hass, {"type": "google_home"}) with patch( "homeassistant.components.emulated_hue.load_json", ...
[ "def", "test_config_google_home_entity_id_to_number", "(", ")", ":", "mock_hass", "=", "Mock", "(", ")", "mock_hass", ".", "config", ".", "path", "=", "MagicMock", "(", "\"path\"", ",", "return_value", "=", "\"test_path\"", ")", "conf", "=", "Config", "(", "mo...
[ 6, 0 ]
[ 37, 45 ]
python
en
['en', 'en', 'en']
True
test_config_google_home_entity_id_to_number_altered
()
Test config adheres to the type.
Test config adheres to the type.
def test_config_google_home_entity_id_to_number_altered(): """Test config adheres to the type.""" mock_hass = Mock() mock_hass.config.path = MagicMock("path", return_value="test_path") conf = Config(mock_hass, {"type": "google_home"}) with patch( "homeassistant.components.emulated_hue.load_...
[ "def", "test_config_google_home_entity_id_to_number_altered", "(", ")", ":", "mock_hass", "=", "Mock", "(", ")", "mock_hass", ".", "config", ".", "path", "=", "MagicMock", "(", "\"path\"", ",", "return_value", "=", "\"test_path\"", ")", "conf", "=", "Config", "(...
[ 40, 0 ]
[ 70, 45 ]
python
en
['en', 'en', 'en']
True
test_config_google_home_entity_id_to_number_empty
()
Test config adheres to the type.
Test config adheres to the type.
def test_config_google_home_entity_id_to_number_empty(): """Test config adheres to the type.""" mock_hass = Mock() mock_hass.config.path = MagicMock("path", return_value="test_path") conf = Config(mock_hass, {"type": "google_home"}) with patch( "homeassistant.components.emulated_hue.load_js...
[ "def", "test_config_google_home_entity_id_to_number_empty", "(", ")", ":", "mock_hass", "=", "Mock", "(", ")", "mock_hass", ".", "config", ".", "path", "=", "MagicMock", "(", "\"path\"", ",", "return_value", "=", "\"test_path\"", ")", "conf", "=", "Config", "(",...
[ 73, 0 ]
[ 99, 45 ]
python
en
['en', 'en', 'en']
True
test_config_alexa_entity_id_to_number
()
Test config adheres to the type.
Test config adheres to the type.
def test_config_alexa_entity_id_to_number(): """Test config adheres to the type.""" conf = Config(None, {"type": "alexa"}) number = conf.entity_id_to_number("light.test") assert number == "light.test" number = conf.entity_id_to_number("light.test") assert number == "light.test" number = c...
[ "def", "test_config_alexa_entity_id_to_number", "(", ")", ":", "conf", "=", "Config", "(", "None", ",", "{", "\"type\"", ":", "\"alexa\"", "}", ")", "number", "=", "conf", ".", "entity_id_to_number", "(", "\"light.test\"", ")", "assert", "number", "==", "\"lig...
[ 102, 0 ]
[ 116, 36 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up a ONVIF binary sensor.
Set up a ONVIF binary sensor.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up a ONVIF binary sensor.""" device = hass.data[DOMAIN][config_entry.unique_id] entities = { event.uid: ONVIFSensor(event.uid, device) for event in device.events.get_platform("sensor") } async_add_entities(...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "device", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "unique_id", "]", "entities", "=", "{", "event", ".", "uid", ":", ...
[ 9, 0 ]
[ 32, 15 ]
python
en
['en', 'haw', 'en']
True
ONVIFSensor.__init__
(self, uid, device)
Initialize the ONVIF binary sensor.
Initialize the ONVIF binary sensor.
def __init__(self, uid, device): """Initialize the ONVIF binary sensor.""" self.uid = uid super().__init__(device)
[ "def", "__init__", "(", "self", ",", "uid", ",", "device", ")", ":", "self", ".", "uid", "=", "uid", "super", "(", ")", ".", "__init__", "(", "device", ")" ]
[ 38, 4 ]
[ 42, 32 ]
python
en
['en', 'haw', 'en']
True
ONVIFSensor.state
(self)
Return the state of the entity.
Return the state of the entity.
def state(self) -> Union[None, str, int, float]: """Return the state of the entity.""" return self.device.events.get_uid(self.uid).value
[ "def", "state", "(", "self", ")", "->", "Union", "[", "None", ",", "str", ",", "int", ",", "float", "]", ":", "return", "self", ".", "device", ".", "events", ".", "get_uid", "(", "self", ".", "uid", ")", ".", "value" ]
[ 45, 4 ]
[ 47, 57 ]
python
en
['en', 'en', 'en']
True
ONVIFSensor.name
(self)
Return the name of the event.
Return the name of the event.
def name(self): """Return the name of the event.""" return self.device.events.get_uid(self.uid).name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "device", ".", "events", ".", "get_uid", "(", "self", ".", "uid", ")", ".", "name" ]
[ 50, 4 ]
[ 52, 56 ]
python
en
['en', 'en', 'en']
True
ONVIFSensor.device_class
(self)
Return the class of this device, from component DEVICE_CLASSES.
Return the class of this device, from component DEVICE_CLASSES.
def device_class(self) -> Optional[str]: """Return the class of this device, from component DEVICE_CLASSES.""" return self.device.events.get_uid(self.uid).device_class
[ "def", "device_class", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "device", ".", "events", ".", "get_uid", "(", "self", ".", "uid", ")", ".", "device_class" ]
[ 55, 4 ]
[ 57, 64 ]
python
en
['en', 'en', 'en']
True
ONVIFSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self) -> Optional[str]: """Return the unit of measurement of this entity, if any.""" return self.device.events.get_uid(self.uid).unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "device", ".", "events", ".", "get_uid", "(", "self", ".", "uid", ")", ".", "unit_of_measurement" ]
[ 60, 4 ]
[ 62, 71 ]
python
en
['en', 'en', 'en']
True
ONVIFSensor.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return self.uid
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "uid" ]
[ 65, 4 ]
[ 67, 23 ]
python
ca
['fr', 'ca', 'en']
False
ONVIFSensor.entity_registry_enabled_default
(self)
Return if the entity should be enabled when first added to the entity registry.
Return if the entity should be enabled when first added to the entity registry.
def entity_registry_enabled_default(self) -> bool: """Return if the entity should be enabled when first added to the entity registry.""" return self.device.events.get_uid(self.uid).entity_enabled
[ "def", "entity_registry_enabled_default", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "device", ".", "events", ".", "get_uid", "(", "self", ".", "uid", ")", ".", "entity_enabled" ]
[ 70, 4 ]
[ 72, 66 ]
python
en
['en', 'en', 'en']
True
ONVIFSensor.should_poll
(self)
Return True if entity has to be polled for state. False if entity pushes its state to HA.
Return True if entity has to be polled for state.
def should_poll(self) -> bool: """Return True if entity has to be polled for state. False if entity pushes its state to HA. """ return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 75, 4 ]
[ 80, 20 ]
python
en
['en', 'en', 'en']
True
ONVIFSensor.async_added_to_hass
(self)
Connect to dispatcher listening for entity data notifications.
Connect to dispatcher listening for entity data notifications.
async def async_added_to_hass(self): """Connect to dispatcher listening for entity data notifications.""" self.async_on_remove( self.device.events.async_add_listener(self.async_write_ha_state) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "self", ".", "device", ".", "events", ".", "async_add_listener", "(", "self", ".", "async_write_ha_state", ")", ")" ]
[ 82, 4 ]
[ 86, 9 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the Danfoss Air component.
Set up the Danfoss Air component.
def setup(hass, config): """Set up the Danfoss Air component.""" conf = config[DOMAIN] hass.data[DOMAIN] = DanfossAir(conf[CONF_HOST]) for platform in DANFOSS_AIR_PLATFORMS: discovery.load_platform(hass, platform, DOMAIN, {}, config) return True
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "hass", ".", "data", "[", "DOMAIN", "]", "=", "DanfossAir", "(", "conf", "[", "CONF_HOST", "]", ")", "for", "platform", "in", "DANFOSS_AIR_PLATFORMS", ":",...
[ 25, 0 ]
[ 34, 15 ]
python
en
['en', 'lb', 'en']
True
DanfossAir.__init__
(self, host)
Initialize the Danfoss Air CCM connection.
Initialize the Danfoss Air CCM connection.
def __init__(self, host): """Initialize the Danfoss Air CCM connection.""" self._data = {} self._client = DanfossClient(host)
[ "def", "__init__", "(", "self", ",", "host", ")", ":", "self", ".", "_data", "=", "{", "}", "self", ".", "_client", "=", "DanfossClient", "(", "host", ")" ]
[ 40, 4 ]
[ 44, 42 ]
python
en
['en', 'fr', 'en']
True
DanfossAir.get_value
(self, item)
Get value for sensor.
Get value for sensor.
def get_value(self, item): """Get value for sensor.""" return self._data.get(item)
[ "def", "get_value", "(", "self", ",", "item", ")", ":", "return", "self", ".", "_data", ".", "get", "(", "item", ")" ]
[ 46, 4 ]
[ 48, 35 ]
python
en
['en', 'da', 'en']
True
DanfossAir.update_state
(self, command, state_command)
Send update command to Danfoss Air CCM.
Send update command to Danfoss Air CCM.
def update_state(self, command, state_command): """Send update command to Danfoss Air CCM.""" self._data[state_command] = self._client.command(command)
[ "def", "update_state", "(", "self", ",", "command", ",", "state_command", ")", ":", "self", ".", "_data", "[", "state_command", "]", "=", "self", ".", "_client", ".", "command", "(", "command", ")" ]
[ 50, 4 ]
[ 52, 65 ]
python
en
['en', 'lb', 'en']
True
DanfossAir.update
(self)
Use the data from Danfoss Air API.
Use the data from Danfoss Air API.
def update(self): """Use the data from Danfoss Air API.""" _LOGGER.debug("Fetching data from Danfoss Air CCM module") self._data[ReadCommand.exhaustTemperature] = self._client.command( ReadCommand.exhaustTemperature ) self._data[ReadCommand.outdoorTemperature] = self...
[ "def", "update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Fetching data from Danfoss Air CCM module\"", ")", "self", ".", "_data", "[", "ReadCommand", ".", "exhaustTemperature", "]", "=", "self", ".", "_client", ".", "command", "(", "ReadCommand",...
[ 55, 4 ]
[ 95, 71 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the triggers to control lights based on device presence.
Set up the triggers to control lights based on device presence.
async def async_setup(hass, config): """Set up the triggers to control lights based on device presence.""" conf = config[DOMAIN] disable_turn_off = conf[CONF_DISABLE_TURN_OFF] light_group = conf.get(CONF_LIGHT_GROUP) light_profile = conf[CONF_LIGHT_PROFILE] device_group = conf.get(CONF_DEVICE_GR...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "disable_turn_off", "=", "conf", "[", "CONF_DISABLE_TURN_OFF", "]", "light_group", "=", "conf", ".", "get", "(", "CONF_LIGHT_GROUP", ")", "light_p...
[ 60, 0 ]
[ 79, 15 ]
python
en
['en', 'en', 'en']
True
activate_automation
( hass, device_group, light_group, light_profile, disable_turn_off )
Activate the automation.
Activate the automation.
async def activate_automation( hass, device_group, light_group, light_profile, disable_turn_off ): """Activate the automation.""" logger = logging.getLogger(__name__) device_tracker = hass.components.device_tracker group = hass.components.group light = hass.components.light person = hass.com...
[ "async", "def", "activate_automation", "(", "hass", ",", "device_group", ",", "light_group", ",", "light_profile", ",", "disable_turn_off", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "device_tracker", "=", "hass", ".", "component...
[ 82, 0 ]
[ 268, 10 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_devices, discovery_info=None)
Set up the DNS IP sensor.
Set up the DNS IP sensor.
async def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the DNS IP sensor.""" hostname = config[CONF_HOSTNAME] name = config.get(CONF_NAME) if not name: if hostname == DEFAULT_HOSTNAME: name = DEFAULT_NAME else: name = hostn...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_devices", ",", "discovery_info", "=", "None", ")", ":", "hostname", "=", "config", "[", "CONF_HOSTNAME", "]", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "if", ...
[ 39, 0 ]
[ 54, 80 ]
python
en
['en', 'ca', 'en']
True
WanIpSensor.__init__
(self, hass, name, hostname, resolver, ipv6)
Initialize the DNS IP sensor.
Initialize the DNS IP sensor.
def __init__(self, hass, name, hostname, resolver, ipv6): """Initialize the DNS IP sensor.""" self.hass = hass self._name = name self.hostname = hostname self.resolver = aiodns.DNSResolver() self.resolver.nameservers = [resolver] self.querytype = "AAAA" if ipv6 e...
[ "def", "__init__", "(", "self", ",", "hass", ",", "name", ",", "hostname", ",", "resolver", ",", "ipv6", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_name", "=", "name", "self", ".", "hostname", "=", "hostname", "self", ".", "resolver",...
[ 60, 4 ]
[ 69, 26 ]
python
en
['en', 'en', 'en']
True
WanIpSensor.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" ]
[ 72, 4 ]
[ 74, 25 ]
python
en
['en', 'mi', 'en']
True
WanIpSensor.state
(self)
Return the current DNS IP address for hostname.
Return the current DNS IP address for hostname.
def state(self): """Return the current DNS IP address for hostname.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 77, 4 ]
[ 79, 26 ]
python
en
['en', 'da', 'en']
True
WanIpSensor.async_update
(self)
Get the current DNS IP address for hostname.
Get the current DNS IP address for hostname.
async def async_update(self): """Get the current DNS IP address for hostname.""" try: response = await self.resolver.query(self.hostname, self.querytype) except DNSError as err: _LOGGER.warning("Exception while resolving host: %s", err) response = None ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "response", "=", "await", "self", ".", "resolver", ".", "query", "(", "self", ".", "hostname", ",", "self", ".", "querytype", ")", "except", "DNSError", "as", "err", ":", "_LOGGER", "."...
[ 81, 4 ]
[ 92, 30 ]
python
en
['en', 'da', 'en']
True
test_import
(hass)
Test that we can import a config entry.
Test that we can import a config entry.
async def test_import(hass): """Test that we can import a config entry.""" with patch("pyalmond.WebAlmondAPI.async_list_apps"): assert await setup.async_setup_component( hass, DOMAIN, {DOMAIN: {"type": "local", "host": "http://localhost:3000"}}, ) awai...
[ "async", "def", "test_import", "(", "hass", ")", ":", "with", "patch", "(", "\"pyalmond.WebAlmondAPI.async_list_apps\"", ")", ":", "assert", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"type\"", "...
[ 16, 0 ]
[ 29, 56 ]
python
en
['en', 'en', 'en']
True
test_import_cannot_connect
(hass)
Test that we won't import a config entry if we cannot connect.
Test that we won't import a config entry if we cannot connect.
async def test_import_cannot_connect(hass): """Test that we won't import a config entry if we cannot connect.""" with patch( "pyalmond.WebAlmondAPI.async_list_apps", side_effect=asyncio.TimeoutError ): assert await setup.async_setup_component( hass, DOMAIN, ...
[ "async", "def", "test_import_cannot_connect", "(", "hass", ")", ":", "with", "patch", "(", "\"pyalmond.WebAlmondAPI.async_list_apps\"", ",", "side_effect", "=", "asyncio", ".", "TimeoutError", ")", ":", "assert", "await", "setup", ".", "async_setup_component", "(", ...
[ 32, 0 ]
[ 44, 62 ]
python
en
['en', 'en', 'en']
True
test_hassio
(hass)
Test that Hass.io can discover this integration.
Test that Hass.io can discover this integration.
async def test_hassio(hass): """Test that Hass.io can discover this integration.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "hassio"}, data={"addon": "Almond add-on", "host": "almond-addon", "port": "1234"}, ) assert result["type"] == data_...
[ "async", "def", "test_hassio", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"hassio\"", "}", ",", "data", "=", "{", "\"addon\""...
[ 47, 0 ]
[ 70, 59 ]
python
en
['en', 'en', 'en']
True
test_abort_if_existing_entry
(hass)
Check flow abort when an entry already exist.
Check flow abort when an entry already exist.
async def test_abort_if_existing_entry(hass): """Check flow abort when an entry already exist.""" MockConfigEntry(domain=DOMAIN).add_to_hass(hass) flow = config_flow.AlmondFlowHandler() flow.hass = hass result = await flow.async_step_user() assert result["type"] == data_entry_flow.RESULT_TYPE_...
[ "async", "def", "test_abort_if_existing_entry", "(", "hass", ")", ":", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ")", ".", "add_to_hass", "(", "hass", ")", "flow", "=", "config_flow", ".", "AlmondFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass...
[ 73, 0 ]
[ 90, 56 ]
python
en
['en', 'en', 'en']
True
test_full_flow
(hass, aiohttp_client, aioclient_mock, current_request)
Check full flow.
Check full flow.
async def test_full_flow(hass, aiohttp_client, aioclient_mock, current_request): """Check full flow.""" assert await setup.async_setup_component( hass, DOMAIN, { DOMAIN: { "type": "oauth2", CONF_CLIENT_ID: CLIENT_ID_VALUE, CONF_...
[ "async", "def", "test_full_flow", "(", "hass", ",", "aiohttp_client", ",", "aioclient_mock", ",", "current_request", ")", ":", "assert", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"type\"", ":", ...
[ 93, 0 ]
[ 146, 65 ]
python
en
['sv', 'no', 'en']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Yamaha MusicCast platform.
Set up the Yamaha MusicCast platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Yamaha MusicCast platform.""" known_hosts = hass.data.get(KNOWN_HOSTS_KEY) if known_hosts is None: known_hosts = hass.data[KNOWN_HOSTS_KEY] = [] _LOGGER.debug("known_hosts: %s", known_hosts) host = config.ge...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "known_hosts", "=", "hass", ".", "data", ".", "get", "(", "KNOWN_HOSTS_KEY", ")", "if", "known_hosts", "is", "None", ":", "known_hosts", ...
[ 63, 0 ]
[ 104, 36 ]
python
en
['en', 'su', 'en']
True
YamahaDevice.__init__
(self, recv, zone)
Initialize the Yamaha MusicCast device.
Initialize the Yamaha MusicCast device.
def __init__(self, recv, zone): """Initialize the Yamaha MusicCast device.""" self._recv = recv self._name = recv.name self._source = None self._source_list = [] self._zone = zone self.mute = False self.media_status = None self.media_status_receive...
[ "def", "__init__", "(", "self", ",", "recv", ",", "zone", ")", ":", "self", ".", "_recv", "=", "recv", "self", ".", "_name", "=", "recv", ".", "name", "self", ".", "_source", "=", "None", "self", ".", "_source_list", "=", "[", "]", "self", ".", "...
[ 110, 4 ]
[ 125, 42 ]
python
en
['en', 'en', 'en']
True
YamahaDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return f"{self._name} ({self._zone.zone_id})"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._name} ({self._zone.zone_id})\"" ]
[ 128, 4 ]
[ 130, 53 ]
python
en
['en', 'en', 'en']
True
YamahaDevice.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" if self.power == STATE_ON and self.status != STATE_UNKNOWN: return self.status return self.power
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "power", "==", "STATE_ON", "and", "self", ".", "status", "!=", "STATE_UNKNOWN", ":", "return", "self", ".", "status", "return", "self", ".", "power" ]
[ 133, 4 ]
[ 137, 25 ]
python
en
['en', 'en', 'en']
True
YamahaDevice.is_volume_muted
(self)
Boolean if volume is currently muted.
Boolean if volume is currently muted.
def is_volume_muted(self): """Boolean if volume is currently muted.""" return self.mute
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "mute" ]
[ 140, 4 ]
[ 142, 24 ]
python
en
['en', 'en', 'en']
True
YamahaDevice.volume_level
(self)
Volume level of the media player (0..1).
Volume level of the media player (0..1).
def volume_level(self): """Volume level of the media player (0..1).""" return self.volume
[ "def", "volume_level", "(", "self", ")", ":", "return", "self", ".", "volume" ]
[ 145, 4 ]
[ 147, 26 ]
python
en
['en', 'en', 'en']
True
YamahaDevice.supported_features
(self)
Flag of features that are supported.
Flag of features that are supported.
def supported_features(self): """Flag of features that are supported.""" return SUPPORTED_FEATURES
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORTED_FEATURES" ]
[ 150, 4 ]
[ 152, 33 ]
python
en
['en', 'en', 'en']
True
YamahaDevice.source
(self)
Return the current input source.
Return the current input source.
def source(self): """Return the current input source.""" return self._source
[ "def", "source", "(", "self", ")", ":", "return", "self", ".", "_source" ]
[ 155, 4 ]
[ 157, 27 ]
python
en
['en', 'en', 'en']
True
YamahaDevice.source_list
(self)
List of available input sources.
List of available input sources.
def source_list(self): """List of available input sources.""" return self._source_list
[ "def", "source_list", "(", "self", ")", ":", "return", "self", ".", "_source_list" ]
[ 160, 4 ]
[ 162, 32 ]
python
en
['en', 'en', 'en']
True