Visualise muted media player

This commit is contained in:
Erwin Boskma 2022-04-07 21:18:45 +02:00
parent ae1a579aa2
commit 6ffcd126e4
Signed by: erwin
GPG key ID: 270B20D17394F7E5

View file

@ -226,8 +226,11 @@ impl HomeAssistant {
let artist = attributes["media_artist"].as_str().unwrap_or("No artist"); let artist = attributes["media_artist"].as_str().unwrap_or("No artist");
let title = attributes["media_title"].as_str().unwrap_or("No title"); let title = attributes["media_title"].as_str().unwrap_or("No title");
let volume_raw = attributes["volume_level"].as_f64().unwrap_or(-1.); let volume_raw = attributes["volume_level"].as_f64().unwrap_or(-1.);
let is_muted = attributes["is_volume_muted"].as_bool().unwrap_or(false);
let volume = if volume_raw >= 0. { let volume = if is_muted {
String::from("[ ﱝ ]")
} else if volume_raw >= 0. {
format!("[{:3.0}%] ", volume_raw * 100.) format!("[{:3.0}%] ", volume_raw * 100.)
} else { } else {
String::new() String::new()