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,41 +101,98 @@ async fn real_main(
let built_at = build_info::BUILD_TIME;
tracing::info!(built_at);
let mut bathroom_mirror_lights = [
LB130USHandle::new(
([10, 0, 3, 80], 9999).into(),
Duration::from_secs(10),
(64).try_into().unwrap(),
),
LB130USHandle::new(
([10, 0, 3, 82], 9999).into(),
Duration::from_secs(10),
(64).try_into().unwrap(),
),
];
tokio::join!(
async {
let mut bathroom_mirror_lights = [
LB130USHandle::new(
([10, 0, 3, 80], 9999).into(),
Duration::from_secs(10),
(64).try_into().unwrap(),
),
LB130USHandle::new(
([10, 0, 3, 82], 9999).into(),
Duration::from_secs(10),
(64).try_into().unwrap(),
),
];
let mut interval = interval(Duration::from_secs(15));
interval.set_missed_tick_behavior(MissedTickBehavior::Delay);
let mut interval = interval(Duration::from_secs(15));
interval.set_missed_tick_behavior(MissedTickBehavior::Delay);
let mut temperature = Kelvin::MIN;
let mut temperature = Kelvin::MIN;
loop {
let instant = interval.tick().await;
// temperature = temperature.wrapping_add(5173);
tracing::info!(?temperature);
loop {
let instant = interval.tick().await;
// temperature = temperature.wrapping_add(5173);
tracing::info!(?temperature);
let tasks = bathroom_mirror_lights
.iter_mut()
.map(|bathroom_mirror_light| bathroom_mirror_light.turn_to_temperature(temperature));
let mut tasks = FuturesUnordered::from_iter(tasks);
let tasks = bathroom_mirror_lights
.iter_mut()
.map(|bathroom_mirror_light| {
bathroom_mirror_light.turn_to_temperature(temperature)
});
let mut tasks = FuturesUnordered::from_iter(tasks);
while let Some(result) = tasks.next().await {
match result {
Ok(()) => {}
Err(error_turning_to_temperature) => tracing::error!(?error_turning_to_temperature),
while let Some(result) = tasks.next().await {
match result {
Ok(()) => {}
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]