feat(entrypoint): try using the do not disturb command

This commit is contained in:
2026-07-08 16:49:37 -04:00
parent 9e7e5cdcc8
commit 89404a56e0

View File

@@ -101,6 +101,8 @@ async fn real_main(
let built_at = build_info::BUILD_TIME; let built_at = build_info::BUILD_TIME;
tracing::info!(built_at); tracing::info!(built_at);
tokio::join!(
async {
let mut bathroom_mirror_lights = [ let mut bathroom_mirror_lights = [
LB130USHandle::new( LB130USHandle::new(
([10, 0, 3, 80], 9999).into(), ([10, 0, 3, 80], 9999).into(),
@@ -126,16 +128,71 @@ async fn real_main(
let tasks = bathroom_mirror_lights let tasks = bathroom_mirror_lights
.iter_mut() .iter_mut()
.map(|bathroom_mirror_light| bathroom_mirror_light.turn_to_temperature(temperature)); .map(|bathroom_mirror_light| {
bathroom_mirror_light.turn_to_temperature(temperature)
});
let mut tasks = FuturesUnordered::from_iter(tasks); let mut tasks = FuturesUnordered::from_iter(tasks);
while let Some(result) = tasks.next().await { while let Some(result) = tasks.next().await {
match result { match result {
Ok(()) => {} Ok(()) => {}
Err(error_turning_to_temperature) => tracing::error!(?error_turning_to_temperature), Err(error_turning_to_temperature) => {
tracing::error!(?error_turning_to_temperature)
} }
} }
} }
}
},
async {
let jacob_phone_id = "galaxy_s21_ultra_1";
let jacob_phone_object_id = ObjectId::from_str(jacob_phone_id).unwrap();
let services = Python::attach(|py| home_assistant.services(py)).unwrap();
let mut interval = interval(Duration::from_secs(15));
interval.set_missed_tick_behavior(MissedTickBehavior::Delay);
use home_assistant::notify::service::mobile_app::command;
// loop {
// let instant = interval.tick().await;
// let context: Option<Context<()>> = None;
// let target: Option<()> = None;
// let turn_off_result: Result<Py<PyAny>, _> = services.call_service(command::DoNotDisturb {
// object_id: jacob_phone_object_id.clone(),
// filter: command::DoNotDisturbFilter::Off,
// }, context, target, false).await;
// dbg!(turn_off_result);
// let instant = interval.tick().await;
// let context: Option<Context<()>> = None;
// let target: Option<()> = None;
// let alarms_only_result: Result<Py<PyAny>, _> = services.call_service(command::DoNotDisturb {
// object_id: jacob_phone_object_id.clone(),
// filter: command::DoNotDisturbFilter::AlarmsOnly,
// }, context, target, false).await;
// dbg!(alarms_only_result);
// let instant = interval.tick().await;
// let context: Option<Context<()>> = None;
// let target: Option<()> = None;
// let priority_only_result: Result<Py<PyAny>, _> = services.call_service(command::DoNotDisturb {
// object_id: jacob_phone_object_id.clone(),
// filter: command::DoNotDisturbFilter::PriorityOnly,
// }, context, target, false).await;
// dbg!(priority_only_result);
// let instant = interval.tick().await;
// let context: Option<Context<()>> = None;
// let target: Option<()> = None;
// let total_silence_result: Result<Py<PyAny>, _> = services.call_service(command::DoNotDisturb {
// object_id: jacob_phone_object_id.clone(),
// filter: command::DoNotDisturbFilter::TotalSilence,
// }, context, target, false).await;
// dbg!(total_silence_result);
// }
}
).0
} }
#[pyfunction] #[pyfunction]