Compare commits

..

No commits in common. "af3a618529a8f1b5f2d58f8138007c59fd2ba27d" and "dca67cb66e2bf546e520fda3b0f6de879d40c4a7" have entirely different histories.

7 changed files with 21 additions and 22 deletions

2
Cargo.lock generated
View file

@ -1143,7 +1143,7 @@ dependencies = [
[[package]]
name = "homekit-exporter"
version = "0.4.0"
version = "0.3.0"
dependencies = [
"clap",
"env_logger",

View file

@ -21,7 +21,6 @@ use crate::{
ConnectionError, HomekitError,
};
#[derive(Debug)]
pub(super) struct AccessorySocket {
socket: TcpStream,
ip: String,
@ -29,7 +28,6 @@ pub(super) struct AccessorySocket {
socket_encryption: Option<SocketEncryption>,
}
#[derive(Debug)]
struct SocketEncryption {
controller_to_accessory_key: [u8; 32],
controller_to_accessory_counter: u64,

View file

@ -60,7 +60,6 @@ impl PythonPairingData {
}
}
#[derive(Debug)]
struct DevicePairingData {
accessory_pairing_id: String,
accessory_ip: String,
@ -70,7 +69,6 @@ struct DevicePairingData {
ios_device_ltsk: [u8; 32],
}
#[derive(Debug)]
pub struct DeviceConnection {
pub accessories: HashMap<usize, Accessory>,
discovered: MdnsDiscoveredList,

View file

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

View file

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

View file

@ -5,9 +5,7 @@ use std::{collections::HashMap, path::PathBuf, time::Duration};
use clap::{Parser, Subcommand};
use futures_util::{pin_mut, StreamExt};
use homekit_controller::{
spawn_discover_thread, CharacteristicType, DeviceConnection, HomekitError,
};
use homekit_controller::{spawn_discover_thread, DeviceConnection, HomekitError, ServiceType};
use server::launch;
mod server;
@ -31,14 +29,18 @@ enum Commands {
Discover,
}
const MONITORED_CHARACTERISTICS: [CharacteristicType; 7] = [
CharacteristicType::CurrentTemperature,
CharacteristicType::PM2_5Density,
CharacteristicType::PM10Density,
CharacteristicType::AirQuality,
CharacteristicType::CurrentRelativeHumidity,
CharacteristicType::AirParticulateDensity,
CharacteristicType::AirParticulateSize,
const SENSORS: [ServiceType; 11] = [
ServiceType::AirQualitySensor,
ServiceType::CarbonDioxideSensor,
ServiceType::CarbonMonoxideSensor,
ServiceType::ContactSensor,
ServiceType::HumiditySensor,
ServiceType::LeakSensor,
ServiceType::LightSensor,
ServiceType::MotionSensor,
ServiceType::OccupancySensor,
ServiceType::SmokeSensor,
ServiceType::TemperatureSensor,
];
#[launch]

View file

@ -3,7 +3,7 @@ use rocket::State;
use std::{collections::HashMap, ops::DerefMut};
use tokio::sync::Mutex;
use crate::MONITORED_CHARACTERISTICS;
use crate::SENSORS;
pub fn launch(
paired: HashMap<String, DeviceConnection>,
@ -25,10 +25,11 @@ pub async fn metrics(state: &State<Mutex<HashMap<String, DeviceConnection>>>) ->
for (aid, accessory) in &connected.accessories {
for service in accessory.services.values() {
for (cid, characteristic) in &service.characteristics {
if !MONITORED_CHARACTERISTICS.contains(&characteristic.characteristic_type) {
if !SENSORS.contains(&service.service_type) {
continue;
}
for (cid, characteristic) in &service.characteristics {
if let Some(value) = &characteristic.value {
if !shown_types.contains(&characteristic.characteristic_type) {
s.push_str(