Compare commits

...

3 commits

7 changed files with 32 additions and 12 deletions

4
Cargo.lock generated
View file

@ -1155,7 +1155,7 @@ dependencies = [
[[package]] [[package]]
name = "homekit-controller" name = "homekit-controller"
version = "0.5.5" version = "0.6.2"
dependencies = [ dependencies = [
"chacha20poly1305", "chacha20poly1305",
"ed25519-dalek", "ed25519-dalek",
@ -1178,7 +1178,7 @@ dependencies = [
[[package]] [[package]]
name = "homekit-exporter" name = "homekit-exporter"
version = "0.6.1" version = "0.6.2"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap", "clap",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "homekit-controller" name = "homekit-controller"
version = "0.5.5" version = "0.6.2"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Partial implementation of the HomeKit controller protocol" description = "Partial implementation of the HomeKit controller protocol"

View file

@ -311,15 +311,17 @@ impl DeviceConnection {
self.characteristics_request(true), self.characteristics_request(true),
) )
.await .await
.map_err(|_| HomekitError::Timeout)
.flatten_result()
{ {
Ok(r) => r, Ok(r) => Ok(r),
Err(_) => { Err(e) => {
log::warn!( log::warn!(
"{}failed to update characteristics", "{}failed to update characteristics: {e:?}",
formatted_name(&self.name) formatted_name(&self.name)
); );
self.socket = None; self.socket = None;
Err(HomekitError::Timeout) Err(e)
} }
} }
} }
@ -432,6 +434,24 @@ pub enum HomekitError {
NoData, NoData,
} }
trait FlattenResult {
type T;
type E;
fn flatten_result(self) -> Result<Self::T, Self::E>;
}
impl<T, E> FlattenResult for Result<Result<T, E>, E> {
type T = T;
type E = E;
fn flatten_result(self) -> Result<Self::T, Self::E> {
match self {
Ok(v) => v,
Err(e) => Err(e),
}
}
}
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum ConnectionError { pub enum ConnectionError {
#[error("http")] #[error("http")]

View file

@ -686,7 +686,7 @@ impl From<CharacteristicTypeInner> for CharacteristicType {
fn from(value: CharacteristicTypeInner) -> Self { fn from(value: CharacteristicTypeInner) -> Self {
match value { match value {
CharacteristicTypeInner::Unknown(v) => { CharacteristicTypeInner::Unknown(v) => {
log::info!("unknown characteristic type: {v}"); log::debug!("unknown characteristic type: {v}");
Self::Unknown Self::Unknown
} }
CharacteristicTypeInner::AccessControlLevel => Self::AccessControlLevel, CharacteristicTypeInner::AccessControlLevel => Self::AccessControlLevel,
@ -1206,7 +1206,7 @@ impl From<ServiceTypeInner> for ServiceType {
fn from(value: ServiceTypeInner) -> Self { fn from(value: ServiceTypeInner) -> Self {
match value { match value {
ServiceTypeInner::Unknown(v) => { ServiceTypeInner::Unknown(v) => {
log::info!("unknown service type: {v}"); log::debug!("unknown service type: {v}");
Self::Unknown Self::Unknown
} }
ServiceTypeInner::AccessControl => Self::AccessControl, ServiceTypeInner::AccessControl => Self::AccessControl,

View file

@ -1,6 +1,6 @@
[package] [package]
name = "homekit-exporter" name = "homekit-exporter"
version = "0.6.1" version = "0.6.2"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Prometheus exporter for HomeKit sensors" description = "Prometheus exporter for HomeKit sensors"

View file

@ -1,7 +1,7 @@
# Maintainer: Alex Janka <alex@alexjanka.com> # Maintainer: Alex Janka <alex@alexjanka.com>
pkgname=homekit-logger pkgname=homekit-logger
pkgver=0.6.1 pkgver=0.6.2
pkgrel=1 pkgrel=1
pkgdesc="Prometheus exporter for HomeKit sensors" pkgdesc="Prometheus exporter for HomeKit sensors"
arch=('x86_64' 'aarch64') arch=('x86_64' 'aarch64')

View file

@ -7,7 +7,7 @@ StartLimitIntervalSec=0
Type=simple Type=simple
Restart=always Restart=always
RestartSec=10s RestartSec=10s
Environment="RUST_LOG=error,warn,mdns=off,homekit_controller::pairing_data::characteristics=off" Environment="RUST_LOG=warn,mdns=off"
Environment="LOG_TIMESTAMP=false" Environment="LOG_TIMESTAMP=false"
ExecStart=/usr/bin/homekit-exporter watch ExecStart=/usr/bin/homekit-exporter watch