Files
smart-home-in-rust-with-hom…/home-assistant/src/event/specific/state_changed.rs
2026-07-15 00:32:04 -04:00

47 lines
1.1 KiB
Rust

use pyo3::FromPyObject;
use python_utils::{FromPyFromStr, ToStrToPy};
use string_literal::StringLiteral;
use crate::{entity_id::EntityId, state_object::StateObject};
#[derive(Debug, Clone, StringLiteral, FromPyFromStr, ToStrToPy)]
#[string_literal(value = "state_changed")]
pub struct Type;
#[derive(Debug, FromPyObject)]
#[pyo3(from_item_all)]
pub struct Data<
OldState,
OldAttributes,
OldStateContextEvent,
NewState,
NewAttributes,
NewStateContextEvent,
> {
pub entity_id: EntityId,
pub old_state: Option<StateObject<OldState, OldAttributes, OldStateContextEvent>>,
pub new_state: Option<StateObject<NewState, NewAttributes, NewStateContextEvent>>,
}
/// A state changed event is fired when on state write the state is changed.
pub type Event<
OldState,
OldAttributes,
OldStateContextEvent,
NewState,
NewAttributes,
NewStateContextEvent,
Context,
> = super::super::Event<
Type,
Data<
OldState,
OldAttributes,
OldStateContextEvent,
NewState,
NewAttributes,
NewStateContextEvent,
>,
Context,
>;