Device tracker
Device tracker 可让您在 Home Assistant 中跟踪设备。这可以通过查询无线路由器来实现,也可以通过应用推送位置信息来实现。
This device tracker is a building block integration that cannot be added to Home Assistant directly, but is used and provided by other integrations. A building block integration differs from a typical integration that connects to a device or service. Instead, other integrations use this device tracker building block to provide entities, actions, and other functionality that you can use in your automations or dashboards. If one of your integrations uses this building block, this page documents the functionality the device tracker building block offers.
配置 device_tracker 平台
要开始使用,请将以下内容添加到 configuration.yaml 中(NETGEAR 示例):
以下可选参数可用于任意平台:
Device tracker 只会在第一个已配置平台的配置下读取以下全局设置:
请注意,即使设置了 track_new_devices: false,新设备仍会记录到 known_devices.yaml 中,但不会被跟踪(track: false)。
:::
在 configuration.yaml 中,上面的扩展示例如下:
多个 device tracker 可以并行使用,例如 Owntracks 和 Nmap。设备状态将由最后一次上报的来源决定。
known_devices.yaml
:::warning
从 0.94 开始,known_devices.yaml 已逐步弃用,不再被所有 tracker 使用。根据您所使用的集成,本节内容可能已不再适用。这包括 OwnTracks、GeoFency、GPSLogger、Locative 和 Huawei LTE。
:::
启用 device_tracker 后,会在您的配置目录中创建一个名为 known_devices.yaml 的文件。您可以编辑此文件来调整要跟踪哪些设备。
下面是单个设备的配置示例:
:::important
在上面的示例中,devicename 指的是检测到的设备名称。例如,在 nmap 中,这会是 MAC 地址(省略字节分隔符)。
已跟踪设备的状态
device tracker 可具有的状态类型取决于其数据来源是 GPS 还是路由器。
以 GPS 为来源的 device tracker 可以具有任意数量的字符串状态。该集成可以返回以下任一情况:
- 上报 GPS 坐标。坐标随后会匹配到一个区域(并将其设为状态)。如果匹配到 home zone,状态将为 Home。如果没有匹配到任何区域,状态将为 Not home。
- 上报一个位置。它可以是任意字符串,并被设置为状态。
以 router 为来源的 device tracker 只有两种状态:Home 或 Not home。
- Home:您的跟踪设备位于 home zone 中,由网络或基于蓝牙的在家状态检测发现。如果您使用的是包含坐标的在家状态检测方法,那么当设备位于某个区域内时,状态会等于该区域名称(区分大小写)。
- Not home:当设备不在家中且不在任何区域内时。
显示开发者工具中 device tracker 实体状态的截图。
此外,该实体还可能具有以下状态:
- Unavailable:实体当前不可用。
- Unknown:状态尚未知晓。
device_tracker.see 操作
device_tracker.see 操作可用于手动更新 device tracker 的状态:

