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
|
|
@ -12,8 +12,7 @@ pub struct ApiLock {
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Deserialize)]
|
#[derive(Debug, Eq, PartialEq, Hash, Deserialize)]
|
||||||
pub struct ApiLockStatus {
|
pub struct ApiLockStatus {
|
||||||
pub is_unreachable: bool,
|
pub is_unreachable: bool,
|
||||||
#[serde(default)]
|
pub is_low_battery: bool,
|
||||||
pub is_low_batteray: bool,
|
|
||||||
pub is_error_jammed: bool,
|
pub is_error_jammed: bool,
|
||||||
pub lock_target_level: LockTargetLevel,
|
pub lock_target_level: LockTargetLevel,
|
||||||
pub lock_state: LockState,
|
pub lock_state: LockState,
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ async fn main() -> eyre::Result<()> {
|
||||||
let lock = find_lock(&api, &lock_name).await?;
|
let lock = find_lock(&api, &lock_name).await?;
|
||||||
|
|
||||||
println!("dooris at your service, locking {} now…", lock.name);
|
println!("dooris at your service, locking {} now…", lock.name);
|
||||||
|
print_lock_warnings(&lock);
|
||||||
api.operate_lock(&lock.id, DesiredLockState::CLOSED).await?;
|
api.operate_lock(&lock.id, DesiredLockState::CLOSED).await?;
|
||||||
|
|
||||||
if wait_until_done {
|
if wait_until_done {
|
||||||
|
|
@ -91,6 +92,7 @@ async fn main() -> eyre::Result<()> {
|
||||||
let lock = find_lock(&api, &lock_name).await?;
|
let lock = find_lock(&api, &lock_name).await?;
|
||||||
|
|
||||||
println!("dooris at your service, unlocking {} now…", lock.name);
|
println!("dooris at your service, unlocking {} now…", lock.name);
|
||||||
|
print_lock_warnings(&lock);
|
||||||
api.operate_lock(&lock.id, DesiredLockState::OPEN).await?;
|
api.operate_lock(&lock.id, DesiredLockState::OPEN).await?;
|
||||||
|
|
||||||
if wait_until_done {
|
if wait_until_done {
|
||||||
|
|
@ -108,15 +110,7 @@ async fn main() -> eyre::Result<()> {
|
||||||
|
|
||||||
for i_lock in locks.iter() {
|
for i_lock in locks.iter() {
|
||||||
println!(">> {}", i_lock.name);
|
println!(">> {}", i_lock.name);
|
||||||
if i_lock.status.is_unreachable {
|
print_lock_warnings(&lock);
|
||||||
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 !!!");
|
|
||||||
}
|
|
||||||
println!(" State: {:?}", i_lock.status.lock_state);
|
println!(" State: {:?}", i_lock.status.lock_state);
|
||||||
println!(" Desired State: {:?}", i_lock.status.lock_target_level);
|
println!(" Desired State: {:?}", i_lock.status.lock_target_level);
|
||||||
println!(" Acitivty: {:?}", i_lock.status.activity_state);
|
println!(" Acitivty: {:?}", i_lock.status.activity_state);
|
||||||
|
|
@ -164,3 +158,33 @@ async fn wait_for_lock_state(
|
||||||
|
|
||||||
Ok(())
|
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