diff --git a/src/home_assistant/home_assistant.rs b/src/home_assistant/home_assistant.rs index 64901ed..6104eea 100644 --- a/src/home_assistant/home_assistant.rs +++ b/src/home_assistant/home_assistant.rs @@ -1,3 +1,5 @@ +use std::convert::Infallible; + use pyo3::prelude::*; use crate::python_utils::{detach, validate_type_by_name}; @@ -17,6 +19,16 @@ impl<'source> FromPyObject<'source> for HomeAssistant { } } +impl<'py> IntoPyObject<'py> for &HomeAssistant { + type Target = PyAny; + type Output = Bound<'py, Self::Target>; + type Error = Infallible; + + fn into_pyobject(self, py: Python<'py>) -> Result { + Ok(self.0.bind(py).to_owned()) + } +} + impl HomeAssistant { /// Return the representation pub fn repr(&self, py: Python<'_>) -> Result {