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
GlowRing.device_info
(self)
Return the device info.
Return the device info.
def device_info(self): """Return the device info.""" return { "name": self.name, "identifiers": {(DOMAIN, self.unique_id)}, "model": "Glow Ring", "manufacturer": "Plum", }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"name\"", ":", "self", ".", "name", ",", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "unique_id", ")", "}", ",", "\"model\"", ":", "\"Glow Ring\"", ",", "\"manufacturer\"", "...
[ 187, 4 ]
[ 194, 9 ]
python
en
['en', 'en', 'en']
True
GlowRing.brightness
(self)
Return the brightness of this switch between 0..255.
Return the brightness of this switch between 0..255.
def brightness(self) -> int: """Return the brightness of this switch between 0..255.""" return min(max(int(round(self._glow_intensity * 255, 0)), 0), 255)
[ "def", "brightness", "(", "self", ")", "->", "int", ":", "return", "min", "(", "max", "(", "int", "(", "round", "(", "self", ".", "_glow_intensity", "*", "255", ",", "0", ")", ")", ",", "0", ")", ",", "255", ")" ]
[ 197, 4 ]
[ 199, 74 ]
python
en
['en', 'en', 'en']
True
GlowRing.glow_intensity
(self)
Brightness in float form.
Brightness in float form.
def glow_intensity(self): """Brightness in float form.""" return self._glow_intensity
[ "def", "glow_intensity", "(", "self", ")", ":", "return", "self", ".", "_glow_intensity" ]
[ 202, 4 ]
[ 204, 35 ]
python
en
['en', 'en', 'en']
True
GlowRing.is_on
(self)
Return true if light is on.
Return true if light is on.
def is_on(self) -> bool: """Return true if light is on.""" return self._state
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_state" ]
[ 207, 4 ]
[ 209, 26 ]
python
en
['en', 'et', 'en']
True
GlowRing.icon
(self)
Return the crop-portrait icon representing the glow ring.
Return the crop-portrait icon representing the glow ring.
def icon(self): """Return the crop-portrait icon representing the glow ring.""" return "mdi:crop-portrait"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:crop-portrait\"" ]
[ 212, 4 ]
[ 214, 34 ]
python
en
['en', 'en', 'en']
True
GlowRing.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_BRIGHTNESS | SUPPORT_COLOR
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_COLOR" ]
[ 217, 4 ]
[ 219, 49 ]
python
en
['da', 'en', 'en']
True
GlowRing.async_turn_on
(self, **kwargs)
Turn the light on.
Turn the light on.
async def async_turn_on(self, **kwargs): """Turn the light on.""" if ATTR_BRIGHTNESS in kwargs: brightness_pct = kwargs[ATTR_BRIGHTNESS] / 255.0 await self._lightpad.set_config({"glowIntensity": brightness_pct}) elif ATTR_HS_COLOR in kwargs: hs_color = kwargs[...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_BRIGHTNESS", "in", "kwargs", ":", "brightness_pct", "=", "kwargs", "[", "ATTR_BRIGHTNESS", "]", "/", "255.0", "await", "self", ".", "_lightpad", ".", "set_config", ...
[ 221, 4 ]
[ 231, 66 ]
python
en
['en', 'et', 'en']
True
GlowRing.async_turn_off
(self, **kwargs)
Turn the light off.
Turn the light off.
async def async_turn_off(self, **kwargs): """Turn the light off.""" if ATTR_BRIGHTNESS in kwargs: brightness_pct = kwargs[ATTR_BRIGHTNESS] / 255.0 await self._lightpad.set_config({"glowIntensity": brightness_pct}) else: await self._lightpad.set_config({"glowEn...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_BRIGHTNESS", "in", "kwargs", ":", "brightness_pct", "=", "kwargs", "[", "ATTR_BRIGHTNESS", "]", "/", "255.0", "await", "self", ".", "_lightpad", ".", "set_config", ...
[ 233, 4 ]
[ 239, 67 ]
python
en
['en', 'zh', 'en']
True
setup_comp
(hass)
Set up demo component.
Set up demo component.
async def setup_comp(hass): """Set up demo component.""" assert await async_setup_component( hass, SWITCH_DOMAIN, {SWITCH_DOMAIN: {"platform": DOMAIN}} ) await hass.async_block_till_done()
[ "async", "def", "setup_comp", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "SWITCH_DOMAIN", ",", "{", "SWITCH_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", "}", "}", ")", "await", "hass", ".", "async_block_till_done"...
[ 16, 0 ]
[ 21, 38 ]
python
en
['en', 'da', 'en']
True
test_turn_on
(hass, switch_entity_id)
Test switch turn on method.
Test switch turn on method.
async def test_turn_on(hass, switch_entity_id): """Test switch turn on method.""" await hass.services.async_call( SWITCH_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: switch_entity_id}, blocking=True, ) state = hass.states.get(switch_entity_id) assert state.state == STA...
[ "async", "def", "test_turn_on", "(", "hass", ",", "switch_entity_id", ")", ":", "await", "hass", ".", "services", ".", "async_call", "(", "SWITCH_DOMAIN", ",", "SERVICE_TURN_OFF", ",", "{", "ATTR_ENTITY_ID", ":", "switch_entity_id", "}", ",", "blocking", "=", ...
[ 25, 0 ]
[ 45, 34 ]
python
en
['en', 'en', 'en']
True
test_turn_off
(hass, switch_entity_id)
Test switch turn off method.
Test switch turn off method.
async def test_turn_off(hass, switch_entity_id): """Test switch turn off method.""" await hass.services.async_call( SWITCH_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: switch_entity_id}, blocking=True, ) state = hass.states.get(switch_entity_id) assert state.state == ST...
[ "async", "def", "test_turn_off", "(", "hass", ",", "switch_entity_id", ")", ":", "await", "hass", ".", "services", ".", "async_call", "(", "SWITCH_DOMAIN", ",", "SERVICE_TURN_ON", ",", "{", "ATTR_ENTITY_ID", ":", "switch_entity_id", "}", ",", "blocking", "=", ...
[ 49, 0 ]
[ 69, 35 ]
python
en
['en', 'en', 'en']
True
test_turn_off_without_entity_id
(hass, switch_entity_id)
Test switch turn off all switches.
Test switch turn off all switches.
async def test_turn_off_without_entity_id(hass, switch_entity_id): """Test switch turn off all switches.""" await hass.services.async_call( SWITCH_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: "all"}, blocking=True ) state = hass.states.get(switch_entity_id) assert state.state == STATE_ON ...
[ "async", "def", "test_turn_off_without_entity_id", "(", "hass", ",", "switch_entity_id", ")", ":", "await", "hass", ".", "services", ".", "async_call", "(", "SWITCH_DOMAIN", ",", "SERVICE_TURN_ON", ",", "{", "ATTR_ENTITY_ID", ":", "\"all\"", "}", ",", "blocking", ...
[ 73, 0 ]
[ 87, 35 ]
python
en
['en', 'en', 'en']
True
test_cleanup_orphaned_devices
(hass, entry, setup_plex_server)
Test cleaning up orphaned devices on startup.
Test cleaning up orphaned devices on startup.
async def test_cleanup_orphaned_devices(hass, entry, setup_plex_server): """Test cleaning up orphaned devices on startup.""" test_device_id = {(DOMAIN, "temporary_device_123")} device_registry = await hass.helpers.device_registry.async_get_registry() entity_registry = await hass.helpers.entity_registry...
[ "async", "def", "test_cleanup_orphaned_devices", "(", "hass", ",", "entry", ",", "setup_plex_server", ")", ":", "test_device_id", "=", "{", "(", "DOMAIN", ",", "\"temporary_device_123\"", ")", "}", "device_registry", "=", "await", "hass", ".", "helpers", ".", "d...
[ 6, 0 ]
[ 35, 25 ]
python
en
['en', 'en', 'en']
True
test_migrate_transient_devices
( hass, entry, setup_plex_server, requests_mock, player_plexweb_resources )
Test cleaning up transient devices on startup.
Test cleaning up transient devices on startup.
async def test_migrate_transient_devices( hass, entry, setup_plex_server, requests_mock, player_plexweb_resources ): """Test cleaning up transient devices on startup.""" plexweb_device_id = {(DOMAIN, "plexweb_id")} non_plexweb_device_id = {(DOMAIN, "1234567890123456-com-plexapp-android")} plex_clien...
[ "async", "def", "test_migrate_transient_devices", "(", "hass", ",", "entry", ",", "setup_plex_server", ",", "requests_mock", ",", "player_plexweb_resources", ")", ":", "plexweb_device_id", "=", "{", "(", "DOMAIN", ",", "\"plexweb_id\"", ")", "}", "non_plexweb_device_i...
[ 38, 0 ]
[ 136, 5 ]
python
en
['en', 'en', 'en']
True
test_mapping_integrity
()
Test ensures the map dicts have proper integrity.
Test ensures the map dicts have proper integrity.
async def test_mapping_integrity(): """Test ensures the map dicts have proper integrity.""" for capability, maps in sensor.CAPABILITY_TO_SENSORS.items(): assert capability in CAPABILITIES, capability for sensor_map in maps: assert sensor_map.attribute in ATTRIBUTES, sensor_map.attrib...
[ "async", "def", "test_mapping_integrity", "(", ")", ":", "for", "capability", ",", "maps", "in", "sensor", ".", "CAPABILITY_TO_SENSORS", ".", "items", "(", ")", ":", "assert", "capability", "in", "CAPABILITIES", ",", "capability", "for", "sensor_map", "in", "m...
[ 29, 0 ]
[ 40, 86 ]
python
en
['en', 'en', 'en']
True
test_entity_state
(hass, device_factory)
Tests the state attributes properly match the sensor types.
Tests the state attributes properly match the sensor types.
async def test_entity_state(hass, device_factory): """Tests the state attributes properly match the sensor types.""" device = device_factory("Sensor 1", [Capability.battery], {Attribute.battery: 100}) await setup_platform(hass, SENSOR_DOMAIN, devices=[device]) state = hass.states.get("sensor.sensor_1_ba...
[ "async", "def", "test_entity_state", "(", "hass", ",", "device_factory", ")", ":", "device", "=", "device_factory", "(", "\"Sensor 1\"", ",", "[", "Capability", ".", "battery", "]", ",", "{", "Attribute", ".", "battery", ":", "100", "}", ")", "await", "set...
[ 43, 0 ]
[ 50, 76 ]
python
en
['en', 'en', 'en']
True
test_entity_three_axis_state
(hass, device_factory)
Tests the state attributes properly match the three axis types.
Tests the state attributes properly match the three axis types.
async def test_entity_three_axis_state(hass, device_factory): """Tests the state attributes properly match the three axis types.""" device = device_factory( "Three Axis", [Capability.three_axis], {Attribute.three_axis: [100, 75, 25]} ) await setup_platform(hass, SENSOR_DOMAIN, devices=[device]) ...
[ "async", "def", "test_entity_three_axis_state", "(", "hass", ",", "device_factory", ")", ":", "device", "=", "device_factory", "(", "\"Three Axis\"", ",", "[", "Capability", ".", "three_axis", "]", ",", "{", "Attribute", ".", "three_axis", ":", "[", "100", ","...
[ 53, 0 ]
[ 67, 81 ]
python
en
['en', 'en', 'en']
True
test_entity_three_axis_invalid_state
(hass, device_factory)
Tests the state attributes properly match the three axis types.
Tests the state attributes properly match the three axis types.
async def test_entity_three_axis_invalid_state(hass, device_factory): """Tests the state attributes properly match the three axis types.""" device = device_factory( "Three Axis", [Capability.three_axis], {Attribute.three_axis: []} ) await setup_platform(hass, SENSOR_DOMAIN, devices=[device]) ...
[ "async", "def", "test_entity_three_axis_invalid_state", "(", "hass", ",", "device_factory", ")", ":", "device", "=", "device_factory", "(", "\"Three Axis\"", ",", "[", "Capability", ".", "three_axis", "]", ",", "{", "Attribute", ".", "three_axis", ":", "[", "]",...
[ 70, 0 ]
[ 81, 39 ]
python
en
['en', 'en', 'en']
True
test_entity_and_device_attributes
(hass, device_factory)
Test the attributes of the entity are correct.
Test the attributes of the entity are correct.
async def test_entity_and_device_attributes(hass, device_factory): """Test the attributes of the entity are correct.""" # Arrange device = device_factory("Sensor 1", [Capability.battery], {Attribute.battery: 100}) entity_registry = er.async_get(hass) device_registry = dr.async_get(hass) # Act ...
[ "async", "def", "test_entity_and_device_attributes", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Sensor 1\"", ",", "[", "Capability", ".", "battery", "]", ",", "{", "Attribute", ".", "battery", ":", "100", ...
[ 84, 0 ]
[ 100, 46 ]
python
en
['en', 'en', 'en']
True
test_energy_sensors_for_switch_device
(hass, device_factory)
Test the attributes of the entity are correct.
Test the attributes of the entity are correct.
async def test_energy_sensors_for_switch_device(hass, device_factory): """Test the attributes of the entity are correct.""" # Arrange device = device_factory( "Switch_1", [Capability.switch, Capability.power_meter, Capability.energy_meter], {Attribute.switch: "off", Attribute.power: ...
[ "async", "def", "test_energy_sensors_for_switch_device", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Switch_1\"", ",", "[", "Capability", ".", "switch", ",", "Capability", ".", "power_meter", ",", "Capability",...
[ 103, 0 ]
[ 138, 46 ]
python
en
['en', 'en', 'en']
True
test_power_consumption_sensor
(hass, device_factory)
Test the attributes of the entity are correct.
Test the attributes of the entity are correct.
async def test_power_consumption_sensor(hass, device_factory): """Test the attributes of the entity are correct.""" # Arrange device = device_factory( "refrigerator", [Capability.power_consumption_report], { Attribute.power_consumption: { "energy": 1412002...
[ "async", "def", "test_power_consumption_sensor", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"refrigerator\"", ",", "[", "Capability", ".", "power_consumption_report", "]", ",", "{", "Attribute", ".", "power_con...
[ 141, 0 ]
[ 209, 46 ]
python
en
['en', 'en', 'en']
True
test_update_from_signal
(hass, device_factory)
Test the binary_sensor updates when receiving a signal.
Test the binary_sensor updates when receiving a signal.
async def test_update_from_signal(hass, device_factory): """Test the binary_sensor updates when receiving a signal.""" # Arrange device = device_factory("Sensor 1", [Capability.battery], {Attribute.battery: 100}) await setup_platform(hass, SENSOR_DOMAIN, devices=[device]) device.status.apply_attribu...
[ "async", "def", "test_update_from_signal", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Sensor 1\"", ",", "[", "Capability", ".", "battery", "]", ",", "{", "Attribute", ".", "battery", ":", "100", "}", "...
[ 212, 0 ]
[ 226, 30 ]
python
en
['en', 'lb', 'en']
True
test_unload_config_entry
(hass, device_factory)
Test the binary_sensor is removed when the config entry is unloaded.
Test the binary_sensor is removed when the config entry is unloaded.
async def test_unload_config_entry(hass, device_factory): """Test the binary_sensor is removed when the config entry is unloaded.""" # Arrange device = device_factory("Sensor 1", [Capability.battery], {Attribute.battery: 100}) config_entry = await setup_platform(hass, SENSOR_DOMAIN, devices=[device]) ...
[ "async", "def", "test_unload_config_entry", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Sensor 1\"", ",", "[", "Capability", ".", "battery", "]", ",", "{", "Attribute", ".", "battery", ":", "100", "}", ...
[ 229, 0 ]
[ 238, 80 ]
python
en
['en', 'en', 'en']
True
path_to_url
(path)
Convert a path to a file: URL. The path will be made absolute and have quoted path parts.
Convert a path to a file: URL. The path will be made absolute and have quoted path parts.
def path_to_url(path): # type: (Union[str, Text]) -> str """ Convert a path to a file: URL. The path will be made absolute and have quoted path parts. """ path = os.path.normpath(os.path.abspath(path)) url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path)) return url
[ "def", "path_to_url", "(", "path", ")", ":", "# type: (Union[str, Text]) -> str", "path", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", "url", "=", "urllib_parse", ".", "urljoin", "(", "'file:'", ...
[ 19, 0 ]
[ 27, 14 ]
python
en
['en', 'error', 'th']
False
url_to_path
(url)
Convert a file: URL to a path.
Convert a file: URL to a path.
def url_to_path(url): # type: (str) -> str """ Convert a file: URL to a path. """ assert url.startswith('file:'), ( "You can only turn file: urls into filenames (not {url!r})" .format(**locals())) _, netloc, path, _, _ = urllib_parse.urlsplit(url) if not netloc or netloc ==...
[ "def", "url_to_path", "(", "url", ")", ":", "# type: (str) -> str", "assert", "url", ".", "startswith", "(", "'file:'", ")", ",", "(", "\"You can only turn file: urls into filenames (not {url!r})\"", ".", "format", "(", "*", "*", "locals", "(", ")", ")", ")", "_...
[ 30, 0 ]
[ 54, 15 ]
python
en
['en', 'error', 'th']
False
device_climate_mock
(hass, zigpy_device_mock, zha_device_joined)
Test regular thermostat device.
Test regular thermostat device.
def device_climate_mock(hass, zigpy_device_mock, zha_device_joined): """Test regular thermostat device.""" async def _dev(clusters, plug=None, manuf=None): if plug is None: plugged_attrs = ZCL_ATTR_PLUG else: plugged_attrs = {**ZCL_ATTR_PLUG, **plug} zigpy_devic...
[ "def", "device_climate_mock", "(", "hass", ",", "zigpy_device_mock", ",", "zha_device_joined", ")", ":", "async", "def", "_dev", "(", "clusters", ",", "plug", "=", "None", ",", "manuf", "=", "None", ")", ":", "if", "plug", "is", "None", ":", "plugged_attrs...
[ 158, 0 ]
[ 174, 15 ]
python
en
['en', 'en', 'en']
True
device_climate
(device_climate_mock)
Plain Climate device.
Plain Climate device.
async def device_climate(device_climate_mock): """Plain Climate device.""" return await device_climate_mock(CLIMATE)
[ "async", "def", "device_climate", "(", "device_climate_mock", ")", ":", "return", "await", "device_climate_mock", "(", "CLIMATE", ")" ]
[ 178, 0 ]
[ 181, 45 ]
python
fr
['fr', 'fr', 'en']
True
device_climate_fan
(device_climate_mock)
Test thermostat with fan device.
Test thermostat with fan device.
async def device_climate_fan(device_climate_mock): """Test thermostat with fan device.""" return await device_climate_mock(CLIMATE_FAN)
[ "async", "def", "device_climate_fan", "(", "device_climate_mock", ")", ":", "return", "await", "device_climate_mock", "(", "CLIMATE_FAN", ")" ]
[ 185, 0 ]
[ 188, 49 ]
python
en
['en', 'en', 'en']
True
device_climate_sinope
(device_climate_mock)
Sinope thermostat.
Sinope thermostat.
async def device_climate_sinope(device_climate_mock): """Sinope thermostat.""" return await device_climate_mock(CLIMATE_SINOPE, manuf=MANUF_SINOPE)
[ "async", "def", "device_climate_sinope", "(", "device_climate_mock", ")", ":", "return", "await", "device_climate_mock", "(", "CLIMATE_SINOPE", ",", "manuf", "=", "MANUF_SINOPE", ")" ]
[ 197, 0 ]
[ 200, 72 ]
python
en
['en', 'ja', 'ru']
False
device_climate_zen
(device_climate_mock)
Zen Within thermostat.
Zen Within thermostat.
async def device_climate_zen(device_climate_mock): """Zen Within thermostat.""" return await device_climate_mock(CLIMATE_ZEN, manuf=MANUF_ZEN)
[ "async", "def", "device_climate_zen", "(", "device_climate_mock", ")", ":", "return", "await", "device_climate_mock", "(", "CLIMATE_ZEN", ",", "manuf", "=", "MANUF_ZEN", ")" ]
[ 204, 0 ]
[ 207, 66 ]
python
en
['en', 'en', 'en']
True
device_climate_moes
(device_climate_mock)
MOES thermostat.
MOES thermostat.
async def device_climate_moes(device_climate_mock): """MOES thermostat.""" return await device_climate_mock(CLIMATE_MOES, manuf=MANUF_MOES)
[ "async", "def", "device_climate_moes", "(", "device_climate_mock", ")", ":", "return", "await", "device_climate_mock", "(", "CLIMATE_MOES", ",", "manuf", "=", "MANUF_MOES", ")" ]
[ 211, 0 ]
[ 214, 68 ]
python
en
['en', 'en', 'it']
False
test_sequence_mappings
()
Test correct mapping between control sequence -> HVAC Mode -> Sysmode.
Test correct mapping between control sequence -> HVAC Mode -> Sysmode.
def test_sequence_mappings(): """Test correct mapping between control sequence -> HVAC Mode -> Sysmode.""" for hvac_modes in SEQ_OF_OPERATION.values(): for hvac_mode in hvac_modes: assert hvac_mode in HVAC_MODE_2_SYSTEM assert Thermostat.SystemMode(HVAC_MODE_2_SYSTEM[hvac_mode])...
[ "def", "test_sequence_mappings", "(", ")", ":", "for", "hvac_modes", "in", "SEQ_OF_OPERATION", ".", "values", "(", ")", ":", "for", "hvac_mode", "in", "hvac_modes", ":", "assert", "hvac_mode", "in", "HVAC_MODE_2_SYSTEM", "assert", "Thermostat", ".", "SystemMode", ...
[ 217, 0 ]
[ 223, 83 ]
python
en
['en', 'en', 'en']
True
test_climate_local_temp
(hass, device_climate)
Test local temperature.
Test local temperature.
async def test_climate_local_temp(hass, device_climate): """Test local temperature.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert state.attributes[ATTR_CURRENT_TEMPERATURE] is...
[ "async", "def", "test_climate_local_temp", "(", "hass", ",", "device_climate", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", ...
[ 226, 0 ]
[ 237, 61 ]
python
en
['en', 'la', 'en']
True
test_climate_hvac_action_running_state
(hass, device_climate)
Test hvac action via running state.
Test hvac action via running state.
async def test_climate_hvac_action_running_state(hass, device_climate): """Test hvac action via running state.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert state.attributes[A...
[ "async", "def", "test_climate_hvac_action_running_state", "(", "hass", ",", "device_climate", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity_id", "(", "DOM...
[ 240, 0 ]
[ 283, 65 ]
python
de
['no', 'de', 'en']
False
test_climate_hvac_action_running_state_zen
(hass, device_climate_zen)
Test Zen hvac action via running state.
Test Zen hvac action via running state.
async def test_climate_hvac_action_running_state_zen(hass, device_climate_zen): """Test Zen hvac action via running state.""" thrm_cluster = device_climate_zen.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate_zen, hass) state = hass.states.get(entity_id) asser...
[ "async", "def", "test_climate_hvac_action_running_state_zen", "(", "hass", ",", "device_climate_zen", ")", ":", "thrm_cluster", "=", "device_climate_zen", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity_id", ...
[ 286, 0 ]
[ 347, 66 ]
python
de
['no', 'de', 'en']
False
test_climate_hvac_action_pi_demand
(hass, device_climate)
Test hvac action based on pi_heating/cooling_demand attrs.
Test hvac action based on pi_heating/cooling_demand attrs.
async def test_climate_hvac_action_pi_demand(hass, device_climate): """Test hvac action based on pi_heating/cooling_demand attrs.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert...
[ "async", "def", "test_climate_hvac_action_pi_demand", "(", "hass", ",", "device_climate", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN"...
[ 350, 0 ]
[ 383, 66 ]
python
en
['en', 'da', 'en']
True
test_hvac_mode
(hass, device_climate, sys_mode, hvac_mode)
Test HVAC modee.
Test HVAC modee.
async def test_hvac_mode(hass, device_climate, sys_mode, hvac_mode): """Test HVAC modee.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert state.state == HVAC_MODE_OFF await ...
[ "async", "def", "test_hvac_mode", "(", "hass", ",", "device_climate", ",", "sys_mode", ",", "hvac_mode", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity...
[ 397, 0 ]
[ 418, 39 ]
python
en
['en', 'zh', 'nl']
False
test_hvac_modes
(hass, device_climate_mock, seq_of_op, modes)
Test HVAC modes from sequence of operations.
Test HVAC modes from sequence of operations.
async def test_hvac_modes(hass, device_climate_mock, seq_of_op, modes): """Test HVAC modes from sequence of operations.""" device_climate = await device_climate_mock( CLIMATE, {"ctrl_seqe_of_oper": seq_of_op} ) entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.stat...
[ "async", "def", "test_hvac_modes", "(", "hass", ",", "device_climate_mock", ",", "seq_of_op", ",", "modes", ")", ":", "device_climate", "=", "await", "device_climate_mock", "(", "CLIMATE", ",", "{", "\"ctrl_seqe_of_oper\"", ":", "seq_of_op", "}", ")", "entity_id",...
[ 433, 0 ]
[ 441, 58 ]
python
en
['en', 'en', 'en']
True
test_target_temperature
( hass, device_climate_mock, sys_mode, preset, target_temp )
Test target temperature property.
Test target temperature property.
async def test_target_temperature( hass, device_climate_mock, sys_mode, preset, target_temp ): """Test target temperature property.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific", ): ...
[ "async", "def", "test_target_temperature", "(", "hass", ",", "device_climate_mock", ",", "sys_mode", ",", "preset", ",", "target_temp", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".", "Man...
[ 453, 0 ]
[ 484, 60 ]
python
en
['en', 'en', 'en']
True
test_target_temperature_high
( hass, device_climate_mock, preset, unoccupied, target_temp )
Test target temperature high property.
Test target temperature high property.
async def test_target_temperature_high( hass, device_climate_mock, preset, unoccupied, target_temp ): """Test target temperature high property.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific",...
[ "async", "def", "test_target_temperature_high", "(", "hass", ",", "device_climate_mock", ",", "preset", ",", "unoccupied", ",", "target_temp", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".",...
[ 495, 0 ]
[ 524, 65 ]
python
en
['en', 'en', 'en']
True
test_target_temperature_low
( hass, device_climate_mock, preset, unoccupied, target_temp )
Test target temperature low property.
Test target temperature low property.
async def test_target_temperature_low( hass, device_climate_mock, preset, unoccupied, target_temp ): """Test target temperature low property.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific", ...
[ "async", "def", "test_target_temperature_low", "(", "hass", ",", "device_climate_mock", ",", "preset", ",", "unoccupied", ",", "target_temp", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".", ...
[ 535, 0 ]
[ 564, 64 ]
python
en
['en', 'en', 'en']
True
test_set_hvac_mode
(hass, device_climate, hvac_mode, sys_mode)
Test setting hvac mode.
Test setting hvac mode.
async def test_set_hvac_mode(hass, device_climate, hvac_mode, sys_mode): """Test setting hvac mode.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert state.state == HVAC_MODE_OFF ...
[ "async", "def", "test_set_hvac_mode", "(", "hass", ",", "device_climate", ",", "hvac_mode", ",", "sys_mode", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_en...
[ 578, 0 ]
[ 617, 5 ]
python
en
['en', 'sq', 'ru']
False
test_preset_setting
(hass, device_climate_sinope)
Test preset setting.
Test preset setting.
async def test_preset_setting(hass, device_climate_sinope): """Test preset setting.""" entity_id = await find_entity_id(DOMAIN, device_climate_sinope, hass) thrm_cluster = device_climate_sinope.device.endpoints[1].thermostat state = hass.states.get(entity_id) assert state.attributes[ATTR_PRESET_MO...
[ "async", "def", "test_preset_setting", "(", "hass", ",", "device_climate_sinope", ")", ":", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", "device_climate_sinope", ",", "hass", ")", "thrm_cluster", "=", "device_climate_sinope", ".", "device", ".", ...
[ 620, 0 ]
[ 695, 80 ]
python
en
['en', 'ko', 'en']
True
test_preset_setting_invalid
(hass, device_climate_sinope)
Test invalid preset setting.
Test invalid preset setting.
async def test_preset_setting_invalid(hass, device_climate_sinope): """Test invalid preset setting.""" entity_id = await find_entity_id(DOMAIN, device_climate_sinope, hass) thrm_cluster = device_climate_sinope.device.endpoints[1].thermostat state = hass.states.get(entity_id) assert state.attribute...
[ "async", "def", "test_preset_setting_invalid", "(", "hass", ",", "device_climate_sinope", ")", ":", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", "device_climate_sinope", ",", "hass", ")", "thrm_cluster", "=", "device_climate_sinope", ".", "device",...
[ 698, 0 ]
[ 716, 56 ]
python
en
['en', 'et', 'en']
True
test_set_temperature_hvac_mode
(hass, device_climate)
Test setting HVAC mode in temperature service call.
Test setting HVAC mode in temperature service call.
async def test_set_temperature_hvac_mode(hass, device_climate): """Test setting HVAC mode in temperature service call.""" entity_id = await find_entity_id(DOMAIN, device_climate, hass) thrm_cluster = device_climate.device.endpoints[1].thermostat state = hass.states.get(entity_id) assert state.stat...
[ "async", "def", "test_set_temperature_hvac_mode", "(", "hass", ",", "device_climate", ")", ":", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", "device_climate", ",", "hass", ")", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoin...
[ 719, 0 ]
[ 744, 5 ]
python
en
['en', 'co', 'en']
True
test_set_temperature_heat_cool
(hass, device_climate_mock)
Test setting temperature service call in heating/cooling HVAC mode.
Test setting temperature service call in heating/cooling HVAC mode.
async def test_set_temperature_heat_cool(hass, device_climate_mock): """Test setting temperature service call in heating/cooling HVAC mode.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific", ): ...
[ "async", "def", "test_set_temperature_heat_cool", "(", "hass", ",", "device_climate_mock", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".", "ManufacturerSpecificCluster", ",", "\"ep_attribute\"", ...
[ 747, 0 ]
[ 834, 5 ]
python
en
['en', 'en', 'en']
True
test_set_temperature_heat
(hass, device_climate_mock)
Test setting temperature service call in heating HVAC mode.
Test setting temperature service call in heating HVAC mode.
async def test_set_temperature_heat(hass, device_climate_mock): """Test setting temperature service call in heating HVAC mode.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific", ): devic...
[ "async", "def", "test_set_temperature_heat", "(", "hass", ",", "device_climate_mock", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".", "ManufacturerSpecificCluster", ",", "\"ep_attribute\"", ",",...
[ 837, 0 ]
[ 917, 5 ]
python
en
['en', 'en', 'en']
True
test_set_temperature_cool
(hass, device_climate_mock)
Test setting temperature service call in cooling HVAC mode.
Test setting temperature service call in cooling HVAC mode.
async def test_set_temperature_cool(hass, device_climate_mock): """Test setting temperature service call in cooling HVAC mode.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific", ): devic...
[ "async", "def", "test_set_temperature_cool", "(", "hass", ",", "device_climate_mock", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".", "ManufacturerSpecificCluster", ",", "\"ep_attribute\"", ",",...
[ 920, 0 ]
[ 1000, 5 ]
python
en
['en', 'en', 'en']
True
test_set_temperature_wrong_mode
(hass, device_climate_mock)
Test setting temperature service call for wrong HVAC mode.
Test setting temperature service call for wrong HVAC mode.
async def test_set_temperature_wrong_mode(hass, device_climate_mock): """Test setting temperature service call for wrong HVAC mode.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific", ): ...
[ "async", "def", "test_set_temperature_wrong_mode", "(", "hass", ",", "device_climate_mock", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".", "ManufacturerSpecificCluster", ",", "\"ep_attribute\"", ...
[ 1003, 0 ]
[ 1039, 57 ]
python
en
['en', 'en', 'en']
True
test_occupancy_reset
(hass, device_climate_sinope)
Test away preset reset.
Test away preset reset.
async def test_occupancy_reset(hass, device_climate_sinope): """Test away preset reset.""" entity_id = await find_entity_id(DOMAIN, device_climate_sinope, hass) thrm_cluster = device_climate_sinope.device.endpoints[1].thermostat state = hass.states.get(entity_id) assert state.attributes[ATTR_PRESE...
[ "async", "def", "test_occupancy_reset", "(", "hass", ",", "device_climate_sinope", ")", ":", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", "device_climate_sinope", ",", "hass", ")", "thrm_cluster", "=", "device_climate_sinope", ".", "device", ".",...
[ 1042, 0 ]
[ 1066, 60 ]
python
de
['de', 'su', 'en']
False
test_fan_mode
(hass, device_climate_fan)
Test fan mode.
Test fan mode.
async def test_fan_mode(hass, device_climate_fan): """Test fan mode.""" entity_id = await find_entity_id(DOMAIN, device_climate_fan, hass) thrm_cluster = device_climate_fan.device.endpoints[1].thermostat state = hass.states.get(entity_id) assert set(state.attributes[ATTR_FAN_MODES]) == {FAN_AUTO, ...
[ "async", "def", "test_fan_mode", "(", "hass", ",", "device_climate_fan", ")", ":", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", "device_climate_fan", ",", "hass", ")", "thrm_cluster", "=", "device_climate_fan", ".", "device", ".", "endpoints", ...
[ 1069, 0 ]
[ 1095, 52 ]
python
fy
['id', 'fy', 'nl']
False
test_set_fan_mode_not_supported
(hass, device_climate_fan)
Test fan setting unsupported mode.
Test fan setting unsupported mode.
async def test_set_fan_mode_not_supported(hass, device_climate_fan): """Test fan setting unsupported mode.""" entity_id = await find_entity_id(DOMAIN, device_climate_fan, hass) fan_cluster = device_climate_fan.device.endpoints[1].fan await hass.services.async_call( DOMAIN, SERVICE_SET_...
[ "async", "def", "test_set_fan_mode_not_supported", "(", "hass", ",", "device_climate_fan", ")", ":", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", "device_climate_fan", ",", "hass", ")", "fan_cluster", "=", "device_climate_fan", ".", "device", "."...
[ 1098, 0 ]
[ 1110, 56 ]
python
en
['de', 'en', 'en']
True
test_set_fan_mode
(hass, device_climate_fan)
Test fan mode setting.
Test fan mode setting.
async def test_set_fan_mode(hass, device_climate_fan): """Test fan mode setting.""" entity_id = await find_entity_id(DOMAIN, device_climate_fan, hass) fan_cluster = device_climate_fan.device.endpoints[1].fan state = hass.states.get(entity_id) assert state.attributes[ATTR_FAN_MODE] == FAN_AUTO ...
[ "async", "def", "test_set_fan_mode", "(", "hass", ",", "device_climate_fan", ")", ":", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", "device_climate_fan", ",", "hass", ")", "fan_cluster", "=", "device_climate_fan", ".", "device", ".", "endpoints...
[ 1113, 0 ]
[ 1139, 74 ]
python
en
['id', 'fy', 'en']
False
test_set_moes_preset
(hass, device_climate_moes)
Test setting preset for moes trv.
Test setting preset for moes trv.
async def test_set_moes_preset(hass, device_climate_moes): """Test setting preset for moes trv.""" entity_id = await find_entity_id(DOMAIN, device_climate_moes, hass) thrm_cluster = device_climate_moes.device.endpoints[1].thermostat state = hass.states.get(entity_id) assert state.attributes[ATTR_P...
[ "async", "def", "test_set_moes_preset", "(", "hass", ",", "device_climate_moes", ")", ":", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", "device_climate_moes", ",", "hass", ")", "thrm_cluster", "=", "device_climate_moes", ".", "device", ".", "en...
[ 1142, 0 ]
[ 1254, 5 ]
python
en
['en', 'en', 'nl']
True
test_set_moes_operation_mode
(hass, device_climate_moes)
Test setting preset for moes trv.
Test setting preset for moes trv.
async def test_set_moes_operation_mode(hass, device_climate_moes): """Test setting preset for moes trv.""" entity_id = await find_entity_id(DOMAIN, device_climate_moes, hass) thrm_cluster = device_climate_moes.device.endpoints[1].thermostat await send_attributes_report(hass, thrm_cluster, {"operation_...
[ "async", "def", "test_set_moes_operation_mode", "(", "hass", ",", "device_climate_moes", ")", ":", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", "device_climate_moes", ",", "hass", ")", "thrm_cluster", "=", "device_climate_moes", ".", "device", "....
[ 1257, 0 ]
[ 1296, 63 ]
python
en
['en', 'en', 'nl']
True
async_setup_platform
( hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None )
Set up MQTT switch through configuration.yaml.
Set up MQTT switch through configuration.yaml.
async def async_setup_platform( hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None ): """Set up MQTT switch through configuration.yaml.""" await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await _async_setup_entity(hass, async_add_entities, config)
[ "async", "def", "async_setup_platform", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "await", "async_setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS...
[ 61, 0 ]
[ 66, 63 ]
python
en
['en', 'ny', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up MQTT switch dynamically through MQTT discovery.
Set up MQTT switch dynamically through MQTT discovery.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up MQTT switch dynamically through MQTT discovery.""" setup = functools.partial( _async_setup_entity, hass, async_add_entities, config_entry=config_entry ) await async_setup_entry_helper(hass, switch.DOMAIN, setup, PLATF...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "setup", "=", "functools", ".", "partial", "(", "_async_setup_entity", ",", "hass", ",", "async_add_entities", ",", "config_entry", "=", "config_entry", ")"...
[ 69, 0 ]
[ 74, 79 ]
python
en
['en', 'en', 'en']
True
_async_setup_entity
( hass, async_add_entities, config, config_entry=None, discovery_data=None )
Set up the MQTT switch.
Set up the MQTT switch.
async def _async_setup_entity( hass, async_add_entities, config, config_entry=None, discovery_data=None ): """Set up the MQTT switch.""" async_add_entities([MqttSwitch(hass, config, config_entry, discovery_data)])
[ "async", "def", "_async_setup_entity", "(", "hass", ",", "async_add_entities", ",", "config", ",", "config_entry", "=", "None", ",", "discovery_data", "=", "None", ")", ":", "async_add_entities", "(", "[", "MqttSwitch", "(", "hass", ",", "config", ",", "config...
[ 77, 0 ]
[ 81, 80 ]
python
en
['en', 'en', 'en']
True
MqttSwitch.__init__
(self, hass, config, config_entry, discovery_data)
Initialize the MQTT switch.
Initialize the MQTT switch.
def __init__(self, hass, config, config_entry, discovery_data): """Initialize the MQTT switch.""" self._state = False self._state_on = None self._state_off = None self._optimistic = None MqttEntity.__init__(self, hass, config, config_entry, discovery_data)
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ",", "config_entry", ",", "discovery_data", ")", ":", "self", ".", "_state", "=", "False", "self", ".", "_state_on", "=", "None", "self", ".", "_state_off", "=", "None", "self", ".", "_optimisti...
[ 89, 4 ]
[ 97, 77 ]
python
en
['en', 'co', 'en']
True
MqttSwitch.config_schema
()
Return the config schema.
Return the config schema.
def config_schema(): """Return the config schema.""" return PLATFORM_SCHEMA
[ "def", "config_schema", "(", ")", ":", "return", "PLATFORM_SCHEMA" ]
[ 100, 4 ]
[ 102, 30 ]
python
en
['en', 'de', 'en']
True
MqttSwitch._setup_from_config
(self, config)
(Re)Setup the entity.
(Re)Setup the entity.
def _setup_from_config(self, config): """(Re)Setup the entity.""" state_on = config.get(CONF_STATE_ON) self._state_on = state_on if state_on else config[CONF_PAYLOAD_ON] state_off = config.get(CONF_STATE_OFF) self._state_off = state_off if state_off else config[CONF_PAYLOAD_OFF]...
[ "def", "_setup_from_config", "(", "self", ",", "config", ")", ":", "state_on", "=", "config", ".", "get", "(", "CONF_STATE_ON", ")", "self", ".", "_state_on", "=", "state_on", "if", "state_on", "else", "config", "[", "CONF_PAYLOAD_ON", "]", "state_off", "=",...
[ 104, 4 ]
[ 116, 37 ]
python
en
['en', 'haw', 'en']
True
MqttSwitch._subscribe_topics
(self)
(Re)Subscribe to topics.
(Re)Subscribe to topics.
async def _subscribe_topics(self): """(Re)Subscribe to topics.""" @callback @log_messages(self.hass, self.entity_id) def state_message_received(msg): """Handle new MQTT state messages.""" payload = msg.payload template = self._config.get(CONF_VALUE_TE...
[ "async", "def", "_subscribe_topics", "(", "self", ")", ":", "@", "callback", "@", "log_messages", "(", "self", ".", "hass", ",", "self", ".", "entity_id", ")", "def", "state_message_received", "(", "msg", ")", ":", "\"\"\"Handle new MQTT state messages.\"\"\"", ...
[ 118, 4 ]
[ 155, 58 ]
python
en
['en', 'en', 'en']
True
MqttSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 158, 4 ]
[ 160, 26 ]
python
en
['en', 'fy', 'en']
True
MqttSwitch.assumed_state
(self)
Return true if we do optimistic updates.
Return true if we do optimistic updates.
def assumed_state(self): """Return true if we do optimistic updates.""" return self._optimistic
[ "def", "assumed_state", "(", "self", ")", ":", "return", "self", ".", "_optimistic" ]
[ 163, 4 ]
[ 165, 31 ]
python
en
['pt', 'la', 'en']
False
MqttSwitch.async_turn_on
(self, **kwargs)
Turn the device on. This method is a coroutine.
Turn the device on.
async def async_turn_on(self, **kwargs): """Turn the device on. This method is a coroutine. """ mqtt.async_publish( self.hass, self._config[CONF_COMMAND_TOPIC], self._config[CONF_PAYLOAD_ON], self._config[CONF_QOS], self._confi...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mqtt", ".", "async_publish", "(", "self", ".", "hass", ",", "self", ".", "_config", "[", "CONF_COMMAND_TOPIC", "]", ",", "self", ".", "_config", "[", "CONF_PAYLOAD_ON", "]"...
[ 167, 4 ]
[ 182, 39 ]
python
en
['en', 'en', 'en']
True
MqttSwitch.async_turn_off
(self, **kwargs)
Turn the device off. This method is a coroutine.
Turn the device off.
async def async_turn_off(self, **kwargs): """Turn the device off. This method is a coroutine. """ mqtt.async_publish( self.hass, self._config[CONF_COMMAND_TOPIC], self._config[CONF_PAYLOAD_OFF], self._config[CONF_QOS], self._co...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mqtt", ".", "async_publish", "(", "self", ".", "hass", ",", "self", ".", "_config", "[", "CONF_COMMAND_TOPIC", "]", ",", "self", ".", "_config", "[", "CONF_PAYLOAD_OFF", "...
[ 184, 4 ]
[ 199, 39 ]
python
en
['en', 'en', 'en']
True
init
(empty=False)
Initialize the platform with entities.
Initialize the platform with entities.
def init(empty=False): """Initialize the platform with entities.""" global ENTITIES ENTITIES = ( {} if empty else { "arm_code": MockAlarm( name="Alarm arm code", code_arm_required=True, unique_id="unique_arm_code", ...
[ "def", "init", "(", "empty", "=", "False", ")", ":", "global", "ENTITIES", "ENTITIES", "=", "(", "{", "}", "if", "empty", "else", "{", "\"arm_code\"", ":", "MockAlarm", "(", "name", "=", "\"Alarm arm code\"", ",", "code_arm_required", "=", "True", ",", "...
[ 27, 0 ]
[ 46, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
( hass, config, async_add_entities_callback, discovery_info=None )
Return mock entities.
Return mock entities.
async def async_setup_platform( hass, config, async_add_entities_callback, discovery_info=None ): """Return mock entities.""" async_add_entities_callback(list(ENTITIES.values()))
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities_callback", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities_callback", "(", "list", "(", "ENTITIES", ".", "values", "(", ")", ")", ")" ]
[ 49, 0 ]
[ 53, 56 ]
python
af
['nl', 'af', 'en']
False
MockAlarm.__init__
(self, **values)
Init the Mock Alarm Control Panel.
Init the Mock Alarm Control Panel.
def __init__(self, **values): """Init the Mock Alarm Control Panel.""" self._state = None MockEntity.__init__(self, **values)
[ "def", "__init__", "(", "self", ",", "*", "*", "values", ")", ":", "self", ".", "_state", "=", "None", "MockEntity", ".", "__init__", "(", "self", ",", "*", "*", "values", ")" ]
[ 59, 4 ]
[ 63, 43 ]
python
en
['en', 'ja', 'en']
True
MockAlarm.code_arm_required
(self)
Whether the code is required for arm actions.
Whether the code is required for arm actions.
def code_arm_required(self): """Whether the code is required for arm actions.""" return self._handle("code_arm_required")
[ "def", "code_arm_required", "(", "self", ")", ":", "return", "self", ".", "_handle", "(", "\"code_arm_required\"", ")" ]
[ 66, 4 ]
[ 68, 48 ]
python
en
['en', 'en', 'en']
True
MockAlarm.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" ]
[ 71, 4 ]
[ 73, 26 ]
python
en
['en', 'en', 'en']
True
MockAlarm.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self) -> int: """Return the list of supported features.""" return ( SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT | SUPPORT_ALARM_TRIGGER | SUPPORT_ALARM_ARM_VACATION )
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "(", "SUPPORT_ALARM_ARM_HOME", "|", "SUPPORT_ALARM_ARM_AWAY", "|", "SUPPORT_ALARM_ARM_NIGHT", "|", "SUPPORT_ALARM_TRIGGER", "|", "SUPPORT_ALARM_ARM_VACATION", ")" ]
[ 76, 4 ]
[ 84, 9 ]
python
en
['en', 'en', 'en']
True
MockAlarm.alarm_arm_away
(self, code=None)
Send arm away command.
Send arm away command.
def alarm_arm_away(self, code=None): """Send arm away command.""" self._state = STATE_ALARM_ARMED_AWAY self.schedule_update_ha_state()
[ "def", "alarm_arm_away", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_state", "=", "STATE_ALARM_ARMED_AWAY", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 86, 4 ]
[ 89, 39 ]
python
en
['en', 'en', 'en']
True
MockAlarm.alarm_arm_home
(self, code=None)
Send arm home command.
Send arm home command.
def alarm_arm_home(self, code=None): """Send arm home command.""" self._state = STATE_ALARM_ARMED_HOME self.schedule_update_ha_state()
[ "def", "alarm_arm_home", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_state", "=", "STATE_ALARM_ARMED_HOME", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 91, 4 ]
[ 94, 39 ]
python
en
['en', 'pt', 'en']
True
MockAlarm.alarm_arm_night
(self, code=None)
Send arm night command.
Send arm night command.
def alarm_arm_night(self, code=None): """Send arm night command.""" self._state = STATE_ALARM_ARMED_NIGHT self.schedule_update_ha_state()
[ "def", "alarm_arm_night", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_state", "=", "STATE_ALARM_ARMED_NIGHT", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 96, 4 ]
[ 99, 39 ]
python
en
['en', 'zh', 'en']
True
MockAlarm.alarm_arm_vacation
(self, code=None)
Send arm night command.
Send arm night command.
def alarm_arm_vacation(self, code=None): """Send arm night command.""" self._state = STATE_ALARM_ARMED_VACATION self.schedule_update_ha_state()
[ "def", "alarm_arm_vacation", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_state", "=", "STATE_ALARM_ARMED_VACATION", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 101, 4 ]
[ 104, 39 ]
python
en
['en', 'zh', 'en']
True
MockAlarm.alarm_disarm
(self, code=None)
Send disarm command.
Send disarm command.
def alarm_disarm(self, code=None): """Send disarm command.""" if code == "1234": self._state = STATE_ALARM_DISARMED self.schedule_update_ha_state()
[ "def", "alarm_disarm", "(", "self", ",", "code", "=", "None", ")", ":", "if", "code", "==", "\"1234\"", ":", "self", ".", "_state", "=", "STATE_ALARM_DISARMED", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 106, 4 ]
[ 110, 43 ]
python
en
['en', 'pt', 'en']
True
MockAlarm.alarm_trigger
(self, code=None)
Send alarm trigger command.
Send alarm trigger command.
def alarm_trigger(self, code=None): """Send alarm trigger command.""" self._state = STATE_ALARM_TRIGGERED self.schedule_update_ha_state()
[ "def", "alarm_trigger", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_state", "=", "STATE_ALARM_TRIGGERED", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 112, 4 ]
[ 115, 39 ]
python
en
['en', 'ca', 'en']
True
get_service
(hass, config, discovery_info=None)
Get the demo notification service.
Get the demo notification service.
def get_service(hass, config, discovery_info=None): """Get the demo notification service.""" return DemoNotificationService(hass)
[ "def", "get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "return", "DemoNotificationService", "(", "hass", ")" ]
[ 6, 0 ]
[ 8, 40 ]
python
en
['en', 'en', 'en']
True
DemoNotificationService.__init__
(self, hass)
Initialize the service.
Initialize the service.
def __init__(self, hass): """Initialize the service.""" self.hass = hass
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "self", ".", "hass", "=", "hass" ]
[ 14, 4 ]
[ 16, 24 ]
python
en
['en', 'en', 'en']
True
DemoNotificationService.targets
(self)
Return a dictionary of registered targets.
Return a dictionary of registered targets.
def targets(self): """Return a dictionary of registered targets.""" return {"test target name": "test target id"}
[ "def", "targets", "(", "self", ")", ":", "return", "{", "\"test target name\"", ":", "\"test target id\"", "}" ]
[ 19, 4 ]
[ 21, 53 ]
python
en
['en', 'en', 'en']
True
DemoNotificationService.send_message
(self, message="", **kwargs)
Send a message to a user.
Send a message to a user.
def send_message(self, message="", **kwargs): """Send a message to a user.""" kwargs["message"] = message self.hass.bus.fire(EVENT_NOTIFY, kwargs)
[ "def", "send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"message\"", "]", "=", "message", "self", ".", "hass", ".", "bus", ".", "fire", "(", "EVENT_NOTIFY", ",", "kwargs", ")" ]
[ 23, 4 ]
[ 26, 48 ]
python
en
['en', 'en', 'en']
True
mock_low_queue
()
Mock a low queue.
Mock a low queue.
def mock_low_queue(): """Mock a low queue.""" with patch("homeassistant.components.websocket_api.http.MAX_PENDING_MSG", 5): yield
[ "def", "mock_low_queue", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.websocket_api.http.MAX_PENDING_MSG\"", ",", "5", ")", ":", "yield" ]
[ 14, 0 ]
[ 17, 13 ]
python
ca
['es', 'ca', 'en']
False
mock_low_peak
()
Mock a low queue.
Mock a low queue.
def mock_low_peak(): """Mock a low queue.""" with patch("homeassistant.components.websocket_api.http.PENDING_MSG_PEAK", 5): yield
[ "def", "mock_low_peak", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.websocket_api.http.PENDING_MSG_PEAK\"", ",", "5", ")", ":", "yield" ]
[ 21, 0 ]
[ 24, 13 ]
python
ca
['es', 'ca', 'en']
False
test_pending_msg_overflow
(hass, mock_low_queue, websocket_client)
Test get_panels command.
Test get_panels command.
async def test_pending_msg_overflow(hass, mock_low_queue, websocket_client): """Test get_panels command.""" for idx in range(10): await websocket_client.send_json({"id": idx + 1, "type": "ping"}) msg = await websocket_client.receive() assert msg.type == WSMsgType.close
[ "async", "def", "test_pending_msg_overflow", "(", "hass", ",", "mock_low_queue", ",", "websocket_client", ")", ":", "for", "idx", "in", "range", "(", "10", ")", ":", "await", "websocket_client", ".", "send_json", "(", "{", "\"id\"", ":", "idx", "+", "1", "...
[ 27, 0 ]
[ 32, 38 ]
python
en
['nl', 'en', 'en']
True
test_pending_msg_peak
(hass, mock_low_peak, hass_ws_client, caplog)
Test pending msg overflow command.
Test pending msg overflow command.
async def test_pending_msg_peak(hass, mock_low_peak, hass_ws_client, caplog): """Test pending msg overflow command.""" orig_handler = http.WebSocketHandler instance = None def instantiate_handler(*args): nonlocal instance instance = orig_handler(*args) return instance with ...
[ "async", "def", "test_pending_msg_peak", "(", "hass", ",", "mock_low_peak", ",", "hass_ws_client", ",", "caplog", ")", ":", "orig_handler", "=", "http", ".", "WebSocketHandler", "instance", "=", "None", "def", "instantiate_handler", "(", "*", "args", ")", ":", ...
[ 35, 0 ]
[ 65, 74 ]
python
en
['en', 'en', 'en']
True
test_non_json_message
(hass, websocket_client, caplog)
Test trying to serialize non JSON objects.
Test trying to serialize non JSON objects.
async def test_non_json_message(hass, websocket_client, caplog): """Test trying to serialize non JSON objects.""" bad_data = object() hass.states.async_set("test_domain.entity", "testing", {"bad": bad_data}) await websocket_client.send_json({"id": 5, "type": "get_states"}) msg = await websocket_cli...
[ "async", "def", "test_non_json_message", "(", "hass", ",", "websocket_client", ",", "caplog", ")", ":", "bad_data", "=", "object", "(", ")", "hass", ".", "states", ".", "async_set", "(", "\"test_domain.entity\"", ",", "\"testing\"", ",", "{", "\"bad\"", ":", ...
[ 68, 0 ]
[ 81, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up Freedompro lock.
Set up Freedompro lock.
async def async_setup_entry(hass, entry, async_add_entities): """Set up Freedompro lock.""" api_key = entry.data[CONF_API_KEY] coordinator = hass.data[DOMAIN][entry.entry_id] async_add_entities( Device(hass, api_key, device, coordinator) for device in coordinator.data if device["...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "api_key", "=", "entry", ".", "data", "[", "CONF_API_KEY", "]", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id",...
[ 14, 0 ]
[ 22, 5 ]
python
en
['en', 'zu', 'en']
True
Device.__init__
(self, hass, api_key, device, coordinator)
Initialize the Freedompro lock.
Initialize the Freedompro lock.
def __init__(self, hass, api_key, device, coordinator): """Initialize the Freedompro lock.""" super().__init__(coordinator) self._hass = hass self._session = aiohttp_client.async_get_clientsession(self._hass) self._api_key = api_key self._attr_name = device["name"] ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "api_key", ",", "device", ",", "coordinator", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "_hass", "=", "hass", "self", ".", "_session", "=", "aiohttp_client", "....
[ 28, 4 ]
[ 45, 9 ]
python
en
['en', 'en', 'en']
True
Device._handle_coordinator_update
(self)
Handle updated data from the coordinator.
Handle updated data from the coordinator.
def _handle_coordinator_update(self) -> None: """Handle updated data from the coordinator.""" device = next( ( device for device in self.coordinator.data if device["uid"] == self.unique_id ), None, ) if d...
[ "def", "_handle_coordinator_update", "(", "self", ")", "->", "None", ":", "device", "=", "next", "(", "(", "device", "for", "device", "in", "self", ".", "coordinator", ".", "data", "if", "device", "[", "\"uid\"", "]", "==", "self", ".", "unique_id", ")",...
[ 48, 4 ]
[ 65, 44 ]
python
en
['en', 'en', 'en']
True
Device.async_added_to_hass
(self)
When entity is added to hass.
When entity is added to hass.
async def async_added_to_hass(self) -> None: """When entity is added to hass.""" await super().async_added_to_hass() self._handle_coordinator_update()
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "_handle_coordinator_update", "(", ")" ]
[ 67, 4 ]
[ 70, 41 ]
python
en
['en', 'en', 'en']
True
Device.async_lock
(self, **kwargs)
Async function to lock the lock.
Async function to lock the lock.
async def async_lock(self, **kwargs): """Async function to lock the lock.""" payload = {"lock": 1} payload = json.dumps(payload) await put_state( self._session, self._api_key, self.unique_id, payload, ) await self.coordinato...
[ "async", "def", "async_lock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "\"lock\"", ":", "1", "}", "payload", "=", "json", ".", "dumps", "(", "payload", ")", "await", "put_state", "(", "self", ".", "_session", ",", "self", ...
[ 72, 4 ]
[ 82, 54 ]
python
en
['en', 'en', 'en']
True
Device.async_unlock
(self, **kwargs)
Async function to unlock the lock.
Async function to unlock the lock.
async def async_unlock(self, **kwargs): """Async function to unlock the lock.""" payload = {"lock": 0} payload = json.dumps(payload) await put_state( self._session, self._api_key, self.unique_id, payload, ) await self.coordi...
[ "async", "def", "async_unlock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "\"lock\"", ":", "0", "}", "payload", "=", "json", ".", "dumps", "(", "payload", ")", "await", "put_state", "(", "self", ".", "_session", ",", "self"...
[ 84, 4 ]
[ 94, 54 ]
python
en
['en', 'en', 'en']
True
mock_setup_entry_fixture
()
Disable component setup.
Disable component setup.
def mock_setup_entry_fixture(): """Disable component setup.""" with patch( "homeassistant.components.philips_js.async_setup_entry", return_value=True ) as mock_setup_entry, patch( "homeassistant.components.philips_js.async_unload_entry", return_value=True ): yield mock_setup_entr...
[ "def", "mock_setup_entry_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.philips_js.async_setup_entry\"", ",", "return_value", "=", "True", ")", "as", "mock_setup_entry", ",", "patch", "(", "\"homeassistant.components.philips_js.async_unload_entry\"",...
[ 23, 0 ]
[ 30, 30 ]
python
en
['en', 'fr', 'en']
True
mock_tv_pairable
(mock_tv)
Return a mock tv that is pariable.
Return a mock tv that is pariable.
async def mock_tv_pairable(mock_tv): """Return a mock tv that is pariable.""" mock_tv.system = MOCK_SYSTEM_UNPAIRED mock_tv.pairing_type = "digest_auth_pairing" mock_tv.api_version = 6 mock_tv.api_version_detected = 6 mock_tv.secured_transport = True mock_tv.pairRequest.return_value = {} ...
[ "async", "def", "mock_tv_pairable", "(", "mock_tv", ")", ":", "mock_tv", ".", "system", "=", "MOCK_SYSTEM_UNPAIRED", "mock_tv", ".", "pairing_type", "=", "\"digest_auth_pairing\"", "mock_tv", ".", "api_version", "=", "6", "mock_tv", ".", "api_version_detected", "=",...
[ 34, 0 ]
[ 44, 18 ]
python
en
['en', 'en', 'en']
True
test_import
(hass, mock_setup_entry)
Test we get an item on import.
Test we get an item on import.
async def test_import(hass, mock_setup_entry): """Test we get an item on import.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=MOCK_IMPORT, ) assert result["type"] == "create_entry" assert result["title"...
[ "async", "def", "test_import", "(", "hass", ",", "mock_setup_entry", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_I...
[ 47, 0 ]
[ 58, 48 ]
python
en
['en', 'en', 'en']
True
test_import_exist
(hass, mock_config_entry)
Test we get an item on import.
Test we get an item on import.
async def test_import_exist(hass, mock_config_entry): """Test we get an item on import.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=MOCK_IMPORT, ) assert result["type"] == "abort" assert result["reason...
[ "async", "def", "test_import_exist", "(", "hass", ",", "mock_config_entry", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "S...
[ 61, 0 ]
[ 70, 51 ]
python
en
['en', 'en', 'en']
True
test_form
(hass, mock_setup_entry)
Test we get the form.
Test we get the form.
async def test_form(hass, mock_setup_entry): """Test we get the form.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["errors"] == {} result2 = await hass.config_entries.flow.as...
[ "async", "def", "test_form", "(", "hass", ",", "mock_setup_entry", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USE...
[ 73, 0 ]
[ 90, 48 ]
python
en
['en', 'en', 'en']
True
test_form_cannot_connect
(hass, mock_tv)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_cannot_connect(hass, mock_tv): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) mock_tv.system = None result = await hass.config_entries.flow.async_configure( r...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ",", "mock_tv", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOUR...
[ 93, 0 ]
[ 105, 57 ]
python
en
['en', 'en', 'en']
True
test_form_unexpected_error
(hass, mock_tv)
Test we handle unexpected exceptions.
Test we handle unexpected exceptions.
async def test_form_unexpected_error(hass, mock_tv): """Test we handle unexpected exceptions.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) mock_tv.getSystem.side_effect = Exception("Unexpected exception") result = await hass...
[ "async", "def", "test_form_unexpected_error", "(", "hass", ",", "mock_tv", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SO...
[ 108, 0 ]
[ 120, 50 ]
python
en
['en', 'en', 'en']
True