mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Remove unnecessary pylint disable in tado (#100196)
This commit is contained in:
parent
a09372590f
commit
44af34083b
@ -52,6 +52,47 @@ class TadoSensorEntityDescription(
|
|||||||
data_category: str | None = None
|
data_category: str | None = None
|
||||||
|
|
||||||
|
|
||||||
|
def format_condition(condition: str) -> str:
|
||||||
|
"""Return condition from dict CONDITIONS_MAP."""
|
||||||
|
for key, value in CONDITIONS_MAP.items():
|
||||||
|
if condition in value:
|
||||||
|
return key
|
||||||
|
return condition
|
||||||
|
|
||||||
|
|
||||||
|
def get_tado_mode(data) -> str | None:
|
||||||
|
"""Return Tado Mode based on Presence attribute."""
|
||||||
|
if "presence" in data:
|
||||||
|
return data["presence"]
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_automatic_geofencing(data) -> bool:
|
||||||
|
"""Return whether Automatic Geofencing is enabled based on Presence Locked attribute."""
|
||||||
|
if "presenceLocked" in data:
|
||||||
|
if data["presenceLocked"]:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def get_geofencing_mode(data) -> str:
|
||||||
|
"""Return Geofencing Mode based on Presence and Presence Locked attributes."""
|
||||||
|
tado_mode = ""
|
||||||
|
tado_mode = data.get("presence", "unknown")
|
||||||
|
|
||||||
|
geofencing_switch_mode = ""
|
||||||
|
if "presenceLocked" in data:
|
||||||
|
if data["presenceLocked"]:
|
||||||
|
geofencing_switch_mode = "manual"
|
||||||
|
else:
|
||||||
|
geofencing_switch_mode = "auto"
|
||||||
|
else:
|
||||||
|
geofencing_switch_mode = "manual"
|
||||||
|
|
||||||
|
return f"{tado_mode.capitalize()} ({geofencing_switch_mode.capitalize()})"
|
||||||
|
|
||||||
|
|
||||||
HOME_SENSORS = [
|
HOME_SENSORS = [
|
||||||
TadoSensorEntityDescription(
|
TadoSensorEntityDescription(
|
||||||
key="outdoor temperature",
|
key="outdoor temperature",
|
||||||
@ -86,22 +127,19 @@ HOME_SENSORS = [
|
|||||||
TadoSensorEntityDescription(
|
TadoSensorEntityDescription(
|
||||||
key="tado mode",
|
key="tado mode",
|
||||||
translation_key="tado_mode",
|
translation_key="tado_mode",
|
||||||
# pylint: disable=unnecessary-lambda
|
state_fn=get_tado_mode,
|
||||||
state_fn=lambda data: get_tado_mode(data),
|
|
||||||
data_category=SENSOR_DATA_CATEGORY_GEOFENCE,
|
data_category=SENSOR_DATA_CATEGORY_GEOFENCE,
|
||||||
),
|
),
|
||||||
TadoSensorEntityDescription(
|
TadoSensorEntityDescription(
|
||||||
key="geofencing mode",
|
key="geofencing mode",
|
||||||
translation_key="geofencing_mode",
|
translation_key="geofencing_mode",
|
||||||
# pylint: disable=unnecessary-lambda
|
state_fn=get_geofencing_mode,
|
||||||
state_fn=lambda data: get_geofencing_mode(data),
|
|
||||||
data_category=SENSOR_DATA_CATEGORY_GEOFENCE,
|
data_category=SENSOR_DATA_CATEGORY_GEOFENCE,
|
||||||
),
|
),
|
||||||
TadoSensorEntityDescription(
|
TadoSensorEntityDescription(
|
||||||
key="automatic geofencing",
|
key="automatic geofencing",
|
||||||
translation_key="automatic_geofencing",
|
translation_key="automatic_geofencing",
|
||||||
# pylint: disable=unnecessary-lambda
|
state_fn=get_automatic_geofencing,
|
||||||
state_fn=lambda data: get_automatic_geofencing(data),
|
|
||||||
data_category=SENSOR_DATA_CATEGORY_GEOFENCE,
|
data_category=SENSOR_DATA_CATEGORY_GEOFENCE,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -163,47 +201,6 @@ ZONE_SENSORS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def format_condition(condition: str) -> str:
|
|
||||||
"""Return condition from dict CONDITIONS_MAP."""
|
|
||||||
for key, value in CONDITIONS_MAP.items():
|
|
||||||
if condition in value:
|
|
||||||
return key
|
|
||||||
return condition
|
|
||||||
|
|
||||||
|
|
||||||
def get_tado_mode(data) -> str | None:
|
|
||||||
"""Return Tado Mode based on Presence attribute."""
|
|
||||||
if "presence" in data:
|
|
||||||
return data["presence"]
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_automatic_geofencing(data) -> bool:
|
|
||||||
"""Return whether Automatic Geofencing is enabled based on Presence Locked attribute."""
|
|
||||||
if "presenceLocked" in data:
|
|
||||||
if data["presenceLocked"]:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def get_geofencing_mode(data) -> str:
|
|
||||||
"""Return Geofencing Mode based on Presence and Presence Locked attributes."""
|
|
||||||
tado_mode = ""
|
|
||||||
tado_mode = data.get("presence", "unknown")
|
|
||||||
|
|
||||||
geofencing_switch_mode = ""
|
|
||||||
if "presenceLocked" in data:
|
|
||||||
if data["presenceLocked"]:
|
|
||||||
geofencing_switch_mode = "manual"
|
|
||||||
else:
|
|
||||||
geofencing_switch_mode = "auto"
|
|
||||||
else:
|
|
||||||
geofencing_switch_mode = "manual"
|
|
||||||
|
|
||||||
return f"{tado_mode.capitalize()} ({geofencing_switch_mode.capitalize()})"
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user