Compare commits
2 Commits
1e9bd300a6
...
5aaa8b43e9
| Author | SHA1 | Date | |
|---|---|---|---|
|
5aaa8b43e9
|
|||
|
c1475370a9
|
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -1108,7 +1108,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "lua_typed"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.huizinga.dev/Dreaded_X/lua_typed#513b36afdbc23efcf10847f070faff7fcd30f29d"
|
||||
source = "git+https://git.huizinga.dev/Dreaded_X/lua_typed#d30a01aada8f5fc49ad3a296ddbf6e369e08d1f4"
|
||||
dependencies = [
|
||||
"eui48",
|
||||
"lua_typed_macro",
|
||||
@@ -1117,7 +1117,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "lua_typed_macro"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.huizinga.dev/Dreaded_X/lua_typed#513b36afdbc23efcf10847f070faff7fcd30f29d"
|
||||
source = "git+https://git.huizinga.dev/Dreaded_X/lua_typed#d30a01aada8f5fc49ad3a296ddbf6e369e08d1f4"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"itertools",
|
||||
|
||||
@@ -17,7 +17,7 @@ use tracing::{debug, trace};
|
||||
#[typed(as = "AirFilterConfig")]
|
||||
pub struct Config {
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub info: InfoConfig,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
@@ -30,25 +30,25 @@ crate::register_type!(SensorType);
|
||||
#[typed(as = "ContactSensorConfig")]
|
||||
pub struct Config {
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub info: InfoConfig,
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub mqtt: MqttDeviceConfig,
|
||||
|
||||
#[device_config(default(SensorType::Window))]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub sensor_type: SensorType,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub callback: ActionCallback<(ContactSensor, bool)>,
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub battery_callback: ActionCallback<(ContactSensor, f32)>,
|
||||
|
||||
#[device_config(from_lua)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub client: WrappedAsyncClient,
|
||||
}
|
||||
crate::register_type!(Config);
|
||||
|
||||
@@ -14,34 +14,34 @@ use tracing::{debug, trace, warn};
|
||||
#[typed(as = "HueSwitchConfig")]
|
||||
pub struct Config {
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub info: InfoConfig,
|
||||
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub mqtt: MqttDeviceConfig,
|
||||
|
||||
#[device_config(from_lua)]
|
||||
pub client: WrappedAsyncClient,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub left_callback: ActionCallback<HueSwitch>,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub right_callback: ActionCallback<HueSwitch>,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub left_hold_callback: ActionCallback<HueSwitch>,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub right_hold_callback: ActionCallback<HueSwitch>,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub battery_callback: ActionCallback<(HueSwitch, f32)>,
|
||||
}
|
||||
crate::register_type!(Config);
|
||||
|
||||
@@ -14,25 +14,25 @@ use tracing::{debug, error, trace};
|
||||
#[typed(as = "IkeaRemoteConfig")]
|
||||
pub struct Config {
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub info: InfoConfig,
|
||||
|
||||
#[device_config(default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub single_button: bool,
|
||||
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub mqtt: MqttDeviceConfig,
|
||||
|
||||
#[device_config(from_lua)]
|
||||
pub client: WrappedAsyncClient,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub callback: ActionCallback<(IkeaRemote, bool)>,
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub battery_callback: ActionCallback<(IkeaRemote, f32)>,
|
||||
}
|
||||
crate::register_type!(Config);
|
||||
|
||||
@@ -18,13 +18,13 @@ use tracing::{debug, trace, warn};
|
||||
pub struct Config {
|
||||
pub identifier: String,
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub mqtt: MqttDeviceConfig,
|
||||
pub min: isize,
|
||||
pub max: isize,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub callback: ActionCallback<(LightSensor, bool)>,
|
||||
|
||||
#[device_config(from_lua)]
|
||||
|
||||
@@ -24,10 +24,12 @@ crate::register_type!(Priority);
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Typed)]
|
||||
#[serde(rename_all = "snake_case", tag = "action")]
|
||||
#[typed(rename_all = "snake_case", tag = "action")]
|
||||
pub enum ActionType {
|
||||
Broadcast {
|
||||
#[serde(skip_serializing_if = "HashMap::is_empty")]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
extras: HashMap<String, String>,
|
||||
},
|
||||
// View,
|
||||
@@ -37,6 +39,7 @@ pub enum ActionType {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Typed)]
|
||||
pub struct Action {
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub action: ActionType,
|
||||
pub label: String,
|
||||
pub clear: Option<bool>,
|
||||
@@ -47,6 +50,7 @@ crate::register_type!(Action);
|
||||
struct NotificationFinal {
|
||||
topic: String,
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
inner: Notification,
|
||||
}
|
||||
|
||||
@@ -76,7 +80,7 @@ impl Notification {
|
||||
#[typed(as = "NtfyConfig")]
|
||||
pub struct Config {
|
||||
#[device_config(default("https://ntfy.sh".into()))]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub url: String,
|
||||
pub topic: String,
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ use tracing::{debug, trace, warn};
|
||||
#[typed(as = "PresenceConfig")]
|
||||
pub struct Config {
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub mqtt: MqttDeviceConfig,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub callback: ActionCallback<(Presence, bool)>,
|
||||
|
||||
#[device_config(from_lua)]
|
||||
|
||||
@@ -20,14 +20,14 @@ use tracing::{debug, error, trace};
|
||||
#[typed(as = "WolConfig")]
|
||||
pub struct Config {
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub info: InfoConfig,
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub mqtt: MqttDeviceConfig,
|
||||
pub mac_address: MacAddress,
|
||||
#[device_config(default(Ipv4Addr::new(255, 255, 255, 255)))]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub broadcast_ip: Ipv4Addr,
|
||||
#[device_config(from_lua)]
|
||||
pub client: WrappedAsyncClient,
|
||||
|
||||
@@ -18,13 +18,13 @@ use tracing::{debug, error, trace};
|
||||
pub struct Config {
|
||||
pub identifier: String,
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub mqtt: MqttDeviceConfig,
|
||||
// Power in Watt
|
||||
pub threshold: f32,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub done_callback: ActionCallback<Washer>,
|
||||
|
||||
#[device_config(from_lua)]
|
||||
|
||||
@@ -34,18 +34,18 @@ where
|
||||
Light<T>: Typed,
|
||||
{
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub info: InfoConfig,
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub mqtt: MqttDeviceConfig,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub callback: ActionCallback<(Light<T>, T)>,
|
||||
|
||||
#[device_config(from_lua)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub client: WrappedAsyncClient,
|
||||
}
|
||||
crate::register_type!(Config<StateOnOff>);
|
||||
|
||||
@@ -50,17 +50,17 @@ where
|
||||
Outlet<T>: Typed,
|
||||
{
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub info: InfoConfig,
|
||||
#[device_config(flatten)]
|
||||
#[serde(flatten)]
|
||||
#[typed(flatten)]
|
||||
pub mqtt: MqttDeviceConfig,
|
||||
#[device_config(default(OutletType::Outlet))]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub outlet_type: OutletType,
|
||||
|
||||
#[device_config(from_lua, default)]
|
||||
#[serde(default)]
|
||||
#[typed(default)]
|
||||
pub callback: ActionCallback<(Outlet<T>, T)>,
|
||||
|
||||
#[device_config(from_lua)]
|
||||
|
||||
Reference in New Issue
Block a user