add missing infos from original and lastchange timestamp #1

Merged
CyReVolt merged 1 commits from add-infos into main 2024-05-22 22:27:40 +00:00
Showing only changes of commit f1b78f9d57 - Show all commits

View File

@ -1,6 +1,7 @@
use std::time::{SystemTime, UNIX_EPOCH};
use spaceapi::{ use spaceapi::{
sensors::{DoorLockedSensor, SensorMetadataWithLocation, Sensors}, sensors::{DoorLockedSensor, SensorMetadataWithLocation, Sensors}, Contact, Feed, Feeds, Location, State, Status, StatusBuilder, Link
Contact, Location, State, Status, StatusBuilder,
}; };
const SPACE_NAME: &str = "Chaospott"; const SPACE_NAME: &str = "Chaospott";
@ -33,8 +34,25 @@ pub fn status(sensors: Sensors, state: State) -> Status {
phone: Some("+49 201 85892243".into()), phone: Some("+49 201 85892243".into()),
..Default::default() ..Default::default()
}) })
// .add_issue_report_channel(IssueReportChannel::IssueMail) .feeds(Feeds {
// .add_issue_report_channel(IssueReportChannel::Ml) blog: Some(Feed {
type_: Some("application/rss+xml".into()),
url: String::from("https://chaospott.de/feed.xml")
}),
calendar: Some(Feed {
type_: Some("ical".into()),
url: String::from("https://cloud.chaospott.de/remote.php/dav/public-calendars/5HM7B0ZOLEYC3QD0?export")
}),
..Default::default()
})
.add_project("https://wiki.chaospott.de/projekte:start")
.add_project("https://git.chaospott.de/")
.add_link(Link {
name: String::from("Sibyllinische Neuigkeiten"),
description: Some("In unserem Podcast berichten wir über unser Clubleben und unterhalten uns über verschiedene Technikthemen.".into()),
url: String::from("https://podcast.chaospott.de/")
})
// TODO state needs icon URLs for open and closed
.state(state) .state(state)
.build() .build()
.unwrap(); .unwrap();
@ -74,9 +92,16 @@ pub fn update(the_doors: TheDoors) -> (Sensors, State) {
let mut sensors = Sensors::default(); let mut sensors = Sensors::default();
sensors.door_locked.push(get_aerie(the_doors.aerie)); sensors.door_locked.push(get_aerie(the_doors.aerie));
sensors.door_locked.push(get_cellar(the_doors.cellar)); sensors.door_locked.push(get_cellar(the_doors.cellar));
let time = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs();
// Open means that any door is open. // Open means that any door is open.
let state = State { let state = State {
open: Some(the_doors.aerie || the_doors.cellar), open: Some(the_doors.aerie || the_doors.cellar),
lastchange: Some(time),
..State::default() ..State::default()
}; };
(sensors, state) (sensors, state)