Struct hass_mqtt_discovery::entity::Button
source · pub struct Button<'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 command_template: Option<Template<'a>>,
pub command_topic: Topic<'a>,
pub device_class: DeviceClass,
pub payload_press: Option<Payload<'a>>,
pub retain: Option<bool>,
}
Expand description
The mqtt button platform lets you send an MQTT message when the button is pressed in the frontend or the button press service is called. This can be used to expose some service of a remote device, for example reboot.
See: https://www.home-assistant.io/integrations/button.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.
command_template: Option<Template<'a>>
Defines a template to generate the payload to send to command_topic
.
command_topic: Topic<'a>
The MQTT topic to publish commands to trigger the button.
device_class: DeviceClass
The type/class of the button to set the icon in the frontend.
payload_press: Option<Payload<'a>>
The payload to send to trigger the button.
Defaults to "PRESS"
.
retain: Option<bool>
If the published message should have the retain flag on or not.
Defaults to false
.
Implementations§
source§impl<'a> Button<'a>
impl<'a> Button<'a>
pub fn new(command_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 command_template(self, command_template: impl Into<Template<'a>>) -> Self
pub fn command_template(self, command_template: impl Into<Template<'a>>) -> Self
Defines a template to generate the payload to send to command_topic
.
sourcepub fn unset_command_template(&mut self) -> &mut Self
pub fn unset_command_template(&mut self) -> &mut Self
Defines a template to generate the payload to send to command_topic
.
sourcepub fn command_topic(self, command_topic: impl Into<Topic<'a>>) -> Self
pub fn command_topic(self, command_topic: impl Into<Topic<'a>>) -> Self
The MQTT topic to publish commands to trigger the button.
sourcepub fn device_class(self, device_class: impl Into<DeviceClass>) -> Self
pub fn device_class(self, device_class: impl Into<DeviceClass>) -> Self
The type/class of the button to set the icon in the frontend.
sourcepub fn payload_press(self, payload_press: impl Into<Payload<'a>>) -> Self
pub fn payload_press(self, payload_press: impl Into<Payload<'a>>) -> Self
The payload to send to trigger the button.
Defaults to "PRESS"
.
sourcepub fn unset_payload_press(&mut self) -> &mut Self
pub fn unset_payload_press(&mut self) -> &mut Self
The payload to send to trigger the button.
Defaults to "PRESS"
.
sourcepub fn retain(self, retain: impl Into<bool>) -> Self
pub fn retain(self, retain: impl Into<bool>) -> Self
If the published message should have the retain flag on or not.
Defaults to false
.
sourcepub fn unset_retain(&mut self) -> &mut Self
pub fn unset_retain(&mut self) -> &mut Self
If the published message should have the retain flag on or not.
Defaults to false
.
Trait Implementations§
source§impl<'de: 'a, 'a> Deserialize<'de> for Button<'a>
impl<'de: 'a, 'a> Deserialize<'de> for Button<'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> Validate for Button<'a>
impl<'a> Validate for Button<'a>
§type Invalidity = ButtonInvalidity
type Invalidity = ButtonInvalidity
source§fn validate(&self) -> ValidationResult<Self::Invalidity>
fn validate(&self) -> ValidationResult<Self::Invalidity>
impl<'a> Eq for Button<'a>
impl<'a> StructuralEq for Button<'a>
impl<'a> StructuralPartialEq for Button<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Button<'a>
impl<'a> Send for Button<'a>
impl<'a> Sync for Button<'a>
impl<'a> Unpin for Button<'a>
impl<'a> UnwindSafe for Button<'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