1786826782

This commit is contained in:
2026-08-15 22:46:22 +02:00
parent b7fce915ca
commit a9b4e75539
3 changed files with 18 additions and 12 deletions

View File

@@ -123,8 +123,14 @@ pub async fn hass(
let s2c_tx = s2c_tx.clone();
async move {
loop {
let ha_client = HaClient::from_environment().unwrap();
let events = ha_client.fetch_calendar_events().unwrap();
let Ok(ha_client) = HaClient::from_environment() else {
sleep(Duration::from_secs(30)).await;
continue;
};
let Ok(events) = ha_client.fetch_calendar_events() else {
sleep(Duration::from_secs(30)).await;
continue;
};
s2c_tx.send(EventMessage::CalendarUpdated(events)).ok();
sleep(Duration::from_secs(30)).await;
}

View File

@@ -26,15 +26,15 @@ macro_rules! apply_model {
let data = $app
.[<get_ $name>]();
let model = data
if let Some(model) = data
.as_any()
.downcast_ref::<VecModel<$ty>>()
.unwrap();
.downcast_ref::<VecModel<$ty>>() {
for entity in $entities.iter().filter($filter) {
match model.iter().position(|item| item.id == entity.entity_id) {
Some(index) => model.set_row_data(index, entity.into()),
None => model.push(entity.into()),
for entity in $entities.iter().filter($filter) {
match model.iter().position(|item| item.id == entity.entity_id) {
Some(index) => model.set_row_data(index, entity.into()),
None => model.push(entity.into()),
}
}
}
}