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