Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -4,8 +4,17 @@ All containing methods are legacy helpers that should not be used by new
|
||||
components. Instead call the service directly.
|
||||
"""
|
||||
from homeassistant.components.device_tracker import (
|
||||
DOMAIN, ATTR_ATTRIBUTES, ATTR_BATTERY, ATTR_GPS, ATTR_GPS_ACCURACY,
|
||||
ATTR_LOCATION_NAME, ATTR_MAC, ATTR_DEV_ID, ATTR_HOST_NAME, SERVICE_SEE)
|
||||
DOMAIN,
|
||||
ATTR_ATTRIBUTES,
|
||||
ATTR_BATTERY,
|
||||
ATTR_GPS,
|
||||
ATTR_GPS_ACCURACY,
|
||||
ATTR_LOCATION_NAME,
|
||||
ATTR_MAC,
|
||||
ATTR_DEV_ID,
|
||||
ATTR_HOST_NAME,
|
||||
SERVICE_SEE,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.typing import GPSType, HomeAssistantType
|
||||
from homeassistant.loader import bind_hass
|
||||
@@ -13,19 +22,31 @@ from homeassistant.loader import bind_hass
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_see(hass: HomeAssistantType, mac: str = None, dev_id: str = None,
|
||||
host_name: str = None, location_name: str = None,
|
||||
gps: GPSType = None, gps_accuracy=None,
|
||||
battery: int = None, attributes: dict = None):
|
||||
def async_see(
|
||||
hass: HomeAssistantType,
|
||||
mac: str = None,
|
||||
dev_id: str = None,
|
||||
host_name: str = None,
|
||||
location_name: str = None,
|
||||
gps: GPSType = None,
|
||||
gps_accuracy=None,
|
||||
battery: int = None,
|
||||
attributes: dict = None,
|
||||
):
|
||||
"""Call service to notify you see device."""
|
||||
data = {key: value for key, value in
|
||||
((ATTR_MAC, mac),
|
||||
(ATTR_DEV_ID, dev_id),
|
||||
(ATTR_HOST_NAME, host_name),
|
||||
(ATTR_LOCATION_NAME, location_name),
|
||||
(ATTR_GPS, gps),
|
||||
(ATTR_GPS_ACCURACY, gps_accuracy),
|
||||
(ATTR_BATTERY, battery)) if value is not None}
|
||||
data = {
|
||||
key: value
|
||||
for key, value in (
|
||||
(ATTR_MAC, mac),
|
||||
(ATTR_DEV_ID, dev_id),
|
||||
(ATTR_HOST_NAME, host_name),
|
||||
(ATTR_LOCATION_NAME, location_name),
|
||||
(ATTR_GPS, gps),
|
||||
(ATTR_GPS_ACCURACY, gps_accuracy),
|
||||
(ATTR_BATTERY, battery),
|
||||
)
|
||||
if value is not None
|
||||
}
|
||||
if attributes:
|
||||
data[ATTR_ATTRIBUTES] = attributes
|
||||
hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_SEE, data))
|
||||
Reference in new issue
Block a user