Struct hass_mqtt_discovery::entity::DeviceTracker
source · pub struct DeviceTracker<'a> {Show 18 fields
pub availability: Cow<'a, [Availability<'a>]>,
pub availability_mode: AvailabilityMode,
pub device: Option<Device<'a>>,
pub enabled_by_default: Option<bool>,
pub encoding: Option<Cow<'a, str>>,
pub entity_category: EntityCategory,
pub icon: Option<Icon<'a>>,
pub json_attributes_template: Option<Template<'a>>,
pub json_attributes_topic: Option<Topic<'a>>,
pub name: Option<Name<'a>>,
pub object_id: Option<Cow<'a, str>>,
pub qos: MqttQoS,
pub unique_id: Option<UniqueId<'a>>,
pub payload_home: Option<Payload<'a>>,
pub payload_not_home: Option<Payload<'a>>,
pub source_type: Option<DeviceTrackerSourceType>,
pub state_topic: Topic<'a>,
pub value_template: Option<Template<'a>>,
}
Expand description
The mqtt device tracker platform allows you to automatically discover device_trackers using the MQTT Discovery protocol.
See: https://www.home-assistant.io/integrations/device_tracker.mqtt/
Fields§
§availability: Cow<'a, [Availability<'a>]>
A list of MQTT topics subscribed to receive availability (online/offline) updates.
availability_mode: AvailabilityMode
When availability
is configured, this controls the conditions needed
to set the entity to available
.
device: Option<Device<'a>>
Information about the device this entity is a part of to tie it into the device registry.
Only works through MQTT discovery and when unique_id
is set.
At least one of identifiers or connections must be present to identify the device.
enabled_by_default: Option<bool>
Flag which defines if the entity should be enabled when first added.
Defaults to true
.
encoding: Option<Cow<'a, str>>
The encoding of the payloads received and published messages. Set to “” to disable decoding of incoming payload.
Defaults to "utf-8"
.
entity_category: EntityCategory
The category of the entity.
icon: Option<Icon<'a>>
Icon for the entity.
json_attributes_template: Option<Template<'a>>
Defines a template to extract the JSON dictionary from messages received
on the json_attributes_topic
.
json_attributes_topic: Option<Topic<'a>>
The MQTT topic subscribed to receive a JSON dictionary payload and then set as entity attributes.
Implies force_update
of the current state when a message is received on this topic.
name: Option<Name<'a>>
The name of the MQTT entity.
object_id: Option<Cow<'a, str>>
Used instead of name
for automatic generation of entity_id
.
qos: MqttQoS
The maximum QoS level of the state topic.
unique_id: Option<UniqueId<'a>>
An ID that uniquely identifies this entity. If two entities have the same unique ID, Home Assistant will raise an exception.
payload_home: Option<Payload<'a>>
The payload value that represents the home
state for the device.
Defaults to "home"
.
payload_not_home: Option<Payload<'a>>
The payload value that represents the not_home
state for the device.
Defaults to "not_home"
.
source_type: Option<DeviceTrackerSourceType>
Attribute of a device tracker that affects state when being used to track a person.
Valid options are gps
, router
, bluetooth
, or bluetooth_le
.
state_topic: Topic<'a>
The MQTT topic subscribed to receive device tracker state changes.
value_template: Option<Template<'a>>
Defines a template that returns a device tracker state.
Implementations§
source§impl<'a> DeviceTracker<'a>
impl<'a> DeviceTracker<'a>
pub fn new(state_topic: impl Into<Topic<'a>>) -> Self
sourcepub fn availability(
self,
availability: impl Into<Cow<'a, [Availability<'a>]>>
) -> Self
pub fn availability(
self,
availability: impl Into<Cow<'a, [Availability<'a>]>>
) -> Self
A list of MQTT topics subscribed to receive availability (online/offline) updates.
sourcepub fn availability_mode(
self,
availability_mode: impl Into<AvailabilityMode>
) -> Self
pub fn availability_mode(
self,
availability_mode: impl Into<AvailabilityMode>
) -> Self
When availability
is configured, this controls the conditions needed
to set the entity to available
.
sourcepub fn device(self, device: impl Into<Device<'a>>) -> Self
pub fn device(self, device: impl Into<Device<'a>>) -> Self
Information about the device this entity is a part of to tie it into the device registry.
Only works through MQTT discovery and when unique_id
is set.
At least one of identifiers or connections must be present to identify the device.
sourcepub fn unset_device(&mut self) -> &mut Self
pub fn unset_device(&mut self) -> &mut Self
Information about the device this entity is a part of to tie it into the device registry.
Only works through MQTT discovery and when unique_id
is set.
At least one of identifiers or connections must be present to identify the device.
sourcepub fn enabled_by_default(self, enabled_by_default: impl Into<bool>) -> Self
pub fn enabled_by_default(self, enabled_by_default: impl Into<bool>) -> Self
Flag which defines if the entity should be enabled when first added.
Defaults to true
.
sourcepub fn unset_enabled_by_default(&mut self) -> &mut Self
pub fn unset_enabled_by_default(&mut self) -> &mut Self
Flag which defines if the entity should be enabled when first added.
Defaults to true
.
sourcepub fn encoding(self, encoding: impl Into<Cow<'a, str>>) -> Self
pub fn encoding(self, encoding: impl Into<Cow<'a, str>>) -> Self
The encoding of the payloads received and published messages. Set to “” to disable decoding of incoming payload.
Defaults to "utf-8"
.
sourcepub fn unset_encoding(&mut self) -> &mut Self
pub fn unset_encoding(&mut self) -> &mut Self
The encoding of the payloads received and published messages. Set to “” to disable decoding of incoming payload.
Defaults to "utf-8"
.
sourcepub fn entity_category(self, entity_category: impl Into<EntityCategory>) -> Self
pub fn entity_category(self, entity_category: impl Into<EntityCategory>) -> Self
The category of the entity.
sourcepub fn unset_icon(&mut self) -> &mut Self
pub fn unset_icon(&mut self) -> &mut Self
Icon for the entity.
sourcepub fn json_attributes_template(
self,
json_attributes_template: impl Into<Template<'a>>
) -> Self
pub fn json_attributes_template(
self,
json_attributes_template: impl Into<Template<'a>>
) -> Self
Defines a template to extract the JSON dictionary from messages received
on the json_attributes_topic
.
sourcepub fn unset_json_attributes_template(&mut self) -> &mut Self
pub fn unset_json_attributes_template(&mut self) -> &mut Self
Defines a template to extract the JSON dictionary from messages received
on the json_attributes_topic
.
sourcepub fn json_attributes_topic(
self,
json_attributes_topic: impl Into<Topic<'a>>
) -> Self
pub fn json_attributes_topic(
self,
json_attributes_topic: impl Into<Topic<'a>>
) -> Self
The MQTT topic subscribed to receive a JSON dictionary payload and then set as entity attributes.
Implies force_update
of the current state when a message is received on this topic.
sourcepub fn unset_json_attributes_topic(&mut self) -> &mut Self
pub fn unset_json_attributes_topic(&mut self) -> &mut Self
The MQTT topic subscribed to receive a JSON dictionary payload and then set as entity attributes.
Implies force_update
of the current state when a message is received on this topic.
sourcepub fn unset_name(&mut self) -> &mut Self
pub fn unset_name(&mut self) -> &mut Self
The name of the MQTT entity.
sourcepub fn object_id(self, object_id: impl Into<Cow<'a, str>>) -> Self
pub fn object_id(self, object_id: impl Into<Cow<'a, str>>) -> Self
Used instead of name
for automatic generation of entity_id
.
sourcepub fn unset_object_id(&mut self) -> &mut Self
pub fn unset_object_id(&mut self) -> &mut Self
Used instead of name
for automatic generation of entity_id
.
sourcepub fn unique_id(self, unique_id: impl Into<UniqueId<'a>>) -> Self
pub fn unique_id(self, unique_id: impl Into<UniqueId<'a>>) -> Self
An ID that uniquely identifies this entity. If two entities have the same unique ID, Home Assistant will raise an exception.
sourcepub fn unset_unique_id(&mut self) -> &mut Self
pub fn unset_unique_id(&mut self) -> &mut Self
An ID that uniquely identifies this entity. If two entities have the same unique ID, Home Assistant will raise an exception.
sourcepub fn payload_home(self, payload_home: impl Into<Payload<'a>>) -> Self
pub fn payload_home(self, payload_home: impl Into<Payload<'a>>) -> Self
The payload value that represents the home
state for the device.
Defaults to "home"
.
sourcepub fn unset_payload_home(&mut self) -> &mut Self
pub fn unset_payload_home(&mut self) -> &mut Self
The payload value that represents the home
state for the device.
Defaults to "home"
.
sourcepub fn payload_not_home(self, payload_not_home: impl Into<Payload<'a>>) -> Self
pub fn payload_not_home(self, payload_not_home: impl Into<Payload<'a>>) -> Self
The payload value that represents the not_home
state for the device.
Defaults to "not_home"
.
sourcepub fn unset_payload_not_home(&mut self) -> &mut Self
pub fn unset_payload_not_home(&mut self) -> &mut Self
The payload value that represents the not_home
state for the device.
Defaults to "not_home"
.
sourcepub fn source_type(self, source_type: impl Into<DeviceTrackerSourceType>) -> Self
pub fn source_type(self, source_type: impl Into<DeviceTrackerSourceType>) -> Self
Attribute of a device tracker that affects state when being used to track a person.
Valid options are gps
, router
, bluetooth
, or bluetooth_le
.
sourcepub fn unset_source_type(&mut self) -> &mut Self
pub fn unset_source_type(&mut self) -> &mut Self
Attribute of a device tracker that affects state when being used to track a person.
Valid options are gps
, router
, bluetooth
, or bluetooth_le
.
sourcepub fn state_topic(self, state_topic: impl Into<Topic<'a>>) -> Self
pub fn state_topic(self, state_topic: impl Into<Topic<'a>>) -> Self
The MQTT topic subscribed to receive device tracker state changes.
sourcepub fn value_template(self, value_template: impl Into<Template<'a>>) -> Self
pub fn value_template(self, value_template: impl Into<Template<'a>>) -> Self
Defines a template that returns a device tracker state.
sourcepub fn unset_value_template(&mut self) -> &mut Self
pub fn unset_value_template(&mut self) -> &mut Self
Defines a template that returns a device tracker state.
Trait Implementations§
source§impl<'a> Clone for DeviceTracker<'a>
impl<'a> Clone for DeviceTracker<'a>
source§fn clone(&self) -> DeviceTracker<'a>
fn clone(&self) -> DeviceTracker<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for DeviceTracker<'a>
impl<'a> Debug for DeviceTracker<'a>
source§impl<'de: 'a, 'a> Deserialize<'de> for DeviceTracker<'a>
impl<'de: 'a, 'a> Deserialize<'de> for DeviceTracker<'a>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<'a> Document for DeviceTracker<'a>
impl<'a> Document for DeviceTracker<'a>
fn serialize_validated<S>(
validated: Validated<&DeviceTracker<'a>>,
serializer: S
) -> Result<S::Ok, S::Error>where
S: Serializer,
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
source§impl<'a> PartialEq<DeviceTracker<'a>> for DeviceTracker<'a>
impl<'a> PartialEq<DeviceTracker<'a>> for DeviceTracker<'a>
source§fn eq(&self, other: &DeviceTracker<'a>) -> bool
fn eq(&self, other: &DeviceTracker<'a>) -> bool
source§impl<'a> Serialize for DeviceTracker<'a>
impl<'a> Serialize for DeviceTracker<'a>
source§impl<'a> Validate for DeviceTracker<'a>
impl<'a> Validate for DeviceTracker<'a>
§type Invalidity = DeviceTrackerInvalidity
type Invalidity = DeviceTrackerInvalidity
source§fn validate(&self) -> ValidationResult<Self::Invalidity>
fn validate(&self) -> ValidationResult<Self::Invalidity>
impl<'a> Eq for DeviceTracker<'a>
impl<'a> StructuralEq for DeviceTracker<'a>
impl<'a> StructuralPartialEq for DeviceTracker<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for DeviceTracker<'a>
impl<'a> Send for DeviceTracker<'a>
impl<'a> Sync for DeviceTracker<'a>
impl<'a> Unpin for DeviceTracker<'a>
impl<'a> UnwindSafe for DeviceTracker<'a>
Blanket Implementations§
source§impl<T, V> IntoValidated<V> for Twhere
V: ValidatedFrom<T>,
impl<T, V> IntoValidated<V> for Twhere
V: ValidatedFrom<T>,
source§fn into_validated(
self
) -> Result<Validated<V>, (V, Context<<V as Validate>::Invalidity>)>
fn into_validated(
self
) -> Result<Validated<V>, (V, Context<<V as Validate>::Invalidity>)>
self
into output value and validate the output Read more§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more