2024-05-21 19:48:14 +00:00
|
|
|
use spaceapi::{
|
|
|
|
sensors::{DoorLockedSensor, SensorMetadataWithLocation, Sensors},
|
|
|
|
Contact, Location, State, Status, StatusBuilder,
|
|
|
|
};
|
|
|
|
|
|
|
|
const SPACE_NAME: &str = "Chaospott";
|
2024-05-21 21:44:10 +00:00
|
|
|
const SPACE_ADDRESS: &str = "Sibyllastr. 9, 45136 Essen, Germany";
|
|
|
|
const SPACE_LOCATION_LAT: f64 = 51.438476;
|
|
|
|
const SPACE_LOCATION_LON: f64 = 7.024991;
|
|
|
|
|
2024-05-21 19:48:14 +00:00
|
|
|
const SPACE_URL: &str = "https://chaospott.de";
|
2024-05-21 21:44:10 +00:00
|
|
|
const SPACE_LOGO: &str = "https://chaospott.de/images/logo.png";
|
2024-05-21 19:48:14 +00:00
|
|
|
|
2024-05-21 21:44:10 +00:00
|
|
|
// TODO: Add missing information
|
|
|
|
pub fn status(sensors: Sensors, state: State) -> Status {
|
2024-05-21 19:48:14 +00:00
|
|
|
let mut status = StatusBuilder::v14(SPACE_NAME)
|
|
|
|
.location(Location {
|
2024-05-21 21:44:10 +00:00
|
|
|
address: Some(SPACE_ADDRESS.into()),
|
|
|
|
lat: SPACE_LOCATION_LAT,
|
|
|
|
lon: SPACE_LOCATION_LON,
|
2024-05-21 19:48:14 +00:00
|
|
|
..Default::default()
|
|
|
|
})
|
|
|
|
.url(SPACE_URL)
|
2024-05-21 21:44:10 +00:00
|
|
|
.logo(SPACE_LOGO)
|
2024-05-21 19:48:14 +00:00
|
|
|
.contact(Contact {
|
|
|
|
email: Some("info@chaospott.de".into()),
|
|
|
|
irc: Some("irc://irc.hackint.org/#chaospott".into()),
|
|
|
|
issue_mail: Some("support@chaospott.de".into()),
|
|
|
|
mastodon: Some("https://chaos.social/@chaospott".into()),
|
|
|
|
matrix: Some("#chaospott:matrix.chaospott.de".into()),
|
|
|
|
ml: Some("discuss@lists.chaospott.de".into()),
|
|
|
|
mumble: Some("mumble://mumble.chaospott.de".into()),
|
|
|
|
phone: Some("+49 201 85892243".into()),
|
|
|
|
..Default::default()
|
|
|
|
})
|
|
|
|
// .add_issue_report_channel(IssueReportChannel::IssueMail)
|
|
|
|
// .add_issue_report_channel(IssueReportChannel::Ml)
|
2024-05-21 21:44:10 +00:00
|
|
|
.state(state)
|
2024-05-21 19:48:14 +00:00
|
|
|
.build()
|
|
|
|
.unwrap();
|
|
|
|
|
2024-05-21 21:44:10 +00:00
|
|
|
status.sensors = Some(sensors);
|
|
|
|
status
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct TheDoors {
|
|
|
|
pub aerie: bool,
|
|
|
|
pub cellar: bool,
|
|
|
|
}
|
2024-05-21 19:48:14 +00:00
|
|
|
|
2024-05-21 21:44:10 +00:00
|
|
|
pub fn get_aerie(open: bool) -> DoorLockedSensor {
|
|
|
|
DoorLockedSensor {
|
|
|
|
value: open,
|
2024-05-21 19:48:14 +00:00
|
|
|
metadata: SensorMetadataWithLocation {
|
|
|
|
name: None,
|
|
|
|
description: None,
|
|
|
|
location: "aerie".to_string(),
|
|
|
|
},
|
2024-05-21 21:44:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_cellar(open: bool) -> DoorLockedSensor {
|
|
|
|
DoorLockedSensor {
|
|
|
|
value: open,
|
2024-05-21 19:48:14 +00:00
|
|
|
metadata: SensorMetadataWithLocation {
|
|
|
|
name: None,
|
|
|
|
description: None,
|
|
|
|
location: "cellar".to_string(),
|
|
|
|
},
|
2024-05-21 21:44:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn update(the_doors: TheDoors) -> (Sensors, State) {
|
|
|
|
let mut sensors = Sensors::default();
|
|
|
|
sensors.door_locked.push(get_aerie(the_doors.aerie));
|
|
|
|
sensors.door_locked.push(get_cellar(the_doors.cellar));
|
|
|
|
// Open means that any door is open.
|
|
|
|
let state = State {
|
|
|
|
open: Some(the_doors.aerie || the_doors.cellar),
|
|
|
|
..State::default()
|
|
|
|
};
|
|
|
|
(sensors, state)
|
2024-05-21 19:48:14 +00:00
|
|
|
}
|