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_show_form
(hass)
Test that the form is served with no input.
Test that the form is served with no input.
async def test_show_form(hass): """Test that the form is served with no input.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == SOURCE_USER
[ "async", "def", "test_show_form", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "assert", "result", "[", ...
[ 9, 0 ]
[ 16, 43 ]
python
en
['en', 'en', 'en']
True
test_invalid_credentials
(hass)
Test we handle invalid credentials.
Test we handle invalid credentials.
async def test_invalid_credentials(hass): """Test we handle invalid credentials.""" with patch( "poolsense.PoolSense.test_poolsense_credentials", return_value=False, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}...
[ "async", "def", "test_invalid_credentials", "(", "hass", ")", ":", "with", "patch", "(", "\"poolsense.PoolSense.test_poolsense_credentials\"", ",", "return_value", "=", "False", ",", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", "."...
[ 19, 0 ]
[ 32, 55 ]
python
en
['en', 'en', 'en']
True
test_valid_credentials
(hass)
Test we handle invalid credentials.
Test we handle invalid credentials.
async def test_valid_credentials(hass): """Test we handle invalid credentials.""" with patch( "poolsense.PoolSense.test_poolsense_credentials", return_value=True ), patch( "homeassistant.components.poolsense.async_setup", return_value=True ) as mock_setup, patch( "homeassistant.c...
[ "async", "def", "test_valid_credentials", "(", "hass", ")", ":", "with", "patch", "(", "\"poolsense.PoolSense.test_poolsense_credentials\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"homeassistant.components.poolsense.async_setup\"", ",", "return_value", ...
[ 35, 0 ]
[ 55, 48 ]
python
en
['en', 'en', 'en']
True
_cv_input_number
(cfg)
Configure validation helper for input number (voluptuous).
Configure validation helper for input number (voluptuous).
def _cv_input_number(cfg): """Configure validation helper for input number (voluptuous).""" minimum = cfg.get(CONF_MIN) maximum = cfg.get(CONF_MAX) if minimum >= maximum: raise vol.Invalid( f"Maximum ({minimum}) is not greater than minimum ({maximum})" ) state = cfg.get(C...
[ "def", "_cv_input_number", "(", "cfg", ")", ":", "minimum", "=", "cfg", ".", "get", "(", "CONF_MIN", ")", "maximum", "=", "cfg", ".", "get", "(", "CONF_MAX", ")", "if", "minimum", ">=", "maximum", ":", "raise", "vol", ".", "Invalid", "(", "f\"Maximum (...
[ 48, 0 ]
[ 59, 14 ]
python
en
['en', 'nl', 'en']
True
async_setup
(hass: HomeAssistantType, config: ConfigType)
Set up an input slider.
Set up an input slider.
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: """Set up an input slider.""" component = EntityComponent(_LOGGER, DOMAIN, hass) id_manager = collection.IDManager() yaml_collection = collection.YamlCollection( logging.getLogger(f"{__name__}.yaml_collection"), id_mana...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "component", "=", "EntityComponent", "(", "_LOGGER", ",", "DOMAIN", ",", "hass", ")", "id_manager", "=", "collection", ".", "IDMan...
[ 113, 0 ]
[ 173, 15 ]
python
en
['en', 'lb', 'en']
True
NumberStorageCollection._process_create_data
(self, data: typing.Dict)
Validate the config is valid.
Validate the config is valid.
async def _process_create_data(self, data: typing.Dict) -> typing.Dict: """Validate the config is valid.""" return self.CREATE_SCHEMA(data)
[ "async", "def", "_process_create_data", "(", "self", ",", "data", ":", "typing", ".", "Dict", ")", "->", "typing", ".", "Dict", ":", "return", "self", ".", "CREATE_SCHEMA", "(", "data", ")" ]
[ 182, 4 ]
[ 184, 39 ]
python
en
['en', 'en', 'en']
True
NumberStorageCollection._get_suggested_id
(self, info: typing.Dict)
Suggest an ID based on the config.
Suggest an ID based on the config.
def _get_suggested_id(self, info: typing.Dict) -> str: """Suggest an ID based on the config.""" return info[CONF_NAME]
[ "def", "_get_suggested_id", "(", "self", ",", "info", ":", "typing", ".", "Dict", ")", "->", "str", ":", "return", "info", "[", "CONF_NAME", "]" ]
[ 187, 4 ]
[ 189, 30 ]
python
en
['en', 'en', 'en']
True
NumberStorageCollection._update_data
(self, data: dict, update_data: typing.Dict)
Return a new updated data object.
Return a new updated data object.
async def _update_data(self, data: dict, update_data: typing.Dict) -> typing.Dict: """Return a new updated data object.""" update_data = self.UPDATE_SCHEMA(update_data) return _cv_input_number({**data, **update_data})
[ "async", "def", "_update_data", "(", "self", ",", "data", ":", "dict", ",", "update_data", ":", "typing", ".", "Dict", ")", "->", "typing", ".", "Dict", ":", "update_data", "=", "self", ".", "UPDATE_SCHEMA", "(", "update_data", ")", "return", "_cv_input_nu...
[ 191, 4 ]
[ 194, 56 ]
python
en
['en', 'en', 'en']
True
InputNumber.__init__
(self, config: typing.Dict)
Initialize an input number.
Initialize an input number.
def __init__(self, config: typing.Dict): """Initialize an input number.""" self._config = config self.editable = True self._current_value = config.get(CONF_INITIAL)
[ "def", "__init__", "(", "self", ",", "config", ":", "typing", ".", "Dict", ")", ":", "self", ".", "_config", "=", "config", "self", ".", "editable", "=", "True", "self", ".", "_current_value", "=", "config", ".", "get", "(", "CONF_INITIAL", ")" ]
[ 200, 4 ]
[ 204, 54 ]
python
en
['en', 'en', 'en']
True
InputNumber.from_yaml
(cls, config: typing.Dict)
Return entity instance initialized from yaml storage.
Return entity instance initialized from yaml storage.
def from_yaml(cls, config: typing.Dict) -> "InputNumber": """Return entity instance initialized from yaml storage.""" input_num = cls(config) input_num.entity_id = f"{DOMAIN}.{config[CONF_ID]}" input_num.editable = False return input_num
[ "def", "from_yaml", "(", "cls", ",", "config", ":", "typing", ".", "Dict", ")", "->", "\"InputNumber\"", ":", "input_num", "=", "cls", "(", "config", ")", "input_num", ".", "entity_id", "=", "f\"{DOMAIN}.{config[CONF_ID]}\"", "input_num", ".", "editable", "=",...
[ 207, 4 ]
[ 212, 24 ]
python
en
['en', 'pl', 'en']
True
InputNumber.should_poll
(self)
If entity should be polled.
If entity should be polled.
def should_poll(self): """If entity should be polled.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 215, 4 ]
[ 217, 20 ]
python
en
['en', 'en', 'en']
True
InputNumber._minimum
(self)
Return minimum allowed value.
Return minimum allowed value.
def _minimum(self) -> float: """Return minimum allowed value.""" return self._config[CONF_MIN]
[ "def", "_minimum", "(", "self", ")", "->", "float", ":", "return", "self", ".", "_config", "[", "CONF_MIN", "]" ]
[ 220, 4 ]
[ 222, 37 ]
python
de
['de', 'et', 'en']
False
InputNumber._maximum
(self)
Return maximum allowed value.
Return maximum allowed value.
def _maximum(self) -> float: """Return maximum allowed value.""" return self._config[CONF_MAX]
[ "def", "_maximum", "(", "self", ")", "->", "float", ":", "return", "self", ".", "_config", "[", "CONF_MAX", "]" ]
[ 225, 4 ]
[ 227, 37 ]
python
de
['de', 'la', 'en']
False
InputNumber.name
(self)
Return the name of the input slider.
Return the name of the input slider.
def name(self): """Return the name of the input slider.""" return self._config.get(CONF_NAME)
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_NAME", ")" ]
[ 230, 4 ]
[ 232, 42 ]
python
en
['en', 'en', 'en']
True
InputNumber.icon
(self)
Return the icon to be used for this entity.
Return the icon to be used for this entity.
def icon(self): """Return the icon to be used for this entity.""" return self._config.get(CONF_ICON)
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_ICON", ")" ]
[ 235, 4 ]
[ 237, 42 ]
python
en
['en', 'en', 'en']
True
InputNumber.state
(self)
Return the state of the component.
Return the state of the component.
def state(self): """Return the state of the component.""" return self._current_value
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_current_value" ]
[ 240, 4 ]
[ 242, 34 ]
python
en
['en', 'en', 'en']
True
InputNumber._step
(self)
Return entity's increment/decrement step.
Return entity's increment/decrement step.
def _step(self) -> int: """Return entity's increment/decrement step.""" return self._config[CONF_STEP]
[ "def", "_step", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_config", "[", "CONF_STEP", "]" ]
[ 245, 4 ]
[ 247, 38 ]
python
en
['nl', 'fr', 'en']
False
InputNumber.unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._config.get(ATTR_UNIT_OF_MEASUREMENT)
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "ATTR_UNIT_OF_MEASUREMENT", ")" ]
[ 250, 4 ]
[ 252, 57 ]
python
en
['en', 'en', 'en']
True
InputNumber.unique_id
(self)
Return unique id of the entity.
Return unique id of the entity.
def unique_id(self) -> typing.Optional[str]: """Return unique id of the entity.""" return self._config[CONF_ID]
[ "def", "unique_id", "(", "self", ")", "->", "typing", ".", "Optional", "[", "str", "]", ":", "return", "self", ".", "_config", "[", "CONF_ID", "]" ]
[ 255, 4 ]
[ 257, 36 ]
python
en
['en', 'en', 'en']
True
InputNumber.state_attributes
(self)
Return the state attributes.
Return the state attributes.
def state_attributes(self): """Return the state attributes.""" return { ATTR_INITIAL: self._config.get(CONF_INITIAL), ATTR_EDITABLE: self.editable, ATTR_MIN: self._minimum, ATTR_MAX: self._maximum, ATTR_STEP: self._step, ATTR_MODE: ...
[ "def", "state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_INITIAL", ":", "self", ".", "_config", ".", "get", "(", "CONF_INITIAL", ")", ",", "ATTR_EDITABLE", ":", "self", ".", "editable", ",", "ATTR_MIN", ":", "self", ".", "_minimum", ",", "A...
[ 260, 4 ]
[ 269, 9 ]
python
en
['en', 'en', 'en']
True
InputNumber.async_added_to_hass
(self)
Run when entity about to be added to hass.
Run when entity about to be added to hass.
async def async_added_to_hass(self): """Run when entity about to be added to hass.""" await super().async_added_to_hass() if self._current_value is not None: return state = await self.async_get_last_state() value = state and float(state.state) # Check agains...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "if", "self", ".", "_current_value", "is", "not", "None", ":", "return", "state", "=", "await", "self", ".", "async_get_last_state...
[ 271, 4 ]
[ 284, 47 ]
python
en
['en', 'en', 'en']
True
InputNumber.async_set_value
(self, value)
Set new value.
Set new value.
async def async_set_value(self, value): """Set new value.""" num_value = float(value) if num_value < self._minimum or num_value > self._maximum: raise vol.Invalid( f"Invalid value for {self.entity_id}: {value} (range {self._minimum} - {self._maximum})" ) ...
[ "async", "def", "async_set_value", "(", "self", ",", "value", ")", ":", "num_value", "=", "float", "(", "value", ")", "if", "num_value", "<", "self", ".", "_minimum", "or", "num_value", ">", "self", ".", "_maximum", ":", "raise", "vol", ".", "Invalid", ...
[ 286, 4 ]
[ 296, 35 ]
python
en
['en', 'yi', 'en']
True
InputNumber.async_increment
(self)
Increment value.
Increment value.
async def async_increment(self): """Increment value.""" await self.async_set_value(min(self._current_value + self._step, self._maximum))
[ "async", "def", "async_increment", "(", "self", ")", ":", "await", "self", ".", "async_set_value", "(", "min", "(", "self", ".", "_current_value", "+", "self", ".", "_step", ",", "self", ".", "_maximum", ")", ")" ]
[ 298, 4 ]
[ 300, 88 ]
python
en
['nl', 'la', 'en']
False
InputNumber.async_decrement
(self)
Decrement value.
Decrement value.
async def async_decrement(self): """Decrement value.""" await self.async_set_value(max(self._current_value - self._step, self._minimum))
[ "async", "def", "async_decrement", "(", "self", ")", ":", "await", "self", ".", "async_set_value", "(", "max", "(", "self", ".", "_current_value", "-", "self", ".", "_step", ",", "self", ".", "_minimum", ")", ")" ]
[ 302, 4 ]
[ 304, 88 ]
python
en
['nl', 'la', 'en']
False
InputNumber.async_update_config
(self, config: typing.Dict)
Handle when the config is updated.
Handle when the config is updated.
async def async_update_config(self, config: typing.Dict) -> None: """Handle when the config is updated.""" self._config = config # just in case min/max values changed self._current_value = min(self._current_value, self._maximum) self._current_value = max(self._current_value, self...
[ "async", "def", "async_update_config", "(", "self", ",", "config", ":", "typing", ".", "Dict", ")", "->", "None", ":", "self", ".", "_config", "=", "config", "# just in case min/max values changed", "self", ".", "_current_value", "=", "min", "(", "self", ".", ...
[ 306, 4 ]
[ 312, 35 ]
python
en
['en', 'en', 'en']
True
test_config_entry_not_ready
( mock_update: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the WLED configuration entry not ready.
Test the WLED configuration entry not ready.
async def test_config_entry_not_ready( mock_update: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the WLED configuration entry not ready.""" entry = await init_integration(hass, aioclient_mock) assert entry.state == ENTRY_STATE_SETUP_RETRY
[ "async", "def", "test_config_entry_not_ready", "(", "mock_update", ":", "MagicMock", ",", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "entry", "=", "await", "init_integration", "(", "hass", ",", "aioclie...
[ 13, 0 ]
[ 18, 49 ]
python
en
['en', 'en', 'en']
True
test_unload_config_entry
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the WLED configuration entry unloading.
Test the WLED configuration entry unloading.
async def test_unload_config_entry( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the WLED configuration entry unloading.""" entry = await init_integration(hass, aioclient_mock) assert hass.data[DOMAIN] await hass.config_entries.async_unload(entry.entry_id) await h...
[ "async", "def", "test_unload_config_entry", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "entry", "=", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ")", "assert", "hass", ".", "...
[ 21, 0 ]
[ 30, 36 ]
python
en
['en', 'en', 'en']
True
test_setting_unique_id
(hass, aioclient_mock)
Test we set unique ID if not set yet.
Test we set unique ID if not set yet.
async def test_setting_unique_id(hass, aioclient_mock): """Test we set unique ID if not set yet.""" entry = await init_integration(hass, aioclient_mock) assert hass.data[DOMAIN] assert entry.unique_id == "aabbccddeeff"
[ "async", "def", "test_setting_unique_id", "(", "hass", ",", "aioclient_mock", ")", ":", "entry", "=", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ")", "assert", "hass", ".", "data", "[", "DOMAIN", "]", "assert", "entry", ".", "unique_id", ...
[ 33, 0 ]
[ 38, 44 ]
python
en
['en', 'en', 'en']
True
time_zone
()
Fixture for time zone.
Fixture for time zone.
def time_zone(): """Fixture for time zone.""" return dt_util.get_time_zone("America/New_York")
[ "def", "time_zone", "(", ")", ":", "return", "dt_util", ".", "get_time_zone", "(", "\"America/New_York\"", ")" ]
[ 8, 0 ]
[ 10, 52 ]
python
en
['en', 'en', 'en']
True
test_time
(hass, time_zone)
Test the time at a different location.
Test the time at a different location.
async def test_time(hass, time_zone): """Test the time at a different location.""" config = {"sensor": {"platform": "worldclock", "time_zone": "America/New_York"}} assert await async_setup_component( hass, "sensor", config, ) await hass.async_block_till_done() state = h...
[ "async", "def", "test_time", "(", "hass", ",", "time_zone", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"worldclock\"", ",", "\"time_zone\"", ":", "\"America/New_York\"", "}", "}", "assert", "await", "async_setup_component", "(",...
[ 13, 0 ]
[ 27, 76 ]
python
en
['en', 'en', 'en']
True
test_time_format
(hass, time_zone)
Test time_format setting.
Test time_format setting.
async def test_time_format(hass, time_zone): """Test time_format setting.""" time_format = "%a, %b %d, %Y %I:%M %p" config = { "sensor": { "platform": "worldclock", "time_zone": "America/New_York", "time_format": time_format, } } assert await asyn...
[ "async", "def", "test_time_format", "(", "hass", ",", "time_zone", ")", ":", "time_format", "=", "\"%a, %b %d, %Y %I:%M %p\"", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"worldclock\"", ",", "\"time_zone\"", ":", "\"America/New_York\"", ",", ...
[ 30, 0 ]
[ 51, 80 ]
python
en
['da', 'en', 'en']
True
test_binary_sensor
(hass, requests_mock)
Test the Ring binary sensors.
Test the Ring binary sensors.
async def test_binary_sensor(hass, requests_mock): """Test the Ring binary sensors.""" with patch( "ring_doorbell.Ring.active_alerts", return_value=[ { "kind": "motion", "doorbot_id": 987654, "state": "ringing", "now": t...
[ "async", "def", "test_binary_sensor", "(", "hass", ",", "requests_mock", ")", ":", "with", "patch", "(", "\"ring_doorbell.Ring.active_alerts\"", ",", "return_value", "=", "[", "{", "\"kind\"", ":", "\"motion\"", ",", "\"doorbot_id\"", ":", "987654", ",", "\"state\...
[ 8, 0 ]
[ 31, 36 ]
python
en
['en', 'vi', 'en']
True
test_owserver_connect_failure
(hass)
Test connection failure raises ConfigEntryNotReady.
Test connection failure raises ConfigEntryNotReady.
async def test_owserver_connect_failure(hass): """Test connection failure raises ConfigEntryNotReady.""" config_entry_owserver = MockConfigEntry( domain=DOMAIN, source="user", data={ CONF_TYPE: CONF_TYPE_OWSERVER, CONF_HOST: "1.2.3.4", CONF_PORT: "1234...
[ "async", "def", "test_owserver_connect_failure", "(", "hass", ")", ":", "config_entry_owserver", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "source", "=", "\"user\"", ",", "data", "=", "{", "CONF_TYPE", ":", "CONF_TYPE_OWSERVER", ",", "CONF_HOST", ...
[ 18, 0 ]
[ 44, 36 ]
python
fr
['fr', 'fr', 'en']
True
test_failed_owserver_listing
(hass)
Create the 1-Wire integration.
Create the 1-Wire integration.
async def test_failed_owserver_listing(hass): """Create the 1-Wire integration.""" config_entry_owserver = MockConfigEntry( domain=DOMAIN, source="user", data={ CONF_TYPE: CONF_TYPE_OWSERVER, CONF_HOST: "1.2.3.4", CONF_PORT: "1234", }, ...
[ "async", "def", "test_failed_owserver_listing", "(", "hass", ")", ":", "config_entry_owserver", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "source", "=", "\"user\"", ",", "data", "=", "{", "CONF_TYPE", ":", "CONF_TYPE_OWSERVER", ",", "CONF_HOST", ...
[ 47, 0 ]
[ 69, 36 ]
python
en
['en', 'en', 'en']
True
test_unload_entry
(hass)
Test being able to unload an entry.
Test being able to unload an entry.
async def test_unload_entry(hass): """Test being able to unload an entry.""" config_entry_owserver = await setup_onewire_owserver_integration(hass) config_entry_sysbus = await setup_onewire_sysbus_integration(hass) assert len(hass.config_entries.async_entries(DOMAIN)) == 2 assert config_entry_owser...
[ "async", "def", "test_unload_entry", "(", "hass", ")", ":", "config_entry_owserver", "=", "await", "setup_onewire_owserver_integration", "(", "hass", ")", "config_entry_sysbus", "=", "await", "setup_onewire_sysbus_integration", "(", "hass", ")", "assert", "len", "(", ...
[ 72, 0 ]
[ 87, 36 ]
python
en
['en', 'en', 'en']
True
test_reproducing_states
(hass, caplog)
Test reproducing Timer states.
Test reproducing Timer states.
async def test_reproducing_states(hass, caplog): """Test reproducing Timer states.""" hass.states.async_set("timer.entity_idle", STATUS_IDLE, {}) hass.states.async_set("timer.entity_paused", STATUS_PAUSED, {}) hass.states.async_set("timer.entity_active", STATUS_ACTIVE, {}) hass.states.async_set( ...
[ "async", "def", "test_reproducing_states", "(", "hass", ",", "caplog", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"timer.entity_idle\"", ",", "STATUS_IDLE", ",", "{", "}", ")", "hass", ".", "states", ".", "async_set", "(", "\"timer.entity_paused...
[ 15, 0 ]
[ 82, 71 ]
python
en
['sv', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up PS4 from a config entry.
Set up PS4 from a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up PS4 from a config entry.""" config = config_entry creds = config.data[CONF_TOKEN] device_list = [] for device in config.data["devices"]: host = device[CONF_HOST] region = device[CONF_REGION] name =...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "config", "=", "config_entry", "creds", "=", "config", ".", "data", "[", "CONF_TOKEN", "]", "device_list", "=", "[", "]", "for", "device", "in", "conf...
[ 57, 0 ]
[ 68, 59 ]
python
en
['en', 'en', 'en']
True
PS4Device.__init__
(self, config, name, host, region, ps4, creds)
Initialize the ps4 device.
Initialize the ps4 device.
def __init__(self, config, name, host, region, ps4, creds): """Initialize the ps4 device.""" self._entry_id = config.entry_id self._ps4 = ps4 self._host = host self._name = name self._region = region self._creds = creds self._state = None self._med...
[ "def", "__init__", "(", "self", ",", "config", ",", "name", ",", "host", ",", "region", ",", "ps4", ",", "creds", ")", ":", "self", ".", "_entry_id", "=", "config", ".", "entry_id", "self", ".", "_ps4", "=", "ps4", "self", ".", "_host", "=", "host"...
[ 74, 4 ]
[ 93, 30 ]
python
en
['en', 'en', 'en']
True
PS4Device.status_callback
(self)
Handle status callback. Parse status.
Handle status callback. Parse status.
def status_callback(self): """Handle status callback. Parse status.""" self._parse_status() self.async_write_ha_state()
[ "def", "status_callback", "(", "self", ")", ":", "self", ".", "_parse_status", "(", ")", "self", ".", "async_write_ha_state", "(", ")" ]
[ 96, 4 ]
[ 99, 35 ]
python
en
['en', 'et', 'en']
True
PS4Device.subscribe_to_protocol
(self)
Notify protocol to callback with update changes.
Notify protocol to callback with update changes.
def subscribe_to_protocol(self): """Notify protocol to callback with update changes.""" self.hass.data[PS4_DATA].protocol.add_callback(self._ps4, self.status_callback)
[ "def", "subscribe_to_protocol", "(", "self", ")", ":", "self", ".", "hass", ".", "data", "[", "PS4_DATA", "]", ".", "protocol", ".", "add_callback", "(", "self", ".", "_ps4", ",", "self", ".", "status_callback", ")" ]
[ 102, 4 ]
[ 104, 87 ]
python
en
['en', 'en', 'en']
True
PS4Device.unsubscribe_to_protocol
(self)
Notify protocol to remove callback.
Notify protocol to remove callback.
def unsubscribe_to_protocol(self): """Notify protocol to remove callback.""" self.hass.data[PS4_DATA].protocol.remove_callback( self._ps4, self.status_callback )
[ "def", "unsubscribe_to_protocol", "(", "self", ")", ":", "self", ".", "hass", ".", "data", "[", "PS4_DATA", "]", ".", "protocol", ".", "remove_callback", "(", "self", ".", "_ps4", ",", "self", ".", "status_callback", ")" ]
[ 107, 4 ]
[ 111, 9 ]
python
en
['en', 'it', 'en']
True
PS4Device.check_region
(self)
Display logger msg if region is deprecated.
Display logger msg if region is deprecated.
def check_region(self): """Display logger msg if region is deprecated.""" # Non-Breaking although data returned may be inaccurate. if self._region in deprecated_regions: _LOGGER.info( """Region: %s has been deprecated. Please remove PS4 int...
[ "def", "check_region", "(", "self", ")", ":", "# Non-Breaking although data returned may be inaccurate.", "if", "self", ".", "_region", "in", "deprecated_regions", ":", "_LOGGER", ".", "info", "(", "\"\"\"Region: %s has been deprecated.\n Please remove ...
[ 113, 4 ]
[ 123, 13 ]
python
en
['en', 'en', 'en']
True
PS4Device.async_added_to_hass
(self)
Subscribe PS4 events.
Subscribe PS4 events.
async def async_added_to_hass(self): """Subscribe PS4 events.""" self.hass.data[PS4_DATA].devices.append(self) self.check_region()
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "hass", ".", "data", "[", "PS4_DATA", "]", ".", "devices", ".", "append", "(", "self", ")", "self", ".", "check_region", "(", ")" ]
[ 125, 4 ]
[ 128, 27 ]
python
en
['en', 'en', 'en']
True
PS4Device.async_update
(self)
Retrieve the latest data.
Retrieve the latest data.
async def async_update(self): """Retrieve the latest data.""" if self._ps4.ddp_protocol is not None: # Request Status with asyncio transport. self._ps4.get_status() # Don't attempt to connect if entity is connected or if, # PS4 is in standby or disconnect...
[ "async", "def", "async_update", "(", "self", ")", ":", "if", "self", ".", "_ps4", ".", "ddp_protocol", "is", "not", "None", ":", "# Request Status with asyncio transport.", "self", ".", "_ps4", ".", "get_status", "(", ")", "# Don't attempt to connect if entity is co...
[ 130, 4 ]
[ 158, 28 ]
python
en
['en', 'ga', 'en']
True
PS4Device._parse_status
(self)
Parse status.
Parse status.
def _parse_status(self): """Parse status.""" status = self._ps4.status if status is not None: self._games = load_games(self.hass, self._unique_id) if self._games: self.get_source_list() self._retry = 0 self._disconnected = False ...
[ "def", "_parse_status", "(", "self", ")", ":", "status", "=", "self", ".", "_ps4", ".", "status", "if", "status", "is", "not", "None", ":", "self", ".", "_games", "=", "load_games", "(", "self", ".", "hass", ",", "self", ".", "_unique_id", ")", "if",...
[ 160, 4 ]
[ 199, 28 ]
python
en
['en', 'la', 'en']
False
PS4Device._use_saved
(self)
Return True, Set media attrs if data is locked.
Return True, Set media attrs if data is locked.
def _use_saved(self) -> bool: """Return True, Set media attrs if data is locked.""" if self._media_content_id in self._games: store = self._games[self._media_content_id] # If locked get attributes from file. locked = store.get(ATTR_LOCKED) if locked: ...
[ "def", "_use_saved", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_media_content_id", "in", "self", ".", "_games", ":", "store", "=", "self", ".", "_games", "[", "self", ".", "_media_content_id", "]", "# If locked get attributes from file.", "locke...
[ 201, 4 ]
[ 214, 20 ]
python
en
['en', 'mt', 'en']
True
PS4Device.idle
(self)
Set states for state idle.
Set states for state idle.
def idle(self): """Set states for state idle.""" self.reset_title() self._state = STATE_IDLE
[ "def", "idle", "(", "self", ")", ":", "self", ".", "reset_title", "(", ")", "self", ".", "_state", "=", "STATE_IDLE" ]
[ 216, 4 ]
[ 219, 32 ]
python
en
['en', 'en', 'en']
True
PS4Device.state_standby
(self)
Set states for state standby.
Set states for state standby.
def state_standby(self): """Set states for state standby.""" self.reset_title() self._state = STATE_STANDBY
[ "def", "state_standby", "(", "self", ")", ":", "self", ".", "reset_title", "(", ")", "self", ".", "_state", "=", "STATE_STANDBY" ]
[ 221, 4 ]
[ 224, 35 ]
python
en
['en', 'en', 'en']
True
PS4Device.state_unknown
(self)
Set states for state unknown.
Set states for state unknown.
def state_unknown(self): """Set states for state unknown.""" self.reset_title() self._state = None if self._disconnected is False: _LOGGER.warning("PS4 could not be reached") self._disconnected = True self._retry = 0
[ "def", "state_unknown", "(", "self", ")", ":", "self", ".", "reset_title", "(", ")", "self", ".", "_state", "=", "None", "if", "self", ".", "_disconnected", "is", "False", ":", "_LOGGER", ".", "warning", "(", "\"PS4 could not be reached\"", ")", "self", "....
[ 226, 4 ]
[ 233, 23 ]
python
en
['en', 'en', 'en']
True
PS4Device.reset_title
(self)
Update if there is no title.
Update if there is no title.
def reset_title(self): """Update if there is no title.""" self._media_title = None self._media_content_id = None self._media_type = None self._source = None
[ "def", "reset_title", "(", "self", ")", ":", "self", ".", "_media_title", "=", "None", "self", ".", "_media_content_id", "=", "None", "self", ".", "_media_type", "=", "None", "self", ".", "_source", "=", "None" ]
[ 235, 4 ]
[ 240, 27 ]
python
en
['en', 'en', 'en']
True
PS4Device.async_get_title_data
(self, title_id, name)
Get PS Store Data.
Get PS Store Data.
async def async_get_title_data(self, title_id, name): """Get PS Store Data.""" app_name = None art = None media_type = None try: title = await self._ps4.async_get_ps_store_data( name, title_id, self._region ) except PSDataIncomple...
[ "async", "def", "async_get_title_data", "(", "self", ",", "title_id", ",", "name", ")", ":", "app_name", "=", "None", "art", "=", "None", "media_type", "=", "None", "try", ":", "title", "=", "await", "self", ".", "_ps4", ".", "async_get_ps_store_data", "("...
[ 242, 4 ]
[ 282, 39 ]
python
en
['en', 'en', 'en']
True
PS4Device.update_list
(self)
Update Game List, Correct data if different.
Update Game List, Correct data if different.
def update_list(self): """Update Game List, Correct data if different.""" if self._media_content_id in self._games: store = self._games[self._media_content_id] if ( store.get(ATTR_MEDIA_TITLE) != self._media_title or store.get(ATTR_MEDIA_IMAGE_URL...
[ "def", "update_list", "(", "self", ")", ":", "if", "self", ".", "_media_content_id", "in", "self", ".", "_games", ":", "store", "=", "self", ".", "_games", "[", "self", ".", "_media_content_id", "]", "if", "(", "store", ".", "get", "(", "ATTR_MEDIA_TITLE...
[ 284, 4 ]
[ 304, 30 ]
python
en
['de', 'en', 'en']
True
PS4Device.get_source_list
(self)
Parse data entry and update source list.
Parse data entry and update source list.
def get_source_list(self): """Parse data entry and update source list.""" games = [] for data in self._games.values(): games.append(data[ATTR_MEDIA_TITLE]) self._source_list = sorted(games)
[ "def", "get_source_list", "(", "self", ")", ":", "games", "=", "[", "]", "for", "data", "in", "self", ".", "_games", ".", "values", "(", ")", ":", "games", ".", "append", "(", "data", "[", "ATTR_MEDIA_TITLE", "]", ")", "self", ".", "_source_list", "=...
[ 306, 4 ]
[ 311, 41 ]
python
en
['en', 'en', 'en']
True
PS4Device.add_games
(self, title_id, app_name, image, g_type, is_locked=False)
Add games to list.
Add games to list.
def add_games(self, title_id, app_name, image, g_type, is_locked=False): """Add games to list.""" games = self._games if title_id is not None and title_id not in games: game = { title_id: { ATTR_MEDIA_TITLE: app_name, ATTR_MEDIA...
[ "def", "add_games", "(", "self", ",", "title_id", ",", "app_name", ",", "image", ",", "g_type", ",", "is_locked", "=", "False", ")", ":", "games", "=", "self", ".", "_games", "if", "title_id", "is", "not", "None", "and", "title_id", "not", "in", "games...
[ 313, 4 ]
[ 326, 57 ]
python
en
['en', 'en', 'en']
True
PS4Device.async_get_device_info
(self, status)
Set device info for registry.
Set device info for registry.
async def async_get_device_info(self, status): """Set device info for registry.""" # If cannot get status on startup, assume info from registry. if status is None: _LOGGER.info("Assuming status from registry") e_registry = await entity_registry.async_get_registry(self.has...
[ "async", "def", "async_get_device_info", "(", "self", ",", "status", ")", ":", "# If cannot get status on startup, assume info from registry.", "if", "status", "is", "None", ":", "_LOGGER", ".", "info", "(", "\"Assuming status from registry\"", ")", "e_registry", "=", "...
[ 328, 4 ]
[ 363, 78 ]
python
en
['fr', 'en', 'en']
True
PS4Device.async_will_remove_from_hass
(self)
Remove Entity from Home Assistant.
Remove Entity from Home Assistant.
async def async_will_remove_from_hass(self): """Remove Entity from Home Assistant.""" # Close TCP Transport. if self._ps4.connected: await self._ps4.close() self.unsubscribe_to_protocol() self.hass.data[PS4_DATA].devices.remove(self)
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "# Close TCP Transport.", "if", "self", ".", "_ps4", ".", "connected", ":", "await", "self", ".", "_ps4", ".", "close", "(", ")", "self", ".", "unsubscribe_to_protocol", "(", ")", "self", ...
[ 365, 4 ]
[ 371, 53 ]
python
en
['en', 'en', 'en']
True
PS4Device.device_info
(self)
Return information about the device.
Return information about the device.
def device_info(self): """Return information about the device.""" return self._info
[ "def", "device_info", "(", "self", ")", ":", "return", "self", ".", "_info" ]
[ 374, 4 ]
[ 376, 25 ]
python
en
['en', 'en', 'en']
True
PS4Device.unique_id
(self)
Return Unique ID for entity.
Return Unique ID for entity.
def unique_id(self): """Return Unique ID for entity.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 379, 4 ]
[ 381, 30 ]
python
en
['fr', 'en', 'en']
True
PS4Device.entity_picture
(self)
Return picture.
Return picture.
def entity_picture(self): """Return picture.""" if self._state == STATE_PLAYING and self._media_content_id is not None: image_hash = self.media_image_hash if image_hash is not None: return ( f"/api/media_player_proxy/{self.entity_id}?" ...
[ "def", "entity_picture", "(", "self", ")", ":", "if", "self", ".", "_state", "==", "STATE_PLAYING", "and", "self", ".", "_media_content_id", "is", "not", "None", ":", "image_hash", "=", "self", ".", "media_image_hash", "if", "image_hash", "is", "not", "None"...
[ 384, 4 ]
[ 393, 34 ]
python
en
['en', 'la', 'en']
False
PS4Device.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" ]
[ 396, 4 ]
[ 398, 25 ]
python
en
['en', 'en', 'en']
True
PS4Device.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" ]
[ 401, 4 ]
[ 403, 26 ]
python
en
['en', 'en', 'en']
True
PS4Device.media_content_id
(self)
Content ID of current playing media.
Content ID of current playing media.
def media_content_id(self): """Content ID of current playing media.""" return self._media_content_id
[ "def", "media_content_id", "(", "self", ")", ":", "return", "self", ".", "_media_content_id" ]
[ 411, 4 ]
[ 413, 37 ]
python
en
['en', 'en', 'en']
True
PS4Device.media_content_type
(self)
Content type of current playing media.
Content type of current playing media.
def media_content_type(self): """Content type of current playing media.""" return self._media_type
[ "def", "media_content_type", "(", "self", ")", ":", "return", "self", ".", "_media_type" ]
[ 416, 4 ]
[ 418, 31 ]
python
en
['en', 'en', 'en']
True
PS4Device.media_image_url
(self)
Image url of current playing media.
Image url of current playing media.
def media_image_url(self): """Image url of current playing media.""" if self._media_content_id is None: return MEDIA_IMAGE_DEFAULT return self._media_image
[ "def", "media_image_url", "(", "self", ")", ":", "if", "self", ".", "_media_content_id", "is", "None", ":", "return", "MEDIA_IMAGE_DEFAULT", "return", "self", ".", "_media_image" ]
[ 421, 4 ]
[ 425, 32 ]
python
en
['en', 'en', 'en']
True
PS4Device.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" return self._media_title
[ "def", "media_title", "(", "self", ")", ":", "return", "self", ".", "_media_title" ]
[ 428, 4 ]
[ 430, 32 ]
python
en
['en', 'en', 'en']
True
PS4Device.supported_features
(self)
Media player features that are supported.
Media player features that are supported.
def supported_features(self): """Media player features that are supported.""" return SUPPORT_PS4
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_PS4" ]
[ 433, 4 ]
[ 435, 26 ]
python
en
['en', 'en', 'en']
True
PS4Device.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" ]
[ 438, 4 ]
[ 440, 27 ]
python
en
['en', 'en', 'en']
True
PS4Device.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" ]
[ 443, 4 ]
[ 445, 32 ]
python
en
['en', 'en', 'en']
True
PS4Device.async_turn_off
(self)
Turn off media player.
Turn off media player.
async def async_turn_off(self): """Turn off media player.""" await self._ps4.standby()
[ "async", "def", "async_turn_off", "(", "self", ")", ":", "await", "self", ".", "_ps4", ".", "standby", "(", ")" ]
[ 447, 4 ]
[ 449, 33 ]
python
en
['en', 'en', 'en']
True
PS4Device.async_turn_on
(self)
Turn on the media player.
Turn on the media player.
async def async_turn_on(self): """Turn on the media player.""" self._ps4.wakeup()
[ "async", "def", "async_turn_on", "(", "self", ")", ":", "self", ".", "_ps4", ".", "wakeup", "(", ")" ]
[ 451, 4 ]
[ 453, 26 ]
python
en
['en', 'en', 'en']
True
PS4Device.async_toggle
(self)
Toggle media player.
Toggle media player.
async def async_toggle(self): """Toggle media player.""" await self._ps4.toggle()
[ "async", "def", "async_toggle", "(", "self", ")", ":", "await", "self", ".", "_ps4", ".", "toggle", "(", ")" ]
[ 455, 4 ]
[ 457, 32 ]
python
en
['fr', 'en', 'en']
True
PS4Device.async_media_pause
(self)
Send keypress ps to return to menu.
Send keypress ps to return to menu.
async def async_media_pause(self): """Send keypress ps to return to menu.""" await self.async_send_remote_control("ps")
[ "async", "def", "async_media_pause", "(", "self", ")", ":", "await", "self", ".", "async_send_remote_control", "(", "\"ps\"", ")" ]
[ 459, 4 ]
[ 461, 50 ]
python
en
['en', 'mt', 'en']
True
PS4Device.async_media_stop
(self)
Send keypress ps to return to menu.
Send keypress ps to return to menu.
async def async_media_stop(self): """Send keypress ps to return to menu.""" await self.async_send_remote_control("ps")
[ "async", "def", "async_media_stop", "(", "self", ")", ":", "await", "self", ".", "async_send_remote_control", "(", "\"ps\"", ")" ]
[ 463, 4 ]
[ 465, 50 ]
python
en
['en', 'mt', 'en']
True
PS4Device.async_select_source
(self, source)
Select input source.
Select input source.
async def async_select_source(self, source): """Select input source.""" for title_id, data in self._games.items(): game = data[ATTR_MEDIA_TITLE] if ( source.lower().encode(encoding="utf-8") == game.lower().encode(encoding="utf-8") o...
[ "async", "def", "async_select_source", "(", "self", ",", "source", ")", ":", "for", "title_id", ",", "data", "in", "self", ".", "_games", ".", "items", "(", ")", ":", "game", "=", "data", "[", "ATTR_MEDIA_TITLE", "]", "if", "(", "source", ".", "lower",...
[ 467, 4 ]
[ 485, 14 ]
python
en
['fr', 'su', 'en']
False
PS4Device.async_send_command
(self, command)
Send Button Command.
Send Button Command.
async def async_send_command(self, command): """Send Button Command.""" await self.async_send_remote_control(command)
[ "async", "def", "async_send_command", "(", "self", ",", "command", ")", ":", "await", "self", ".", "async_send_remote_control", "(", "command", ")" ]
[ 487, 4 ]
[ 489, 53 ]
python
en
['en', 'it', 'en']
True
PS4Device.async_send_remote_control
(self, command)
Send RC command.
Send RC command.
async def async_send_remote_control(self, command): """Send RC command.""" await self._ps4.remote_control(command)
[ "async", "def", "async_send_remote_control", "(", "self", ",", "command", ")", ":", "await", "self", ".", "_ps4", ".", "remote_control", "(", "command", ")" ]
[ 491, 4 ]
[ 493, 47 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Queensland Bushfire Alert Feed platform.
Set up the Queensland Bushfire Alert Feed platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Queensland Bushfire Alert Feed platform.""" scan_interval = config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL) coordinates = ( config.get(CONF_LATITUDE, hass.config.latitude), config.get(CONF_LONGITUDE, hass.config...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "scan_interval", "=", "config", ".", "get", "(", "CONF_SCAN_INTERVAL", ",", "SCAN_INTERVAL", ")", "coordinates", "=", "(", "config", ".", ...
[ 62, 0 ]
[ 80, 71 ]
python
en
['en', 'da', 'en']
True
QldBushfireFeedEntityManager.__init__
( self, hass, add_entities, scan_interval, coordinates, radius_in_km, categories )
Initialize the Feed Entity Manager.
Initialize the Feed Entity Manager.
def __init__( self, hass, add_entities, scan_interval, coordinates, radius_in_km, categories ): """Initialize the Feed Entity Manager.""" self._hass = hass self._feed_manager = QldBushfireAlertFeedManager( self._generate_entity, self._update_entity, ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "add_entities", ",", "scan_interval", ",", "coordinates", ",", "radius_in_km", ",", "categories", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_feed_manager", "=", "QldBushfireAlertFeedManager", "...
[ 86, 4 ]
[ 100, 43 ]
python
en
['en', 'en', 'en']
True
QldBushfireFeedEntityManager.startup
(self)
Start up this manager.
Start up this manager.
def startup(self): """Start up this manager.""" self._feed_manager.update() self._init_regular_updates()
[ "def", "startup", "(", "self", ")", ":", "self", ".", "_feed_manager", ".", "update", "(", ")", "self", ".", "_init_regular_updates", "(", ")" ]
[ 102, 4 ]
[ 105, 36 ]
python
en
['en', 'en', 'en']
True
QldBushfireFeedEntityManager._init_regular_updates
(self)
Schedule regular updates at the specified interval.
Schedule regular updates at the specified interval.
def _init_regular_updates(self): """Schedule regular updates at the specified interval.""" track_time_interval( self._hass, lambda now: self._feed_manager.update(), self._scan_interval )
[ "def", "_init_regular_updates", "(", "self", ")", ":", "track_time_interval", "(", "self", ".", "_hass", ",", "lambda", "now", ":", "self", ".", "_feed_manager", ".", "update", "(", ")", ",", "self", ".", "_scan_interval", ")" ]
[ 107, 4 ]
[ 111, 9 ]
python
en
['en', 'en', 'en']
True
QldBushfireFeedEntityManager.get_entry
(self, external_id)
Get feed entry by external id.
Get feed entry by external id.
def get_entry(self, external_id): """Get feed entry by external id.""" return self._feed_manager.feed_entries.get(external_id)
[ "def", "get_entry", "(", "self", ",", "external_id", ")", ":", "return", "self", ".", "_feed_manager", ".", "feed_entries", ".", "get", "(", "external_id", ")" ]
[ 113, 4 ]
[ 115, 63 ]
python
en
['en', 'en', 'en']
True
QldBushfireFeedEntityManager._generate_entity
(self, external_id)
Generate new entity.
Generate new entity.
def _generate_entity(self, external_id): """Generate new entity.""" new_entity = QldBushfireLocationEvent(self, external_id) # Add new entities to HA. self._add_entities([new_entity], True)
[ "def", "_generate_entity", "(", "self", ",", "external_id", ")", ":", "new_entity", "=", "QldBushfireLocationEvent", "(", "self", ",", "external_id", ")", "# Add new entities to HA.", "self", ".", "_add_entities", "(", "[", "new_entity", "]", ",", "True", ")" ]
[ 117, 4 ]
[ 121, 46 ]
python
en
['en', 'en', 'en']
True
QldBushfireFeedEntityManager._update_entity
(self, external_id)
Update entity.
Update entity.
def _update_entity(self, external_id): """Update entity.""" dispatcher_send(self._hass, SIGNAL_UPDATE_ENTITY.format(external_id))
[ "def", "_update_entity", "(", "self", ",", "external_id", ")", ":", "dispatcher_send", "(", "self", ".", "_hass", ",", "SIGNAL_UPDATE_ENTITY", ".", "format", "(", "external_id", ")", ")" ]
[ 123, 4 ]
[ 125, 77 ]
python
en
['es', 'en', 'en']
False
QldBushfireFeedEntityManager._remove_entity
(self, external_id)
Remove entity.
Remove entity.
def _remove_entity(self, external_id): """Remove entity.""" dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(external_id))
[ "def", "_remove_entity", "(", "self", ",", "external_id", ")", ":", "dispatcher_send", "(", "self", ".", "_hass", ",", "SIGNAL_DELETE_ENTITY", ".", "format", "(", "external_id", ")", ")" ]
[ 127, 4 ]
[ 129, 77 ]
python
en
['es', 'it', 'en']
False
QldBushfireLocationEvent.__init__
(self, feed_manager, external_id)
Initialize entity with data from feed entry.
Initialize entity with data from feed entry.
def __init__(self, feed_manager, external_id): """Initialize entity with data from feed entry.""" self._feed_manager = feed_manager self._external_id = external_id self._name = None self._distance = None self._latitude = None self._longitude = None self._a...
[ "def", "__init__", "(", "self", ",", "feed_manager", ",", "external_id", ")", ":", "self", ".", "_feed_manager", "=", "feed_manager", "self", ".", "_external_id", "=", "external_id", "self", ".", "_name", "=", "None", "self", ".", "_distance", "=", "None", ...
[ 135, 4 ]
[ 149, 41 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent.async_added_to_hass
(self)
Call when entity is added to hass.
Call when entity is added to hass.
async def async_added_to_hass(self): """Call when entity is added to hass.""" self._remove_signal_delete = async_dispatcher_connect( self.hass, SIGNAL_DELETE_ENTITY.format(self._external_id), self._delete_callback, ) self._remove_signal_update = async_...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_remove_signal_delete", "=", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "SIGNAL_DELETE_ENTITY", ".", "format", "(", "self", ".", "_external_id", ")", ",", "self", ".", ...
[ 151, 4 ]
[ 162, 9 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent._delete_callback
(self)
Remove this entity.
Remove this entity.
def _delete_callback(self): """Remove this entity.""" self._remove_signal_delete() self._remove_signal_update() self.hass.async_create_task(self.async_remove())
[ "def", "_delete_callback", "(", "self", ")", ":", "self", ".", "_remove_signal_delete", "(", ")", "self", ".", "_remove_signal_update", "(", ")", "self", ".", "hass", ".", "async_create_task", "(", "self", ".", "async_remove", "(", ")", ")" ]
[ 165, 4 ]
[ 169, 56 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent._update_callback
(self)
Call update method.
Call update method.
def _update_callback(self): """Call update method.""" self.async_schedule_update_ha_state(True)
[ "def", "_update_callback", "(", "self", ")", ":", "self", ".", "async_schedule_update_ha_state", "(", "True", ")" ]
[ 172, 4 ]
[ 174, 49 ]
python
en
['en', 'sn', 'en']
True
QldBushfireLocationEvent.should_poll
(self)
No polling needed for Qld Bushfire Alert feed location events.
No polling needed for Qld Bushfire Alert feed location events.
def should_poll(self): """No polling needed for Qld Bushfire Alert feed location events.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 177, 4 ]
[ 179, 20 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent.async_update
(self)
Update this entity from the data held in the feed manager.
Update this entity from the data held in the feed manager.
async def async_update(self): """Update this entity from the data held in the feed manager.""" _LOGGER.debug("Updating %s", self._external_id) feed_entry = self._feed_manager.get_entry(self._external_id) if feed_entry: self._update_from_feed(feed_entry)
[ "async", "def", "async_update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating %s\"", ",", "self", ".", "_external_id", ")", "feed_entry", "=", "self", ".", "_feed_manager", ".", "get_entry", "(", "self", ".", "_external_id", ")", "if", "...
[ 181, 4 ]
[ 186, 46 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent._update_from_feed
(self, feed_entry)
Update the internal state from the provided feed entry.
Update the internal state from the provided feed entry.
def _update_from_feed(self, feed_entry): """Update the internal state from the provided feed entry.""" self._name = feed_entry.title self._distance = feed_entry.distance_to_home self._latitude = feed_entry.coordinates[0] self._longitude = feed_entry.coordinates[1] self._a...
[ "def", "_update_from_feed", "(", "self", ",", "feed_entry", ")", ":", "self", ".", "_name", "=", "feed_entry", ".", "title", "self", ".", "_distance", "=", "feed_entry", ".", "distance_to_home", "self", ".", "_latitude", "=", "feed_entry", ".", "coordinates", ...
[ 188, 4 ]
[ 198, 40 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent.icon
(self)
Return the icon to use in the frontend.
Return the icon to use in the frontend.
def icon(self): """Return the icon to use in the frontend.""" return "mdi:fire"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:fire\"" ]
[ 201, 4 ]
[ 203, 25 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent.source
(self)
Return source value of this external event.
Return source value of this external event.
def source(self) -> str: """Return source value of this external event.""" return SOURCE
[ "def", "source", "(", "self", ")", "->", "str", ":", "return", "SOURCE" ]
[ 206, 4 ]
[ 208, 21 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self) -> Optional[str]: """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_name" ]
[ 211, 4 ]
[ 213, 25 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent.distance
(self)
Return distance value of this external event.
Return distance value of this external event.
def distance(self) -> Optional[float]: """Return distance value of this external event.""" return self._distance
[ "def", "distance", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "self", ".", "_distance" ]
[ 216, 4 ]
[ 218, 29 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent.latitude
(self)
Return latitude value of this external event.
Return latitude value of this external event.
def latitude(self) -> Optional[float]: """Return latitude value of this external event.""" return self._latitude
[ "def", "latitude", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "self", ".", "_latitude" ]
[ 221, 4 ]
[ 223, 29 ]
python
en
['en', 'la', 'en']
True
QldBushfireLocationEvent.longitude
(self)
Return longitude value of this external event.
Return longitude value of this external event.
def longitude(self) -> Optional[float]: """Return longitude value of this external event.""" return self._longitude
[ "def", "longitude", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "self", ".", "_longitude" ]
[ 226, 4 ]
[ 228, 30 ]
python
en
['en', 'en', 'en']
True
QldBushfireLocationEvent.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 LENGTH_KILOMETERS
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "LENGTH_KILOMETERS" ]
[ 231, 4 ]
[ 233, 32 ]
python
en
['en', 'la', 'en']
True
QldBushfireLocationEvent.device_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def device_state_attributes(self): """Return the device state attributes.""" attributes = {} for key, value in ( (ATTR_EXTERNAL_ID, self._external_id), (ATTR_CATEGORY, self._category), (ATTR_ATTRIBUTION, self._attribution), (ATTR_PUBLICATION_DATE, ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "}", "for", "key", ",", "value", "in", "(", "(", "ATTR_EXTERNAL_ID", ",", "self", ".", "_external_id", ")", ",", "(", "ATTR_CATEGORY", ",", "self", ".", "_category", ")", ",...
[ 236, 4 ]
[ 249, 25 ]
python
en
['en', 'en', 'en']
True
TestDashboard.test_get_sample_ratio_selection_list
(self)
Test method get_sample_ratio_selection_list(a)
Test method get_sample_ratio_selection_list(a)
def test_get_sample_ratio_selection_list(self): """Test method get_sample_ratio_selection_list(a)""" self.assertEqual( [0.0, 0.2, 0.4, 0.6, 0.8, 1.0], get_sample_ratio_selection_list(5) )
[ "def", "test_get_sample_ratio_selection_list", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "[", "0.0", ",", "0.2", ",", "0.4", ",", "0.6", ",", "0.8", ",", "1.0", "]", ",", "get_sample_ratio_selection_list", "(", "5", ")", ")" ]
[ 10, 4 ]
[ 15, 9 ]
python
en
['de', 'en', 'en']
True