mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Removal of extraneous parenthesis (#33637)
This commit is contained in:
parent
7d3c974747
commit
187b6525b4
@ -217,16 +217,14 @@ async def async_get_conditions(
|
||||
)
|
||||
|
||||
conditions.extend(
|
||||
(
|
||||
{
|
||||
**template,
|
||||
"condition": "device",
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": DOMAIN,
|
||||
}
|
||||
for template in templates
|
||||
)
|
||||
{
|
||||
**template,
|
||||
"condition": "device",
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": DOMAIN,
|
||||
}
|
||||
for template in templates
|
||||
)
|
||||
|
||||
return conditions
|
||||
|
@ -226,16 +226,14 @@ async def async_get_triggers(hass, device_id):
|
||||
)
|
||||
|
||||
triggers.extend(
|
||||
(
|
||||
{
|
||||
**automation,
|
||||
"platform": "device",
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": DOMAIN,
|
||||
}
|
||||
for automation in templates
|
||||
)
|
||||
{
|
||||
**automation,
|
||||
"platform": "device",
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": DOMAIN,
|
||||
}
|
||||
for automation in templates
|
||||
)
|
||||
|
||||
return triggers
|
||||
|
@ -186,15 +186,13 @@ async def _async_get_automations(
|
||||
|
||||
for entry in entries:
|
||||
automations.extend(
|
||||
(
|
||||
{
|
||||
**template,
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": domain,
|
||||
}
|
||||
for template in automation_templates
|
||||
)
|
||||
{
|
||||
**template,
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": domain,
|
||||
}
|
||||
for template in automation_templates
|
||||
)
|
||||
|
||||
return automations
|
||||
|
@ -124,9 +124,7 @@ def get_last_state_changes(hass, number_of_states, entity_id):
|
||||
start_time = dt_util.utcnow()
|
||||
|
||||
with session_scope(hass=hass) as session:
|
||||
query = session.query(States).filter(
|
||||
(States.last_changed == States.last_updated)
|
||||
)
|
||||
query = session.query(States).filter(States.last_changed == States.last_updated)
|
||||
|
||||
if entity_id is not None:
|
||||
query = query.filter_by(entity_id=entity_id.lower())
|
||||
|
@ -66,7 +66,7 @@ OPERATION_MODES = {
|
||||
"Dry": HVAC_MODE_DRY,
|
||||
}
|
||||
|
||||
OPERATION_MODES_INV = dict((reversed(item) for item in OPERATION_MODES.items()))
|
||||
OPERATION_MODES_INV = dict(reversed(item) for item in OPERATION_MODES.items())
|
||||
|
||||
PRESET_MODES = {
|
||||
# Map DPT 201.100 HVAC operating modes to HA presets
|
||||
@ -76,7 +76,7 @@ PRESET_MODES = {
|
||||
"Comfort": PRESET_COMFORT,
|
||||
}
|
||||
|
||||
PRESET_MODES_INV = dict((reversed(item) for item in PRESET_MODES.items()))
|
||||
PRESET_MODES_INV = dict(reversed(item) for item in PRESET_MODES.items())
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
|
@ -46,9 +46,7 @@ SERVICE_TO_METHOD = {
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Set up the Kodi integration."""
|
||||
if any(
|
||||
((CONF_PLATFORM, DOMAIN) in cfg.items() for cfg in config.get(MP_DOMAIN, []))
|
||||
):
|
||||
if any((CONF_PLATFORM, DOMAIN) in cfg.items() for cfg in config.get(MP_DOMAIN, [])):
|
||||
# Register the Kodi media_player services
|
||||
async def async_service_handler(service):
|
||||
"""Map services to methods on MediaPlayerDevice."""
|
||||
|
@ -335,11 +335,9 @@ class KonnectedView(HomeAssistantView):
|
||||
payload = await request.json()
|
||||
except json.decoder.JSONDecodeError:
|
||||
_LOGGER.error(
|
||||
(
|
||||
"Your Konnected device software may be out of "
|
||||
"date. Visit https://help.konnected.io for "
|
||||
"updating instructions."
|
||||
)
|
||||
"Your Konnected device software may be out of "
|
||||
"date. Visit https://help.konnected.io for "
|
||||
"updating instructions."
|
||||
)
|
||||
|
||||
device = data[CONF_DEVICES].get(device_id)
|
||||
@ -389,11 +387,9 @@ class KonnectedView(HomeAssistantView):
|
||||
request.query.get(CONF_ZONE) or PIN_TO_ZONE[request.query[CONF_PIN]]
|
||||
)
|
||||
zone = next(
|
||||
(
|
||||
switch
|
||||
for switch in device[CONF_SWITCHES]
|
||||
if switch[CONF_ZONE] == zone_num
|
||||
)
|
||||
switch
|
||||
for switch in device[CONF_SWITCHES]
|
||||
if switch[CONF_ZONE] == zone_num
|
||||
)
|
||||
|
||||
except StopIteration:
|
||||
|
@ -201,13 +201,13 @@ class NextBusDepartureSensor(Entity):
|
||||
messages = listify(results.get("message", []))
|
||||
self._log_debug("Messages: %s", messages)
|
||||
self._attributes["message"] = " -- ".join(
|
||||
(message.get("text", "") for message in messages)
|
||||
message.get("text", "") for message in messages
|
||||
)
|
||||
|
||||
# List out all directions in the attributes
|
||||
directions = listify(results.get("direction", []))
|
||||
self._attributes["direction"] = ", ".join(
|
||||
(direction.get("title", "") for direction in directions)
|
||||
direction.get("title", "") for direction in directions
|
||||
)
|
||||
|
||||
# Chain all predictions together
|
||||
|
@ -47,12 +47,12 @@ def get_time_until(departure_time=None):
|
||||
return 0
|
||||
|
||||
delta = dt_util.utc_from_timestamp(int(departure_time)) - dt_util.now()
|
||||
return round((delta.total_seconds() / 60))
|
||||
return round(delta.total_seconds() / 60)
|
||||
|
||||
|
||||
def get_delay_in_minutes(delay=0):
|
||||
"""Get the delay in minutes from a delay in seconds."""
|
||||
return round((int(delay) / 60))
|
||||
return round(int(delay) / 60)
|
||||
|
||||
|
||||
def get_ride_duration(departure_time, arrival_time, delay=0):
|
||||
@ -60,7 +60,7 @@ def get_ride_duration(departure_time, arrival_time, delay=0):
|
||||
duration = dt_util.utc_from_timestamp(
|
||||
int(arrival_time)
|
||||
) - dt_util.utc_from_timestamp(int(departure_time))
|
||||
duration_time = int(round((duration.total_seconds() / 60)))
|
||||
duration_time = int(round(duration.total_seconds() / 60))
|
||||
return duration_time + get_delay_in_minutes(delay)
|
||||
|
||||
|
||||
|
@ -98,7 +98,7 @@ def _resize_image(image, opts):
|
||||
new_width = old_width
|
||||
|
||||
scale = new_width / float(old_width)
|
||||
new_height = int((float(old_height) * float(scale)))
|
||||
new_height = int(float(old_height) * float(scale))
|
||||
|
||||
img = img.resize((new_width, new_height), Image.ANTIALIAS)
|
||||
imgbuf = io.BytesIO()
|
||||
|
@ -21,14 +21,14 @@ def purge_old_data(instance, purge_days, repack):
|
||||
with session_scope(session=instance.get_session()) as session:
|
||||
deleted_rows = (
|
||||
session.query(States)
|
||||
.filter((States.last_updated < purge_before))
|
||||
.filter(States.last_updated < purge_before)
|
||||
.delete(synchronize_session=False)
|
||||
)
|
||||
_LOGGER.debug("Deleted %s states", deleted_rows)
|
||||
|
||||
deleted_rows = (
|
||||
session.query(Events)
|
||||
.filter((Events.time_fired < purge_before))
|
||||
.filter(Events.time_fired < purge_before)
|
||||
.delete(synchronize_session=False)
|
||||
)
|
||||
_LOGGER.debug("Deleted %s events", deleted_rows)
|
||||
|
@ -113,16 +113,14 @@ async def async_get_conditions(
|
||||
)
|
||||
|
||||
conditions.extend(
|
||||
(
|
||||
{
|
||||
**template,
|
||||
"condition": "device",
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": DOMAIN,
|
||||
}
|
||||
for template in templates
|
||||
)
|
||||
{
|
||||
**template,
|
||||
"condition": "device",
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": DOMAIN,
|
||||
}
|
||||
for template in templates
|
||||
)
|
||||
|
||||
return conditions
|
||||
|
@ -129,16 +129,14 @@ async def async_get_triggers(hass, device_id):
|
||||
)
|
||||
|
||||
triggers.extend(
|
||||
(
|
||||
{
|
||||
**automation,
|
||||
"platform": "device",
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": DOMAIN,
|
||||
}
|
||||
for automation in templates
|
||||
)
|
||||
{
|
||||
**automation,
|
||||
"platform": "device",
|
||||
"device_id": device_id,
|
||||
"entity_id": entry.entity_id,
|
||||
"domain": DOMAIN,
|
||||
}
|
||||
for automation in templates
|
||||
)
|
||||
|
||||
return triggers
|
||||
|
@ -176,7 +176,7 @@ class Monitor(threading.Thread):
|
||||
value[2],
|
||||
value[1],
|
||||
)
|
||||
self.data["temp"] = float(("%d.%d" % (value[0], value[2])))
|
||||
self.data["temp"] = float("%d.%d" % (value[0], value[2]))
|
||||
self.data["humid"] = value[1]
|
||||
|
||||
def terminate(self):
|
||||
|
@ -113,10 +113,7 @@ class TomatoDeviceScanner(DeviceScanner):
|
||||
if response.status_code == 401:
|
||||
# Authentication error
|
||||
_LOGGER.exception(
|
||||
(
|
||||
"Failed to authenticate, "
|
||||
"please check your username and password"
|
||||
)
|
||||
"Failed to authenticate, please check your username and password"
|
||||
)
|
||||
return False
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user