display lock warnings on every operation not just show-locks
Some checks failed
Build Container / Build Container (push) Failing after 2m43s
Some checks failed
Build Container / Build Container (push) Failing after 2m43s
This commit is contained in:
parent
d0a865e85a
commit
5850cff536
2 changed files with 34 additions and 11 deletions
|
|
@ -72,6 +72,7 @@ async fn main() -> eyre::Result<()> {
|
|||
let lock = find_lock(&api, &lock_name).await?;
|
||||
|
||||
println!("dooris at your service, locking {} now…", lock.name);
|
||||
print_lock_warnings(&lock);
|
||||
api.operate_lock(&lock.id, DesiredLockState::CLOSED).await?;
|
||||
|
||||
if wait_until_done {
|
||||
|
|
@ -91,6 +92,7 @@ async fn main() -> eyre::Result<()> {
|
|||
let lock = find_lock(&api, &lock_name).await?;
|
||||
|
||||
println!("dooris at your service, unlocking {} now…", lock.name);
|
||||
print_lock_warnings(&lock);
|
||||
api.operate_lock(&lock.id, DesiredLockState::OPEN).await?;
|
||||
|
||||
if wait_until_done {
|
||||
|
|
@ -108,15 +110,7 @@ async fn main() -> eyre::Result<()> {
|
|||
|
||||
for i_lock in locks.iter() {
|
||||
println!(">> {}", i_lock.name);
|
||||
if i_lock.status.is_unreachable {
|
||||
println!(" !!! Lock is currently unreachable !!!");
|
||||
}
|
||||
if i_lock.status.is_low_batteray {
|
||||
println!(" !!! Lock has low battery !!!");
|
||||
}
|
||||
if i_lock.status.is_error_jammed {
|
||||
println!(" !!! Lock is jammed !!!");
|
||||
}
|
||||
print_lock_warnings(&lock);
|
||||
println!(" State: {:?}", i_lock.status.lock_state);
|
||||
println!(" Desired State: {:?}", i_lock.status.lock_target_level);
|
||||
println!(" Acitivty: {:?}", i_lock.status.activity_state);
|
||||
|
|
@ -164,3 +158,33 @@ async fn wait_for_lock_state(
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Display big warnings if the lock is in an error state like jammed/disconnected/low battery
|
||||
fn print_lock_warnings(lock: &ApiLock) {
|
||||
let has_any_error =
|
||||
lock.status.is_unreachable || lock.status.is_low_battery || lock.status.is_error_jammed;
|
||||
|
||||
if has_any_error {
|
||||
println!(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
}
|
||||
|
||||
if lock.status.is_unreachable {
|
||||
println!(" !!! !!!");
|
||||
println!(" !!! Lock is currently unreachable !!!");
|
||||
println!(" !!! !!!");
|
||||
}
|
||||
if lock.status.is_low_battery {
|
||||
println!(" !!! !!!");
|
||||
println!(" !!! Lock has low battery !!!");
|
||||
println!(" !!! !!!");
|
||||
}
|
||||
if lock.status.is_error_jammed {
|
||||
println!(" !!! !!!");
|
||||
println!(" !!! Lock is jammed !!!");
|
||||
println!(" !!! !!!");
|
||||
}
|
||||
|
||||
if has_any_error {
|
||||
println!(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue