added power feature

This commit is contained in:
Wyatt J. Miller
2020-01-03 23:15:13 -05:00
parent 2e6c297a06
commit b4ca32cf0c
3 changed files with 53 additions and 18 deletions

View File

@ -29,6 +29,35 @@ impl Configuration {
pub fn change_active_app(&mut self) {
// stuff happens here
}
pub fn get_tv_status(&self) -> String {
let request = format!(
"http://{ipaddr}:{port}/query/active-app",
ipaddr = self.ipaddr,
port = self.port
);
let response = reqwest::get(&request).unwrap();
let document = Document::from_read(response).unwrap();
let next = document.find(Name("app")).next().unwrap();
next.text().to_string()
}
pub fn get_power_status(&self) -> String {
let request = format!(
"http://{ipaddr}:{port}/query/device-info",
ipaddr = self.ipaddr,
port = self.port
);
let response = reqwest::get(&request).unwrap();
let document = Document::from_read(response).unwrap();
let next = document.find(Name("power-mode")).next().unwrap();
next.text().to_string()
}
}
// grab the config
@ -41,17 +70,3 @@ pub fn init_config() -> Configuration {
config
}
pub fn get_tv_status(configuration: &Configuration) -> String {
let request = format!(
"http://{ipaddr}:{port}/query/active-app",
ipaddr = configuration.ipaddr,
port = configuration.port
);
let response = reqwest::get(&request).unwrap();
//println!("{}", response.status());
let document = Document::from_read(response).unwrap();
let next = document.find(Name("app")).next().unwrap();
next.text().to_string()
}