Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_user_ipp_version_error
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we abort user flow on IPP version not supported error.
Test we abort user flow on IPP version not supported error.
async def test_user_ipp_version_error( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we abort user flow on IPP version not supported error.""" mock_connection(aioclient_mock, version_not_supported=True) user_input = {**MOCK_USER_INPUT} result = await hass.config_entrie...
[ "async", "def", "test_user_ipp_version_error", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ",", "version_not_supported", "=", "True", ")", "user_input", "=", ...
[ 205, 0 ]
[ 219, 50 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_ipp_version_error
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we abort zeroconf flow on IPP version not supported error.
Test we abort zeroconf flow on IPP version not supported error.
async def test_zeroconf_ipp_version_error( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we abort zeroconf flow on IPP version not supported error.""" mock_connection(aioclient_mock, version_not_supported=True) discovery_info = {**MOCK_ZEROCONF_IPP_SERVICE_INFO} result...
[ "async", "def", "test_zeroconf_ipp_version_error", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ",", "version_not_supported", "=", "True", ")", "discovery_info", ...
[ 222, 0 ]
[ 236, 50 ]
python
en
['en', 'de', 'en']
True
test_user_device_exists_abort
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we abort user flow if printer already configured.
Test we abort user flow if printer already configured.
async def test_user_device_exists_abort( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we abort user flow if printer already configured.""" await init_integration(hass, aioclient_mock, skip_setup=True) user_input = MOCK_USER_INPUT.copy() result = await hass.config_entr...
[ "async", "def", "test_user_device_exists_abort", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ",", "skip_setup", "=", "True", ")", "us...
[ 239, 0 ]
[ 253, 51 ]
python
en
['en', 'de', 'en']
True
test_zeroconf_device_exists_abort
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we abort zeroconf flow if printer already configured.
Test we abort zeroconf flow if printer already configured.
async def test_zeroconf_device_exists_abort( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we abort zeroconf flow if printer already configured.""" await init_integration(hass, aioclient_mock, skip_setup=True) discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() resu...
[ "async", "def", "test_zeroconf_device_exists_abort", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ",", "skip_setup", "=", "True", ")", ...
[ 256, 0 ]
[ 270, 51 ]
python
de
['de', 'de', 'en']
True
test_zeroconf_with_uuid_device_exists_abort
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we abort zeroconf flow if printer already configured.
Test we abort zeroconf flow if printer already configured.
async def test_zeroconf_with_uuid_device_exists_abort( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we abort zeroconf flow if printer already configured.""" await init_integration(hass, aioclient_mock, skip_setup=True) discovery_info = { **MOCK_ZEROCONF_IPP_SERVIC...
[ "async", "def", "test_zeroconf_with_uuid_device_exists_abort", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ",", "skip_setup", "=", "True"...
[ 273, 0 ]
[ 293, 51 ]
python
de
['de', 'de', 'en']
True
test_zeroconf_empty_unique_id
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test zeroconf flow if printer lacks (empty) unique identification.
Test zeroconf flow if printer lacks (empty) unique identification.
async def test_zeroconf_empty_unique_id( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test zeroconf flow if printer lacks (empty) unique identification.""" mock_connection(aioclient_mock, no_unique_id=True) discovery_info = { **MOCK_ZEROCONF_IPP_SERVICE_INFO, "...
[ "async", "def", "test_zeroconf_empty_unique_id", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ",", "no_unique_id", "=", "True", ")", "discovery_info", "=", "{"...
[ 296, 0 ]
[ 312, 45 ]
python
fr
['fr', 'fr', 'en']
True
test_zeroconf_no_unique_id
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test zeroconf flow if printer lacks unique identification.
Test zeroconf flow if printer lacks unique identification.
async def test_zeroconf_no_unique_id( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test zeroconf flow if printer lacks unique identification.""" mock_connection(aioclient_mock, no_unique_id=True) discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.co...
[ "async", "def", "test_zeroconf_no_unique_id", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ",", "no_unique_id", "=", "True", ")", "discovery_info", "=", "MOCK_...
[ 315, 0 ]
[ 328, 45 ]
python
fr
['fr', 'fr', 'en']
True
test_full_user_flow_implementation
( hass: HomeAssistant, aioclient_mock )
Test the full manual user flow from start to finish.
Test the full manual user flow from start to finish.
async def test_full_user_flow_implementation( hass: HomeAssistant, aioclient_mock ) -> None: """Test the full manual user flow from start to finish.""" mock_connection(aioclient_mock) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, ) ...
[ "async", "def", "test_full_user_flow_implementation", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_i...
[ 331, 0 ]
[ 361, 79 ]
python
en
['en', 'en', 'en']
True
test_full_zeroconf_flow_implementation
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the full manual user flow from start to finish.
Test the full manual user flow from start to finish.
async def test_full_zeroconf_flow_implementation( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the full manual user flow from start to finish.""" mock_connection(aioclient_mock) discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.config_entries....
[ "async", "def", "test_full_zeroconf_flow_implementation", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ")", "discovery_info", "=", "MOCK_ZEROCONF_IPP_SERVICE_INFO", ...
[ 364, 0 ]
[ 397, 79 ]
python
en
['en', 'en', 'en']
True
test_full_zeroconf_tls_flow_implementation
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the full manual user flow from start to finish.
Test the full manual user flow from start to finish.
async def test_full_zeroconf_tls_flow_implementation( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the full manual user flow from start to finish.""" mock_connection(aioclient_mock, ssl=True) discovery_info = MOCK_ZEROCONF_IPPS_SERVICE_INFO.copy() result = await hass....
[ "async", "def", "test_full_zeroconf_tls_flow_implementation", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ",", "ssl", "=", "True", ")", "discovery_info", "=", ...
[ 400, 0 ]
[ 434, 79 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Epson projector from a config entry.
Set up the Epson projector from a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Epson projector from a config entry.""" unique_id = config_entry.entry_id projector = hass.data[DOMAIN][unique_id] projector_entity = EpsonProjectorMediaPlayer( projector, config_entry.title, unique_id ) a...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "unique_id", "=", "config_entry", ".", "entry_id", "projector", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "unique_id", "]", "projector_entity", ...
[ 66, 0 ]
[ 79, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Epson projector.
Set up the Epson projector.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Epson projector.""" hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data=config ) )
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",...
[ 82, 0 ]
[ 88, 5 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.__init__
(self, projector, name, unique_id)
Initialize entity to control Epson projector.
Initialize entity to control Epson projector.
def __init__(self, projector, name, unique_id): """Initialize entity to control Epson projector.""" self._name = name self._projector = projector self._available = False self._cmode = None self._source_list = list(DEFAULT_SOURCES.values()) self._source = None ...
[ "def", "__init__", "(", "self", ",", "projector", ",", "name", ",", "unique_id", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_projector", "=", "projector", "self", ".", "_available", "=", "False", "self", ".", "_cmode", "=", "None", "sel...
[ 94, 4 ]
[ 104, 35 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.async_update
(self)
Update state of device.
Update state of device.
async def async_update(self): """Update state of device.""" power_state = await self._projector.get_property(POWER) _LOGGER.debug("Projector status: %s", power_state) if not power_state or power_state == EPSON_STATE_UNAVAILABLE: self._available = False return ...
[ "async", "def", "async_update", "(", "self", ")", ":", "power_state", "=", "await", "self", ".", "_projector", ".", "get_property", "(", "POWER", ")", "_LOGGER", ".", "debug", "(", "\"Projector status: %s\"", ",", "power_state", ")", "if", "not", "power_state"...
[ 106, 4 ]
[ 127, 35 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 130, 4 ]
[ 132, 25 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.unique_id
(self)
Return unique ID.
Return unique ID.
def unique_id(self): """Return unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 135, 4 ]
[ 137, 30 ]
python
en
['fr', 'la', 'en']
False
EpsonProjectorMediaPlayer.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 140, 4 ]
[ 142, 26 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.available
(self)
Return if projector is available.
Return if projector is available.
def available(self): """Return if projector is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 145, 4 ]
[ 147, 30 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.supported_features
(self)
Flag media player features that are supported.
Flag media player features that are supported.
def supported_features(self): """Flag media player features that are supported.""" return SUPPORT_EPSON
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_EPSON" ]
[ 150, 4 ]
[ 152, 28 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.async_turn_on
(self)
Turn on epson.
Turn on epson.
async def async_turn_on(self): """Turn on epson.""" if self._state == STATE_OFF: await self._projector.send_command(TURN_ON)
[ "async", "def", "async_turn_on", "(", "self", ")", ":", "if", "self", ".", "_state", "==", "STATE_OFF", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "TURN_ON", ")" ]
[ 154, 4 ]
[ 157, 55 ]
python
en
['en', 'et', 'en']
True
EpsonProjectorMediaPlayer.async_turn_off
(self)
Turn off epson.
Turn off epson.
async def async_turn_off(self): """Turn off epson.""" if self._state == STATE_ON: await self._projector.send_command(TURN_OFF)
[ "async", "def", "async_turn_off", "(", "self", ")", ":", "if", "self", ".", "_state", "==", "STATE_ON", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "TURN_OFF", ")" ]
[ 159, 4 ]
[ 162, 56 ]
python
en
['en', 'ja', 'en']
True
EpsonProjectorMediaPlayer.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" ]
[ 165, 4 ]
[ 167, 32 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.source
(self)
Get current input sources.
Get current input sources.
def source(self): """Get current input sources.""" return self._source
[ "def", "source", "(", "self", ")", ":", "return", "self", ".", "_source" ]
[ 170, 4 ]
[ 172, 27 ]
python
en
['fr', 'en', 'en']
True
EpsonProjectorMediaPlayer.volume_level
(self)
Return the volume level of the media player (0..1).
Return the volume level of the media player (0..1).
def volume_level(self): """Return the volume level of the media player (0..1).""" return self._volume
[ "def", "volume_level", "(", "self", ")", ":", "return", "self", ".", "_volume" ]
[ 175, 4 ]
[ 177, 27 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.select_cmode
(self, cmode)
Set color mode in Epson.
Set color mode in Epson.
async def select_cmode(self, cmode): """Set color mode in Epson.""" await self._projector.send_command(CMODE_LIST_SET[cmode])
[ "async", "def", "select_cmode", "(", "self", ",", "cmode", ")", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "CMODE_LIST_SET", "[", "cmode", "]", ")" ]
[ 179, 4 ]
[ 181, 65 ]
python
en
['en', 'en', 'en']
True
EpsonProjectorMediaPlayer.async_select_source
(self, source)
Select input source.
Select input source.
async def async_select_source(self, source): """Select input source.""" selected_source = INV_SOURCES[source] await self._projector.send_command(selected_source)
[ "async", "def", "async_select_source", "(", "self", ",", "source", ")", ":", "selected_source", "=", "INV_SOURCES", "[", "source", "]", "await", "self", ".", "_projector", ".", "send_command", "(", "selected_source", ")" ]
[ 183, 4 ]
[ 186, 59 ]
python
en
['fr', 'su', 'en']
False
EpsonProjectorMediaPlayer.async_mute_volume
(self, mute)
Mute (true) or unmute (false) sound.
Mute (true) or unmute (false) sound.
async def async_mute_volume(self, mute): """Mute (true) or unmute (false) sound.""" await self._projector.send_command(MUTE)
[ "async", "def", "async_mute_volume", "(", "self", ",", "mute", ")", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "MUTE", ")" ]
[ 188, 4 ]
[ 190, 48 ]
python
en
['en', 'la', 'en']
True
EpsonProjectorMediaPlayer.async_volume_up
(self)
Increase volume.
Increase volume.
async def async_volume_up(self): """Increase volume.""" await self._projector.send_command(VOL_UP)
[ "async", "def", "async_volume_up", "(", "self", ")", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "VOL_UP", ")" ]
[ 192, 4 ]
[ 194, 50 ]
python
en
['en', 'af', 'en']
False
EpsonProjectorMediaPlayer.async_volume_down
(self)
Decrease volume.
Decrease volume.
async def async_volume_down(self): """Decrease volume.""" await self._projector.send_command(VOL_DOWN)
[ "async", "def", "async_volume_down", "(", "self", ")", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "VOL_DOWN", ")" ]
[ 196, 4 ]
[ 198, 52 ]
python
en
['en', 'de', 'en']
False
EpsonProjectorMediaPlayer.async_media_play
(self)
Play media via Epson.
Play media via Epson.
async def async_media_play(self): """Play media via Epson.""" await self._projector.send_command(PLAY)
[ "async", "def", "async_media_play", "(", "self", ")", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "PLAY", ")" ]
[ 200, 4 ]
[ 202, 48 ]
python
en
['en', 'sk', 'it']
False
EpsonProjectorMediaPlayer.async_media_pause
(self)
Pause media via Epson.
Pause media via Epson.
async def async_media_pause(self): """Pause media via Epson.""" await self._projector.send_command(PAUSE)
[ "async", "def", "async_media_pause", "(", "self", ")", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "PAUSE", ")" ]
[ 204, 4 ]
[ 206, 49 ]
python
de
['de', 'sk', 'it']
False
EpsonProjectorMediaPlayer.async_media_next_track
(self)
Skip to next.
Skip to next.
async def async_media_next_track(self): """Skip to next.""" await self._projector.send_command(FAST)
[ "async", "def", "async_media_next_track", "(", "self", ")", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "FAST", ")" ]
[ 208, 4 ]
[ 210, 48 ]
python
en
['en', 'bg-Latn', 'en']
True
EpsonProjectorMediaPlayer.async_media_previous_track
(self)
Skip to previous.
Skip to previous.
async def async_media_previous_track(self): """Skip to previous.""" await self._projector.send_command(BACK)
[ "async", "def", "async_media_previous_track", "(", "self", ")", ":", "await", "self", ".", "_projector", ".", "send_command", "(", "BACK", ")" ]
[ 212, 4 ]
[ 214, 48 ]
python
en
['en', 'el-Latn', 'en']
True
EpsonProjectorMediaPlayer.device_state_attributes
(self)
Return device specific state attributes.
Return device specific state attributes.
def device_state_attributes(self): """Return device specific state attributes.""" if self._cmode is None: return {} return {ATTR_CMODE: self._cmode}
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_cmode", "is", "None", ":", "return", "{", "}", "return", "{", "ATTR_CMODE", ":", "self", ".", "_cmode", "}" ]
[ 217, 4 ]
[ 221, 40 ]
python
en
['fr', 'en', 'en']
True
get_domains
(device_type)
Return the domains available for a device type.
Return the domains available for a device type.
def get_domains(device_type): """Return the domains available for a device type.""" return {domain for domain, types in DOMAINS_AND_TYPES if device_type in types}
[ "def", "get_domains", "(", "device_type", ")", ":", "return", "{", "domain", "for", "domain", ",", "types", "in", "DOMAINS_AND_TYPES", "if", "device_type", "in", "types", "}" ]
[ 24, 0 ]
[ 26, 82 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.__init__
(self, hass, config)
Initialize the device.
Initialize the device.
def __init__(self, hass, config): """Initialize the device.""" self.hass = hass self.config = config self.api = None self.update_manager = None self.fw_version = None self.authorized = None self.reset_jobs = []
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "config", "=", "config", "self", ".", "api", "=", "None", "self", ".", "update_manager", "=", "None", "self", ".", "fw_version", "=",...
[ 32, 4 ]
[ 40, 28 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.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.config.title
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "config", ".", "title" ]
[ 43, 4 ]
[ 45, 32 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.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.config.unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "config", ".", "unique_id" ]
[ 48, 4 ]
[ 50, 36 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.async_update
(hass, entry)
Update the device and related entities. Triggered when the device is renamed on the frontend.
Update the device and related entities.
async def async_update(hass, entry): """Update the device and related entities. Triggered when the device is renamed on the frontend. """ device_registry = await dr.async_get_registry(hass) device_entry = device_registry.async_get_device( {(DOMAIN, entry.unique_id)},...
[ "async", "def", "async_update", "(", "hass", ",", "entry", ")", ":", "device_registry", "=", "await", "dr", ".", "async_get_registry", "(", "hass", ")", "device_entry", "=", "device_registry", ".", "async_get_device", "(", "{", "(", "DOMAIN", ",", "entry", "...
[ 53, 4 ]
[ 63, 62 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.async_setup
(self)
Set up the device and related entities.
Set up the device and related entities.
async def async_setup(self): """Set up the device and related entities.""" config = self.config api = blk.gendevice( config.data[CONF_TYPE], (config.data[CONF_HOST], DEFAULT_PORT), bytes.fromhex(config.data[CONF_MAC]), name=config.title, )...
[ "async", "def", "async_setup", "(", "self", ")", ":", "config", "=", "self", ".", "config", "api", "=", "blk", ".", "gendevice", "(", "config", ".", "data", "[", "CONF_TYPE", "]", ",", "(", "config", ".", "data", "[", "CONF_HOST", "]", ",", "DEFAULT_...
[ 65, 4 ]
[ 119, 19 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.async_unload
(self)
Unload the device and related entities.
Unload the device and related entities.
async def async_unload(self): """Unload the device and related entities.""" if self.update_manager is None: return True while self.reset_jobs: self.reset_jobs.pop()() tasks = ( self.hass.config_entries.async_forward_entry_unload(self.config, domain) ...
[ "async", "def", "async_unload", "(", "self", ")", ":", "if", "self", ".", "update_manager", "is", "None", ":", "return", "True", "while", "self", ".", "reset_jobs", ":", "self", ".", "reset_jobs", ".", "pop", "(", ")", "(", ")", "tasks", "=", "(", "s...
[ 121, 4 ]
[ 134, 27 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.async_auth
(self)
Authenticate to the device.
Authenticate to the device.
async def async_auth(self): """Authenticate to the device.""" try: await self.hass.async_add_executor_job(self.api.auth) except (BroadlinkException, OSError) as err: _LOGGER.debug( "Failed to authenticate to the device at %s: %s", self.api.host[0], err ...
[ "async", "def", "async_auth", "(", "self", ")", ":", "try", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "api", ".", "auth", ")", "except", "(", "BroadlinkException", ",", "OSError", ")", "as", "err", ":", "_LOGGER"...
[ 136, 4 ]
[ 147, 19 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.async_request
(self, function, *args, **kwargs)
Send a request to the device.
Send a request to the device.
async def async_request(self, function, *args, **kwargs): """Send a request to the device.""" request = partial(function, *args, **kwargs) try: return await self.hass.async_add_executor_job(request) except (AuthorizationError, ConnectionClosedError): if not await ...
[ "async", "def", "async_request", "(", "self", ",", "function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "request", "=", "partial", "(", "function", ",", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "return", "await", "self", "...
[ 149, 4 ]
[ 157, 66 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice._async_handle_auth_error
(self)
Handle an authentication error.
Handle an authentication error.
async def _async_handle_auth_error(self): """Handle an authentication error.""" if self.authorized is False: return self.authorized = False _LOGGER.error( "%s (%s at %s) is locked. Click Configuration in the sidebar, " "click Integrations, click Conf...
[ "async", "def", "_async_handle_auth_error", "(", "self", ")", ":", "if", "self", ".", "authorized", "is", "False", ":", "return", "self", ".", "authorized", "=", "False", "_LOGGER", ".", "error", "(", "\"%s (%s at %s) is locked. Click Configuration in the sidebar, \""...
[ 159, 4 ]
[ 181, 9 ]
python
de
['de', 'fr', 'en']
False
test_flow_manual_configuration
(hass)
Test that config flow works.
Test that config flow works.
async def test_flow_manual_configuration(hass): """Test that config flow works.""" result = await hass.config_entries.flow.async_init( AXIS_DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == SOURCE_USER with patch("axis.vapix...
[ "async", "def", "test_flow_manual_configuration", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "AXIS_DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "assert", ...
[ 31, 0 ]
[ 61, 5 ]
python
en
['en', 'en', 'en']
True
test_manual_configuration_update_configuration
(hass)
Test that config flow fails on already configured device.
Test that config flow fails on already configured device.
async def test_manual_configuration_update_configuration(hass): """Test that config flow fails on already configured device.""" config_entry = await setup_axis_integration(hass) device = hass.data[AXIS_DOMAIN][config_entry.unique_id] result = await hass.config_entries.flow.async_init( AXIS_DOMA...
[ "async", "def", "test_manual_configuration_update_configuration", "(", "hass", ")", ":", "config_entry", "=", "await", "setup_axis_integration", "(", "hass", ")", "device", "=", "hass", ".", "data", "[", "AXIS_DOMAIN", "]", "[", "config_entry", ".", "unique_id", "...
[ 64, 0 ]
[ 94, 48 ]
python
en
['en', 'en', 'en']
True
test_flow_fails_already_configured
(hass)
Test that config flow fails on already configured device.
Test that config flow fails on already configured device.
async def test_flow_fails_already_configured(hass): """Test that config flow fails on already configured device.""" await setup_axis_integration(hass) result = await hass.config_entries.flow.async_init( AXIS_DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == RESULT_TYPE_FOR...
[ "async", "def", "test_flow_fails_already_configured", "(", "hass", ")", ":", "await", "setup_axis_integration", "(", "hass", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "AXIS_DOMAIN", ",", "context", "=", "{",...
[ 97, 0 ]
[ 120, 51 ]
python
en
['en', 'en', 'en']
True
test_flow_fails_faulty_credentials
(hass)
Test that config flow fails on faulty credentials.
Test that config flow fails on faulty credentials.
async def test_flow_fails_faulty_credentials(hass): """Test that config flow fails on faulty credentials.""" result = await hass.config_entries.flow.async_init( AXIS_DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == SOURCE_USER ...
[ "async", "def", "test_flow_fails_faulty_credentials", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "AXIS_DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "asser...
[ 123, 0 ]
[ 146, 55 ]
python
en
['en', 'en', 'en']
True
test_flow_fails_cannot_connect
(hass)
Test that config flow fails on cannot connect.
Test that config flow fails on cannot connect.
async def test_flow_fails_cannot_connect(hass): """Test that config flow fails on cannot connect.""" result = await hass.config_entries.flow.async_init( AXIS_DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == SOURCE_USER with...
[ "async", "def", "test_flow_fails_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "AXIS_DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "assert", ...
[ 149, 0 ]
[ 172, 57 ]
python
en
['en', 'en', 'en']
True
test_flow_create_entry_multiple_existing_entries_of_same_model
(hass)
Test that create entry can generate a name with other entries.
Test that create entry can generate a name with other entries.
async def test_flow_create_entry_multiple_existing_entries_of_same_model(hass): """Test that create entry can generate a name with other entries.""" entry = MockConfigEntry( domain=AXIS_DOMAIN, data={CONF_NAME: "M1065-LW 0", CONF_MODEL: "M1065-LW"}, ) entry.add_to_hass(hass) entry2 =...
[ "async", "def", "test_flow_create_entry_multiple_existing_entries_of_same_model", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "AXIS_DOMAIN", ",", "data", "=", "{", "CONF_NAME", ":", "\"M1065-LW 0\"", ",", "CONF_MODEL", ":", "\"M1065-LW\...
[ 175, 0 ]
[ 218, 52 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_flow
(hass)
Test that zeroconf discovery for new devices work.
Test that zeroconf discovery for new devices work.
async def test_zeroconf_flow(hass): """Test that zeroconf discovery for new devices work.""" result = await hass.config_entries.flow.async_init( AXIS_DOMAIN, data={ CONF_HOST: "1.2.3.4", CONF_PORT: 80, "hostname": "name", "properties": {"macaddress...
[ "async", "def", "test_zeroconf_flow", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "AXIS_DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "\"1.2.3.4\"", ",", "CONF_PORT", ":", "80", ","...
[ 221, 0 ]
[ 260, 52 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_flow_already_configured
(hass)
Test that zeroconf doesn't setup already configured devices.
Test that zeroconf doesn't setup already configured devices.
async def test_zeroconf_flow_already_configured(hass): """Test that zeroconf doesn't setup already configured devices.""" config_entry = await setup_axis_integration(hass) device = hass.data[AXIS_DOMAIN][config_entry.unique_id] assert device.host == "1.2.3.4" result = await hass.config_entries.flow...
[ "async", "def", "test_zeroconf_flow_already_configured", "(", "hass", ")", ":", "config_entry", "=", "await", "setup_axis_integration", "(", "hass", ")", "device", "=", "hass", ".", "data", "[", "AXIS_DOMAIN", "]", "[", "config_entry", ".", "unique_id", "]", "as...
[ 263, 0 ]
[ 282, 35 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_flow_updated_configuration
(hass)
Test that zeroconf update configuration with new parameters.
Test that zeroconf update configuration with new parameters.
async def test_zeroconf_flow_updated_configuration(hass): """Test that zeroconf update configuration with new parameters.""" config_entry = await setup_axis_integration(hass) device = hass.data[AXIS_DOMAIN][config_entry.unique_id] assert device.host == "1.2.3.4" assert device.config_entry.data == { ...
[ "async", "def", "test_zeroconf_flow_updated_configuration", "(", "hass", ")", ":", "config_entry", "=", "await", "setup_axis_integration", "(", "hass", ")", "device", "=", "hass", ".", "data", "[", "AXIS_DOMAIN", "]", "[", "config_entry", ".", "unique_id", "]", ...
[ 285, 0 ]
[ 327, 48 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_flow_ignore_non_axis_device
(hass)
Test that zeroconf doesn't setup devices with link local addresses.
Test that zeroconf doesn't setup devices with link local addresses.
async def test_zeroconf_flow_ignore_non_axis_device(hass): """Test that zeroconf doesn't setup devices with link local addresses.""" result = await hass.config_entries.flow.async_init( AXIS_DOMAIN, data={CONF_HOST: "169.254.3.4", "properties": {"macaddress": "01234567890"}}, context={"so...
[ "async", "def", "test_zeroconf_flow_ignore_non_axis_device", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "AXIS_DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "\"169.254.3.4\"", ",", "\"pro...
[ 330, 0 ]
[ 339, 48 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_flow_ignore_link_local_address
(hass)
Test that zeroconf doesn't setup devices with link local addresses.
Test that zeroconf doesn't setup devices with link local addresses.
async def test_zeroconf_flow_ignore_link_local_address(hass): """Test that zeroconf doesn't setup devices with link local addresses.""" result = await hass.config_entries.flow.async_init( AXIS_DOMAIN, data={CONF_HOST: "169.254.3.4", "properties": {"macaddress": MAC}}, context={"source": ...
[ "async", "def", "test_zeroconf_flow_ignore_link_local_address", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "AXIS_DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "\"169.254.3.4\"", ",", "\"...
[ 342, 0 ]
[ 351, 51 ]
python
en
['en', 'en', 'en']
True
test_option_flow
(hass)
Test config flow options.
Test config flow options.
async def test_option_flow(hass): """Test config flow options.""" config_entry = await setup_axis_integration(hass) device = hass.data[AXIS_DOMAIN][config_entry.unique_id] assert device.option_stream_profile == DEFAULT_STREAM_PROFILE result = await hass.config_entries.options.async_init(device.conf...
[ "async", "def", "test_option_flow", "(", "hass", ")", ":", "config_entry", "=", "await", "setup_axis_integration", "(", "hass", ")", "device", "=", "hass", ".", "data", "[", "AXIS_DOMAIN", "]", "[", "config_entry", ".", "unique_id", "]", "assert", "device", ...
[ 354, 0 ]
[ 380, 54 ]
python
en
['en', 'fr', 'en']
True
BinaryMeta.events
(self)
List[Event]: Events definition.
List[Event]: Events definition.
def events(self) -> List[Event]: """List[Event]: Events definition.""" return self._events
[ "def", "events", "(", "self", ")", "->", "List", "[", "Event", "]", ":", "return", "self", ".", "_events" ]
[ 65, 4 ]
[ 67, 27 ]
python
en
['fr', 'en', 'en']
True
BinaryMeta.default_event_name
(self)
str: Default event name, if no value matched.
str: Default event name, if no value matched.
def default_event_name(self) -> str: """str: Default event name, if no value matched.""" return self._default_event_name
[ "def", "default_event_name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_default_event_name" ]
[ 70, 4 ]
[ 72, 39 ]
python
ca
['ca', 'da', 'en']
False
BinaryMeta.event_attr_name
(self)
str: Event attribute name.
str: Event attribute name.
def event_attr_name(self) -> str: """str: Event attribute name.""" return self._event_attr_name
[ "def", "event_attr_name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_event_attr_name" ]
[ 75, 4 ]
[ 77, 36 ]
python
en
['en', 'en', 'en']
True
BinaryMeta.time_zone
(self)
Time zone of this meta, used to correct timestamp.
Time zone of this meta, used to correct timestamp.
def time_zone(self): """Time zone of this meta, used to correct timestamp.""" return self._tzone
[ "def", "time_zone", "(", "self", ")", ":", "return", "self", ".", "_tzone" ]
[ 80, 4 ]
[ 82, 26 ]
python
en
['en', 'en', 'en']
True
BinaryMeta.item_size
(self)
int: Item binary size (in bytes).
int: Item binary size (in bytes).
def item_size(self) -> int: """int: Item binary size (in bytes).""" return self._item_struct.size
[ "def", "item_size", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_item_struct", ".", "size" ]
[ 85, 4 ]
[ 87, 37 ]
python
en
['en', 'en', 'en']
True
BinaryMeta.columns
(self)
dict: Columns to extract.
dict: Columns to extract.
def columns(self) -> dict: """dict: Columns to extract.""" return {a.name: a.raw_name for a in self._attrs}
[ "def", "columns", "(", "self", ")", "->", "dict", ":", "return", "{", "a", ".", "name", ":", "a", ".", "raw_name", "for", "a", "in", "self", ".", "_attrs", "}" ]
[ 90, 4 ]
[ 92, 56 ]
python
en
['en', 'en', 'en']
True
BinaryMeta.items
(self)
dict: Attribute items.
dict: Attribute items.
def items(self) -> dict: """dict: Attribute items.""" return {a.name: a.dtype for a in self._attrs}
[ "def", "items", "(", "self", ")", "->", "dict", ":", "return", "{", "a", ".", "name", ":", "a", ".", "dtype", "for", "a", "in", "self", ".", "_attrs", "}" ]
[ 94, 4 ]
[ 96, 53 ]
python
en
['en', 'la', 'en']
True
BinaryMeta.from_file
(self, file: str)
Read meta from yaml file.
Read meta from yaml file.
def from_file(self, file: str): """Read meta from yaml file.""" assert os.path.exists(file) with open(file, "rt") as fp: conf = safe_load(fp) self._validate(conf) self._build_item_struct()
[ "def", "from_file", "(", "self", ",", "file", ":", "str", ")", ":", "assert", "os", ".", "path", ".", "exists", "(", "file", ")", "with", "open", "(", "file", ",", "\"rt\"", ")", "as", "fp", ":", "conf", "=", "safe_load", "(", "fp", ")", "self", ...
[ 98, 4 ]
[ 107, 37 ]
python
en
['en', 'yo', 'en']
True
BinaryMeta.from_bytes
(self, meta_bytes: Union[bytes, bytearray, memoryview])
Construct meta from bytes. Args: meta_bytes (Union[bytes, bytearray, memoryview]): Bytes content of meta.
Construct meta from bytes.
def from_bytes(self, meta_bytes: Union[bytes, bytearray, memoryview]): """Construct meta from bytes. Args: meta_bytes (Union[bytes, bytearray, memoryview]): Bytes content of meta. """ assert meta_bytes is not None self._events.clear() self._attrs.clear() ...
[ "def", "from_bytes", "(", "self", ",", "meta_bytes", ":", "Union", "[", "bytes", ",", "bytearray", ",", "memoryview", "]", ")", ":", "assert", "meta_bytes", "is", "not", "None", "self", ".", "_events", ".", "clear", "(", ")", "self", ".", "_attrs", "."...
[ 109, 4 ]
[ 137, 33 ]
python
en
['en', 'en', 'en']
True
BinaryMeta.from_dict
(self, meta_dict: dict)
Construct meta from dictionary. Args: meta_dict (dict): Meta dictionary.
Construct meta from dictionary.
def from_dict(self, meta_dict: dict): """Construct meta from dictionary. Args: meta_dict (dict): Meta dictionary. """ self._validate(meta_dict) self._build_item_struct()
[ "def", "from_dict", "(", "self", ",", "meta_dict", ":", "dict", ")", ":", "self", ".", "_validate", "(", "meta_dict", ")", "self", ".", "_build_item_struct", "(", ")" ]
[ 139, 4 ]
[ 147, 33 ]
python
en
['en', 'en', 'en']
True
BinaryMeta.to_bytes
(self)
Convert meta into bytes. Returns: bytes: Bytes content of current meta.
Convert meta into bytes.
def to_bytes(self): """Convert meta into bytes. Returns: bytes: Bytes content of current meta. """ return safe_dump( { "events": self._events, "attributes": self._attrs, "default_event_name": self._default_event_nam...
[ "def", "to_bytes", "(", "self", ")", ":", "return", "safe_dump", "(", "{", "\"events\"", ":", "self", ".", "_events", ",", "\"attributes\"", ":", "self", ".", "_attrs", ",", "\"default_event_name\"", ":", "self", ".", "_default_event_name", ",", "\"event_attr_...
[ 149, 4 ]
[ 162, 18 ]
python
en
['en', 'sr', 'en']
True
BinaryMeta.get_item_values
(self, row: dict)
Retrieve value for item. Args: row (dict): A row that from a csv file. Returns: Union[list, tuple]: Get value for configured attributes from dict.
Retrieve value for item.
def get_item_values(self, row: dict) -> Union[list, tuple]: """Retrieve value for item. Args: row (dict): A row that from a csv file. Returns: Union[list, tuple]: Get value for configured attributes from dict. """ # NOTE: keep the order return (r...
[ "def", "get_item_values", "(", "self", ",", "row", ":", "dict", ")", "->", "Union", "[", "list", ",", "tuple", "]", ":", "# NOTE: keep the order", "return", "(", "row", "[", "col", "]", "for", "col", "in", "self", ".", "_raw_cols", ")" ]
[ 164, 4 ]
[ 174, 51 ]
python
en
['en', 'pt', 'en']
True
BinaryMeta.item_to_bytes
(self, item_values: Union[tuple, list], out_bytes: Union[memoryview, bytearray])
Convert item into bytes. Args: item_values (Union[tuple, list]): Value of attributes used to construct item. out_bytes (Union[memoryview, bytearray]): Item bytes content. Returns: int: Result item size.
Convert item into bytes.
def item_to_bytes(self, item_values: Union[tuple, list], out_bytes: Union[memoryview, bytearray]) -> int: """Convert item into bytes. Args: item_values (Union[tuple, list]): Value of attributes used to construct item. out_bytes (Union[memoryview, bytearray]): Item bytes content....
[ "def", "item_to_bytes", "(", "self", ",", "item_values", ":", "Union", "[", "tuple", ",", "list", "]", ",", "out_bytes", ":", "Union", "[", "memoryview", ",", "bytearray", "]", ")", "->", "int", ":", "self", ".", "_item_struct", ".", "pack_into", "(", ...
[ 176, 4 ]
[ 188, 29 ]
python
en
['en', 'hu', 'en']
True
BinaryMeta.item_from_bytes
(self, item_bytes: Union[bytes, bytearray, memoryview], adjust_value: bool = False)
Convert bytes into item (namedtuple). Args: item_bytes (Union[bytes, bytearray, memoryview]): Item byte content. adjust_value (bool): If need to adjust value for attributes that enabled this feature. Returns: namedtuple: Result item tuple.
Convert bytes into item (namedtuple).
def item_from_bytes(self, item_bytes: Union[bytes, bytearray, memoryview], adjust_value: bool = False): """Convert bytes into item (namedtuple). Args: item_bytes (Union[bytes, bytearray, memoryview]): Item byte content. adjust_value (bool): If need to adjust value for attributes...
[ "def", "item_from_bytes", "(", "self", ",", "item_bytes", ":", "Union", "[", "bytes", ",", "bytearray", ",", "memoryview", "]", ",", "adjust_value", ":", "bool", "=", "False", ")", ":", "item_tuple", "=", "self", ".", "_item_struct", ".", "unpack_from", "(...
[ 190, 4 ]
[ 210, 46 ]
python
en
['en', 'hu', 'en']
True
BinaryMeta._build_item_struct
(self)
Build item struct use field name in meta.
Build item struct use field name in meta.
def _build_item_struct(self): """Build item struct use field name in meta.""" self._item_nt = namedtuple("Item", [a.name for a in self._attrs]) fmt: str = "<" + "".join([dtype_pack_map[a.dtype] for a in self._attrs]) self._item_struct = Struct(fmt)
[ "def", "_build_item_struct", "(", "self", ")", ":", "self", ".", "_item_nt", "=", "namedtuple", "(", "\"Item\"", ",", "[", "a", ".", "name", "for", "a", "in", "self", ".", "_attrs", "]", ")", "fmt", ":", "str", "=", "\"<\"", "+", "\"\"", ".", "join...
[ 212, 4 ]
[ 218, 39 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the available Danfoss Air sensors etc.
Set up the available Danfoss Air sensors etc.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the available Danfoss Air sensors etc.""" data = hass.data[DANFOSS_AIR_DOMAIN] sensors = [ [ "Danfoss Air Exhaust Temperature", TEMP_CELSIUS, ReadCommand.exhaustTemperature, ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "data", "=", "hass", ".", "data", "[", "DANFOSS_AIR_DOMAIN", "]", "sensors", "=", "[", "[", "\"Danfoss Air Exhaust Temperature\"", ",", "TEM...
[ 19, 0 ]
[ 76, 27 ]
python
en
['en', 'su', 'en']
True
DanfossAir.__init__
(self, data, name, sensor_unit, sensor_type, device_class)
Initialize the sensor.
Initialize the sensor.
def __init__(self, data, name, sensor_unit, sensor_type, device_class): """Initialize the sensor.""" self._data = data self._name = name self._state = None self._type = sensor_type self._unit = sensor_unit self._device_class = device_class
[ "def", "__init__", "(", "self", ",", "data", ",", "name", ",", "sensor_unit", ",", "sensor_type", ",", "device_class", ")", ":", "self", ".", "_data", "=", "data", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "None", "self", ".", "_...
[ 82, 4 ]
[ 89, 41 ]
python
en
['en', 'en', 'en']
True
DanfossAir.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" ]
[ 92, 4 ]
[ 94, 25 ]
python
en
['en', 'mi', 'en']
True
DanfossAir.device_class
(self)
Return the device class of the sensor.
Return the device class of the sensor.
def device_class(self): """Return the device class of the sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 97, 4 ]
[ 99, 33 ]
python
en
['en', 'en', 'en']
True
DanfossAir.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" ]
[ 102, 4 ]
[ 104, 26 ]
python
en
['en', 'en', 'en']
True
DanfossAir.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" ]
[ 107, 4 ]
[ 109, 25 ]
python
en
['en', 'la', 'en']
True
DanfossAir.update
(self)
Update the new state of the sensor. This is done through the DanfossAir object that does the actual communication with the Air CCM.
Update the new state of the sensor.
def update(self): """Update the new state of the sensor. This is done through the DanfossAir object that does the actual communication with the Air CCM. """ self._data.update() self._state = self._data.get_value(self._type) if self._state is None: _L...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_data", ".", "update", "(", ")", "self", ".", "_state", "=", "self", ".", "_data", ".", "get_value", "(", "self", ".", "_type", ")", "if", "self", ".", "_state", "is", "None", ":", "_LOGGER", ...
[ 111, 4 ]
[ 121, 66 ]
python
en
['en', 'en', 'en']
True
MaIlpAgent.__init__
( self, ilp: CitiBikeILP, num_station: int, num_time_interval: int, ticks_per_interval: int, ma_window_size: int )
An agent that make decisions by ILP in Citi Bike scenario. Args: ilp (CitiBikeILP): The ILP instance. num_station (int): The number of stations in the target environment. num_time_interval (int): The number of time intervals for which the agent need to provide future demand ...
An agent that make decisions by ILP in Citi Bike scenario.
def __init__( self, ilp: CitiBikeILP, num_station: int, num_time_interval: int, ticks_per_interval: int, ma_window_size: int ): """An agent that make decisions by ILP in Citi Bike scenario. Args: ilp (CitiBikeILP): The ILP instance. num_station (int): The number of s...
[ "def", "__init__", "(", "self", ",", "ilp", ":", "CitiBikeILP", ",", "num_station", ":", "int", ",", "num_time_interval", ":", "int", ",", "ticks_per_interval", ":", "int", ",", "ma_window_size", ":", "int", ")", ":", "self", ".", "_ilp", "=", "ilp", "se...
[ 25, 4 ]
[ 48, 36 ]
python
en
['en', 'en', 'en']
True
MaIlpAgent._record_history
(self, env_tick: int, finished_events: List[Event])
Args: env_tick (int): The current Env tick. finished_events (List[Event]): The finished events got from the Env.
Args: env_tick (int): The current Env tick. finished_events (List[Event]): The finished events got from the Env.
def _record_history(self, env_tick: int, finished_events: List[Event]): """ Args: env_tick (int): The current Env tick. finished_events (List[Event]): The finished events got from the Env. """ num_interval_to_record = (env_tick - 1) // self._ticks_per_interval - s...
[ "def", "_record_history", "(", "self", ",", "env_tick", ":", "int", ",", "finished_events", ":", "List", "[", "Event", "]", ")", ":", "num_interval_to_record", "=", "(", "env_tick", "-", "1", ")", "//", "self", ".", "_ticks_per_interval", "-", "self", ".",...
[ 52, 4 ]
[ 91, 67 ]
python
en
['en', 'error', 'th']
False
MaIlpAgent._forecast_demand_and_supply
(self)
Returns: Tuple[np.ndarray, np.ndarray]: The first item indicates the forecasting demand for each station in each time interval, with shape: (num_time_interval, num_station). The second item indicates the forecasting supply for each station in each tim...
Returns: Tuple[np.ndarray, np.ndarray]: The first item indicates the forecasting demand for each station in each time interval, with shape: (num_time_interval, num_station). The second item indicates the forecasting supply for each station in each tim...
def _forecast_demand_and_supply(self) -> Tuple[np.ndarray, np.ndarray]: """ Returns: Tuple[np.ndarray, np.ndarray]: The first item indicates the forecasting demand for each station in each time interval, with shape: (num_time_interval, num_station). ...
[ "def", "_forecast_demand_and_supply", "(", "self", ")", "->", "Tuple", "[", "np", ".", "ndarray", ",", "np", ".", "ndarray", "]", ":", "demand", "=", "np", ".", "array", "(", "[", "round", "(", "self", ".", "_demand_forecaster", "[", "i", "]", ".", "...
[ 93, 4 ]
[ 112, 29 ]
python
en
['en', 'error', 'th']
False
test_show_set_form
(hass)
Test that the setup form is served.
Test that the setup form is served.
async def test_show_set_form(hass): """Test that the setup form is served.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "user"
[ "async", "def", "test_show_set_form", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ",", ...
[ 34, 0 ]
[ 41, 38 ]
python
en
['en', 'en', 'en']
True
test_urlize_plain_host
(hass, requests_mock)
Test that plain host or IP gets converted to a URL.
Test that plain host or IP gets converted to a URL.
async def test_urlize_plain_host(hass, requests_mock): """Test that plain host or IP gets converted to a URL.""" requests_mock.request(ANY, ANY, exc=ConnectionError()) host = "192.168.100.1" user_input = {**FIXTURE_USER_INPUT, CONF_URL: host} result = await hass.config_entries.flow.async_init( ...
[ "async", "def", "test_urlize_plain_host", "(", "hass", ",", "requests_mock", ")", ":", "requests_mock", ".", "request", "(", "ANY", ",", "ANY", ",", "exc", "=", "ConnectionError", "(", ")", ")", "host", "=", "\"192.168.100.1\"", "user_input", "=", "{", "*", ...
[ 44, 0 ]
[ 55, 52 ]
python
en
['en', 'en', 'en']
True
test_already_configured
(hass)
Test we reject already configured devices.
Test we reject already configured devices.
async def test_already_configured(hass): """Test we reject already configured devices.""" MockConfigEntry( domain=DOMAIN, data=FIXTURE_USER_INPUT, title="Already configured" ).add_to_hass(hass) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config...
[ "async", "def", "test_already_configured", "(", "hass", ")", ":", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "FIXTURE_USER_INPUT", ",", "title", "=", "\"Already configured\"", ")", ".", "add_to_hass", "(", "hass", ")", "result", "=", "a...
[ 58, 0 ]
[ 75, 51 ]
python
en
['en', 'en', 'en']
True
test_connection_error
(hass, requests_mock)
Test we show user form on connection error.
Test we show user form on connection error.
async def test_connection_error(hass, requests_mock): """Test we show user form on connection error.""" requests_mock.request(ANY, ANY, exc=ConnectionError()) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=FIXTURE_USER_INPUT ) ...
[ "async", "def", "test_connection_error", "(", "hass", ",", "requests_mock", ")", ":", "requests_mock", ".", "request", "(", "ANY", ",", "ANY", ",", "exc", "=", "ConnectionError", "(", ")", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "f...
[ 78, 0 ]
[ 87, 52 ]
python
en
['en', 'en', 'en']
True
login_requests_mock
(requests_mock)
Set up a requests_mock with base mocks for login tests.
Set up a requests_mock with base mocks for login tests.
def login_requests_mock(requests_mock): """Set up a requests_mock with base mocks for login tests.""" requests_mock.request( ANY, FIXTURE_USER_INPUT[CONF_URL], text='<meta name="csrf_token" content="x"/>' ) requests_mock.request( ANY, f"{FIXTURE_USER_INPUT[CONF_URL]}api/user/stat...
[ "def", "login_requests_mock", "(", "requests_mock", ")", ":", "requests_mock", ".", "request", "(", "ANY", ",", "FIXTURE_USER_INPUT", "[", "CONF_URL", "]", ",", "text", "=", "'<meta name=\"csrf_token\" content=\"x\"/>'", ")", "requests_mock", ".", "request", "(", "A...
[ 91, 0 ]
[ 104, 24 ]
python
en
['en', 'da', 'en']
True
test_login_error
(hass, login_requests_mock, code, errors)
Test we show user form with appropriate error on response failure.
Test we show user form with appropriate error on response failure.
async def test_login_error(hass, login_requests_mock, code, errors): """Test we show user form with appropriate error on response failure.""" login_requests_mock.request( ANY, f"{FIXTURE_USER_INPUT[CONF_URL]}api/user/login", text=f"<error><code>{code}</code><message/></error>", ) ...
[ "async", "def", "test_login_error", "(", "hass", ",", "login_requests_mock", ",", "code", ",", "errors", ")", ":", "login_requests_mock", ".", "request", "(", "ANY", ",", "f\"{FIXTURE_USER_INPUT[CONF_URL]}api/user/login\"", ",", "text", "=", "f\"<error><code>{code}</cod...
[ 120, 0 ]
[ 133, 37 ]
python
en
['en', 'en', 'en']
True
test_success
(hass, login_requests_mock)
Test successful flow provides entry creation data.
Test successful flow provides entry creation data.
async def test_success(hass, login_requests_mock): """Test successful flow provides entry creation data.""" login_requests_mock.request( ANY, f"{FIXTURE_USER_INPUT[CONF_URL]}api/user/login", text="<response>OK</response>", ) with patch("homeassistant.components.huawei_lte.async_s...
[ "async", "def", "test_success", "(", "hass", ",", "login_requests_mock", ")", ":", "login_requests_mock", ".", "request", "(", "ANY", ",", "f\"{FIXTURE_USER_INPUT[CONF_URL]}api/user/login\"", ",", "text", "=", "\"<response>OK</response>\"", ",", ")", "with", "patch", ...
[ 136, 0 ]
[ 156, 77 ]
python
en
['en', 'en', 'en']
True
test_ssdp
(hass)
Test SSDP discovery initiates config properly.
Test SSDP discovery initiates config properly.
async def test_ssdp(hass): """Test SSDP discovery initiates config properly.""" url = "http://192.168.100.1/" context = {"source": config_entries.SOURCE_SSDP} result = await hass.config_entries.flow.async_init( DOMAIN, context=context, data={ ssdp.ATTR_SSDP_LOCATION: ...
[ "async", "def", "test_ssdp", "(", "hass", ")", ":", "url", "=", "\"http://192.168.100.1/\"", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_SSDP", "}", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init...
[ 159, 0 ]
[ 183, 35 ]
python
en
['en', 'en', 'en']
True
test_options
(hass)
Test options produce expected data.
Test options produce expected data.
async def test_options(hass): """Test options produce expected data.""" config_entry = MockConfigEntry( domain=DOMAIN, data=FIXTURE_USER_INPUT, options=FIXTURE_USER_INPUT_OPTIONS ) config_entry.add_to_hass(hass) result = await hass.config_entries.options.async_init(config_entry.entry_id) ...
[ "async", "def", "test_options", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "FIXTURE_USER_INPUT", ",", "options", "=", "FIXTURE_USER_INPUT_OPTIONS", ")", "config_entry", ".", "add_to_hass", "(", ...
[ 186, 0 ]
[ 203, 56 ]
python
en
['en', 'en', 'en']
True
log_entry
(hass, name, message, domain=None, entity_id=None, context=None)
Add an entry to the logbook.
Add an entry to the logbook.
def log_entry(hass, name, message, domain=None, entity_id=None, context=None): """Add an entry to the logbook.""" hass.add_job(async_log_entry, hass, name, message, domain, entity_id, context)
[ "def", "log_entry", "(", "hass", ",", "name", ",", "message", ",", "domain", "=", "None", ",", "entity_id", "=", "None", ",", "context", "=", "None", ")", ":", "hass", ".", "add_job", "(", "async_log_entry", ",", "hass", ",", "name", ",", "message", ...
[ 110, 0 ]
[ 112, 82 ]
python
en
['en', 'en', 'en']
True
async_log_entry
(hass, name, message, domain=None, entity_id=None, context=None)
Add an entry to the logbook.
Add an entry to the logbook.
def async_log_entry(hass, name, message, domain=None, entity_id=None, context=None): """Add an entry to the logbook.""" data = {ATTR_NAME: name, ATTR_MESSAGE: message} if domain is not None: data[ATTR_DOMAIN] = domain if entity_id is not None: data[ATTR_ENTITY_ID] = entity_id hass.b...
[ "def", "async_log_entry", "(", "hass", ",", "name", ",", "message", ",", "domain", "=", "None", ",", "entity_id", "=", "None", ",", "context", "=", "None", ")", ":", "data", "=", "{", "ATTR_NAME", ":", "name", ",", "ATTR_MESSAGE", ":", "message", "}", ...
[ 116, 0 ]
[ 124, 67 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Logbook setup.
Logbook setup.
async def async_setup(hass, config): """Logbook setup.""" hass.data[DOMAIN] = {} @callback def log_message(service): """Handle sending notification message service calls.""" message = service.data[ATTR_MESSAGE] name = service.data[ATTR_NAME] domain = service.data.get(ATT...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "@", "callback", "def", "log_message", "(", "service", ")", ":", "\"\"\"Handle sending notification message service calls.\"\"\"", "messa...
[ 127, 0 ]
[ 168, 15 ]
python
en
['en', 'bs', 'en']
False
_process_logbook_platform
(hass, domain, platform)
Process a logbook platform.
Process a logbook platform.
async def _process_logbook_platform(hass, domain, platform): """Process a logbook platform.""" @callback def _async_describe_event(domain, event_name, describe_callback): """Teach logbook how to describe a new event.""" hass.data[DOMAIN][event_name] = (domain, describe_callback) platfo...
[ "async", "def", "_process_logbook_platform", "(", "hass", ",", "domain", ",", "platform", ")", ":", "@", "callback", "def", "_async_describe_event", "(", "domain", ",", "event_name", ",", "describe_callback", ")", ":", "\"\"\"Teach logbook how to describe a new event.\"...
[ 171, 0 ]
[ 179, 63 ]
python
en
['en', 'lv', 'en']
True
humanify
(hass, events, entity_attr_cache, context_lookup)
Generate a converted list of events into Entry objects. Will try to group events if possible: - if 2+ sensor updates in GROUP_BY_MINUTES, show last - if Home Assistant stop and start happen in same minute call it restarted
Generate a converted list of events into Entry objects.
def humanify(hass, events, entity_attr_cache, context_lookup): """Generate a converted list of events into Entry objects. Will try to group events if possible: - if 2+ sensor updates in GROUP_BY_MINUTES, show last - if Home Assistant stop and start happen in same minute call it restarted """ ex...
[ "def", "humanify", "(", "hass", ",", "events", ",", "entity_attr_cache", ",", "context_lookup", ")", ":", "external_events", "=", "hass", ".", "data", ".", "get", "(", "DOMAIN", ",", "{", "}", ")", "# Group events in batches of GROUP_BY_MINUTES", "for", "_", "...
[ 252, 0 ]
[ 410, 26 ]
python
en
['en', 'en', 'en']
True
_get_events
( hass, start_day, end_day, entity_ids=None, filters=None, entities_filter=None, entity_matches_only=False, )
Get events for a period of time.
Get events for a period of time.
def _get_events( hass, start_day, end_day, entity_ids=None, filters=None, entities_filter=None, entity_matches_only=False, ): """Get events for a period of time.""" entity_attr_cache = EntityAttributeCache(hass) context_lookup = {None: None} def yield_events(query): ...
[ "def", "_get_events", "(", "hass", ",", "start_day", ",", "end_day", ",", "entity_ids", "=", "None", ",", "filters", "=", "None", ",", "entities_filter", "=", "None", ",", "entity_matches_only", "=", "False", ",", ")", ":", "entity_attr_cache", "=", "EntityA...
[ 413, 0 ]
[ 479, 9 ]
python
en
['en', 'en', 'en']
True
_entity_name_from_event
(entity_id, event, entity_attr_cache)
Extract the entity name from the event using the cache if possible.
Extract the entity name from the event using the cache if possible.
def _entity_name_from_event(entity_id, event, entity_attr_cache): """Extract the entity name from the event using the cache if possible.""" return entity_attr_cache.get( entity_id, ATTR_FRIENDLY_NAME, event ) or split_entity_id(entity_id)[1].replace("_", " ")
[ "def", "_entity_name_from_event", "(", "entity_id", ",", "event", ",", "entity_attr_cache", ")", ":", "return", "entity_attr_cache", ".", "get", "(", "entity_id", ",", "ATTR_FRIENDLY_NAME", ",", "event", ")", "or", "split_entity_id", "(", "entity_id", ")", "[", ...
[ 653, 0 ]
[ 657, 56 ]
python
en
['en', 'en', 'en']
True
LogbookView.__init__
(self, config, filters, entities_filter)
Initialize the logbook view.
Initialize the logbook view.
def __init__(self, config, filters, entities_filter): """Initialize the logbook view.""" self.config = config self.filters = filters self.entities_filter = entities_filter
[ "def", "__init__", "(", "self", ",", "config", ",", "filters", ",", "entities_filter", ")", ":", "self", ".", "config", "=", "config", "self", ".", "filters", "=", "filters", "self", ".", "entities_filter", "=", "entities_filter" ]
[ 189, 4 ]
[ 193, 46 ]
python
en
['en', 'en', 'en']
True
LogbookView.get
(self, request, datetime=None)
Retrieve logbook entries.
Retrieve logbook entries.
async def get(self, request, datetime=None): """Retrieve logbook entries.""" if datetime: datetime = dt_util.parse_datetime(datetime) if datetime is None: return self.json_message("Invalid datetime", HTTP_BAD_REQUEST) else: datetime = dt_util....
[ "async", "def", "get", "(", "self", ",", "request", ",", "datetime", "=", "None", ")", ":", "if", "datetime", ":", "datetime", "=", "dt_util", ".", "parse_datetime", "(", "datetime", ")", "if", "datetime", "is", "None", ":", "return", "self", ".", "jso...
[ 195, 4 ]
[ 249, 61 ]
python
en
['en', 'sk', 'en']
True
LazyEventPartialState.__init__
(self, row)
Init the lazy event.
Init the lazy event.
def __init__(self, row): """Init the lazy event.""" self._row = row self._event_data = None self._time_fired_isoformat = None self._attributes = None self.event_type = self._row.event_type self.entity_id = self._row.entity_id self.state = self._row.state ...
[ "def", "__init__", "(", "self", ",", "row", ")", ":", "self", ".", "_row", "=", "row", "self", ".", "_event_data", "=", "None", "self", ".", "_time_fired_isoformat", "=", "None", "self", ".", "_attributes", "=", "None", "self", ".", "event_type", "=", ...
[ 677, 4 ]
[ 689, 60 ]
python
en
['en', 'en', 'en']
True