Compare commits
3 Commits
f7194bcc5a
...
ac00dc0329
Author | SHA1 | Date | |
---|---|---|---|
ac00dc0329 | |||
73a2b077ed | |||
78bb80d510 |
49
.drone.yml
49
.drone.yml
|
@ -1,49 +0,0 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: docker
|
||||
volumes:
|
||||
- name: socket
|
||||
path: /var/run/docker.sock
|
||||
commands:
|
||||
- DOCKER_BUILDKIT=1 docker build -t automation_rs .
|
||||
|
||||
- name: deploy
|
||||
image: docker
|
||||
volumes:
|
||||
- name: socket
|
||||
path: /var/run/docker.sock
|
||||
environment:
|
||||
MQTT_PASSWORD:
|
||||
from_secret: MQTT_PASSWORD
|
||||
HUE_TOKEN:
|
||||
from_secret: HUE_TOKEN
|
||||
NTFY_TOPIC:
|
||||
from_secret: NTFY_TOPIC
|
||||
RUST_LOG:
|
||||
from_secret: RUST_LOG
|
||||
commands:
|
||||
- docker stop automation_rs || true
|
||||
|
||||
- docker rm automation_rs || true
|
||||
|
||||
# Networks need to be setup to to allow broadcasts: https://www.devwithimagination.com/2020/06/15/homebridge-docker-and-wake-on-lan/ https://github.com/dhutchison/container-images/blob/0c2d7d96bab751fb0a008cc91ba2990724bbd11f/homebridge/configure_docker_networks_for_wol.sh
|
||||
# Needs to be done for ALL networks, because we can't seem to control which interface gets used to send the broadcast
|
||||
- docker create -e RUST_LOG=$RUST_LOG -e MQTT_PASSWORD=$MQTT_PASSWORD -e HUE_TOKEN=$HUE_TOKEN -e NTFY_TOPIC=$NTFY_TOPIC --network mqtt --restart unless-stopped --name automation_rs automation_rs
|
||||
- docker network connect web automation_rs
|
||||
- docker start automation_rs
|
||||
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
volumes:
|
||||
- name: socket
|
||||
host:
|
||||
path: /var/run/docker.sock
|
73
.gitea/workflows/build.yml
Normal file
73
.gitea/workflows/build.yml
Normal file
|
@ -0,0 +1,73 @@
|
|||
# Based on: https://pastebin.com/99Fq2b2w
|
||||
name: Build and deploy automation_rs
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- feature/actions
|
||||
|
||||
jobs:
|
||||
|
||||
format:
|
||||
name: cargo fmt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
- name: Rustfmt check
|
||||
uses: actions-rust-lang/rustfmt@v1
|
||||
|
||||
clippy:
|
||||
name: cargo clippy
|
||||
runs-on: ubuntu-latest
|
||||
needs: [format]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
- name: Clippy
|
||||
run: cargo clippy --all-targets --all -- -D warnings
|
||||
|
||||
build:
|
||||
name: cargo build
|
||||
runs-on: ubuntu-latest
|
||||
needs: [clippy]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
|
||||
# create-docker-container:
|
||||
# name: docker build
|
||||
# runs-on: ubuntu-latest
|
||||
# needs: [build]
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - uses: Swatinem/rust-cache@v2
|
||||
# with:
|
||||
# shared-key: "automation_rs"
|
||||
# - run: ls -alh
|
||||
|
||||
# create-docker-container:
|
||||
# runs-on: ubuntu-latest
|
||||
# container: catthehacker/ubuntu:act-latest
|
||||
# steps:
|
||||
# - name: Checkout repository
|
||||
# uses: https://github.com/actions/checkout@v3
|
||||
#
|
||||
# - name: Set up Docker BuildX
|
||||
# uses: https://github.com/docker/setup-buildx-action@v3
|
||||
#
|
||||
# - name: Login to registry
|
||||
# uses: https://github.com/docker/login-action@v3
|
||||
# with:
|
||||
# registry: git.huizinga.dev
|
||||
# username: ${{ gitea.actor }}
|
||||
# password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
#
|
||||
# - name: Build and push Docker image
|
||||
# uses: https://github.com/docker/build-push-action@v5
|
||||
# with:
|
||||
# context: .
|
||||
# push: true
|
||||
# tags: git.huizinga.dev/dreaded_x/automation_rs:latest
|
2
.rustfmt.toml
Normal file
2
.rustfmt.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
imports_granularity = "Module"
|
||||
group_imports = "StdExternalCrate"
|
|
@ -110,7 +110,7 @@ devices:
|
|||
!ContactSensor
|
||||
topic: "zigbee2mqtt/hallway/frontdoor"
|
||||
presence:
|
||||
topic: "automation_dev/presence/contact/frontdoor"
|
||||
topic: "automation/presence/contact/frontdoor"
|
||||
timeout: 900
|
||||
trigger:
|
||||
devices: ["hallway_lights"]
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use async_trait::async_trait;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{
|
||||
errors::{DeviceError, ErrorCode},
|
||||
request::execute::CommandType,
|
||||
response,
|
||||
traits::{FanSpeed, OnOff, Scene, Trait},
|
||||
types::Type,
|
||||
};
|
||||
use crate::errors::{DeviceError, ErrorCode};
|
||||
use crate::request::execute::CommandType;
|
||||
use crate::response;
|
||||
use crate::traits::{FanSpeed, OnOff, Scene, Trait};
|
||||
use crate::types::Type;
|
||||
|
||||
// TODO: Find a more elegant way to do this
|
||||
pub trait AsGoogleHomeDevice {
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
use std::{collections::HashMap, sync::Arc};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::future::{join_all, OptionFuture};
|
||||
use thiserror::Error;
|
||||
use tokio::sync::{Mutex, RwLock};
|
||||
|
||||
use crate::{
|
||||
device::AsGoogleHomeDevice,
|
||||
errors::{DeviceError, ErrorCode},
|
||||
request::{self, Intent, Request},
|
||||
response::{self, execute, query, sync, Response, ResponsePayload, State},
|
||||
};
|
||||
use crate::device::AsGoogleHomeDevice;
|
||||
use crate::errors::{DeviceError, ErrorCode};
|
||||
use crate::request::{self, Intent, Request};
|
||||
use crate::response::{self, execute, query, sync, Response, ResponsePayload, State};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct GoogleHome {
|
||||
|
|
|
@ -13,7 +13,6 @@ pub mod traits;
|
|||
pub mod types;
|
||||
|
||||
pub use device::GoogleHomeDevice;
|
||||
pub use fullfillment::FullfillmentError;
|
||||
pub use fullfillment::GoogleHome;
|
||||
pub use fullfillment::{FullfillmentError, GoogleHome};
|
||||
pub use request::Request;
|
||||
pub use response::Response;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use crate::{errors::ErrorCode, response::State};
|
||||
use crate::errors::ErrorCode;
|
||||
use crate::response::State;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -87,10 +88,8 @@ pub enum Status {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
errors::DeviceError,
|
||||
response::{Response, ResponsePayload, State},
|
||||
};
|
||||
use crate::errors::DeviceError;
|
||||
use crate::response::{Response, ResponsePayload, State};
|
||||
|
||||
#[test]
|
||||
fn serialize() {
|
||||
|
|
|
@ -2,7 +2,8 @@ use std::collections::HashMap;
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{errors::ErrorCode, response::State};
|
||||
use crate::errors::ErrorCode;
|
||||
use crate::response::State;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
|
@ -69,11 +69,9 @@ impl Device {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
response::{Response, ResponsePayload},
|
||||
traits::Trait,
|
||||
types::Type,
|
||||
};
|
||||
use crate::response::{Response, ResponsePayload};
|
||||
use crate::traits::Trait;
|
||||
use crate::types::Type;
|
||||
|
||||
#[test]
|
||||
fn serialize() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use proc_macro::TokenStream;
|
||||
use quote::{format_ident, quote, ToTokens};
|
||||
use syn::{parse::Parse, parse_macro_input, Ident, ItemTrait, Path, Token, TypeParamBound};
|
||||
use syn::parse::Parse;
|
||||
use syn::{parse_macro_input, Ident, ItemTrait, Path, Token, TypeParamBound};
|
||||
|
||||
struct Attr {
|
||||
name: Ident,
|
||||
|
|
4
rust-toolchain.toml
Normal file
4
rust-toolchain.toml
Normal file
|
@ -0,0 +1,4 @@
|
|||
[toolchain]
|
||||
channel = "nightly-2023-11-15"
|
||||
components = ["rustfmt", "clippy"]
|
||||
profile = "minimal"
|
|
@ -1,8 +1,7 @@
|
|||
use axum::{
|
||||
async_trait,
|
||||
extract::{FromRef, FromRequestParts},
|
||||
http::{request::Parts, StatusCode},
|
||||
};
|
||||
use axum::async_trait;
|
||||
use axum::extract::{FromRef, FromRequestParts};
|
||||
use axum::http::request::Parts;
|
||||
use axum::http::StatusCode;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::error::{ApiError, ApiErrorJson};
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::{
|
||||
fs,
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
time::Duration,
|
||||
};
|
||||
use std::fs;
|
||||
use std::net::{Ipv4Addr, SocketAddr};
|
||||
use std::time::Duration;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use regex::{Captures, Regex};
|
||||
|
@ -10,13 +8,11 @@ use rumqttc::{MqttOptions, Transport};
|
|||
use serde::{Deserialize, Deserializer};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::{
|
||||
auth::OpenIDConfig,
|
||||
device_manager::DeviceConfigs,
|
||||
devices::PresenceConfig,
|
||||
error::{ConfigParseError, MissingEnv},
|
||||
schedule::Schedule,
|
||||
};
|
||||
use crate::auth::OpenIDConfig;
|
||||
use crate::device_manager::DeviceConfigs;
|
||||
use crate::devices::PresenceConfig;
|
||||
use crate::error::{ConfigParseError, MissingEnv};
|
||||
use crate::schedule::Schedule;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Config {
|
||||
|
|
|
@ -11,19 +11,14 @@ use tokio::sync::{RwLock, RwLockReadGuard};
|
|||
use tokio_cron_scheduler::{Job, JobScheduler};
|
||||
use tracing::{debug, error, instrument, trace};
|
||||
|
||||
use crate::{
|
||||
devices::{
|
||||
AirFilterConfig, As, AudioSetupConfig, ContactSensorConfig, DebugBridgeConfig, Device,
|
||||
HueBridgeConfig, HueGroupConfig, IkeaOutletConfig, KasaOutletConfig, LightSensorConfig,
|
||||
WakeOnLANConfig, WasherConfig,
|
||||
},
|
||||
error::DeviceConfigError,
|
||||
event::OnDarkness,
|
||||
event::OnNotification,
|
||||
event::OnPresence,
|
||||
event::{Event, EventChannel, OnMqtt},
|
||||
schedule::{Action, Schedule},
|
||||
use crate::devices::{
|
||||
AirFilterConfig, As, AudioSetupConfig, ContactSensorConfig, DebugBridgeConfig, Device,
|
||||
HueBridgeConfig, HueGroupConfig, IkeaOutletConfig, KasaOutletConfig, LightSensorConfig,
|
||||
WakeOnLANConfig, WasherConfig,
|
||||
};
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::{Event, EventChannel, OnDarkness, OnMqtt, OnNotification, OnPresence};
|
||||
use crate::schedule::{Action, Schedule};
|
||||
|
||||
pub struct ConfigExternal<'a> {
|
||||
pub client: &'a AsyncClient,
|
||||
|
|
|
@ -3,17 +3,13 @@ use google_home::traits::OnOff;
|
|||
use serde::Deserialize;
|
||||
use tracing::{debug, error, trace, warn};
|
||||
|
||||
use crate::{
|
||||
config::MqttDeviceConfig,
|
||||
device_manager::{ConfigExternal, DeviceConfig, WrappedDevice},
|
||||
devices::As,
|
||||
error::DeviceConfigError,
|
||||
event::OnMqtt,
|
||||
event::OnPresence,
|
||||
messages::{RemoteAction, RemoteMessage},
|
||||
};
|
||||
|
||||
use super::Device;
|
||||
use crate::config::MqttDeviceConfig;
|
||||
use crate::device_manager::{ConfigExternal, DeviceConfig, WrappedDevice};
|
||||
use crate::devices::As;
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::{OnMqtt, OnPresence};
|
||||
use crate::messages::{RemoteAction, RemoteMessage};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct AudioSetupConfig {
|
||||
|
|
|
@ -8,18 +8,14 @@ use serde_with::{serde_as, DurationSeconds};
|
|||
use tokio::task::JoinHandle;
|
||||
use tracing::{debug, error, trace, warn};
|
||||
|
||||
use crate::{
|
||||
config::MqttDeviceConfig,
|
||||
device_manager::{ConfigExternal, DeviceConfig, WrappedDevice},
|
||||
devices::{As, DEFAULT_PRESENCE},
|
||||
error::DeviceConfigError,
|
||||
event::OnMqtt,
|
||||
event::OnPresence,
|
||||
messages::{ContactMessage, PresenceMessage},
|
||||
traits::Timeout,
|
||||
};
|
||||
|
||||
use super::Device;
|
||||
use crate::config::MqttDeviceConfig;
|
||||
use crate::device_manager::{ConfigExternal, DeviceConfig, WrappedDevice};
|
||||
use crate::devices::{As, DEFAULT_PRESENCE};
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::{OnMqtt, OnPresence};
|
||||
use crate::messages::{ContactMessage, PresenceMessage};
|
||||
use crate::traits::Timeout;
|
||||
|
||||
// NOTE: If we add more presence devices we might need to move this out of here
|
||||
#[serde_as]
|
||||
|
|
|
@ -3,16 +3,12 @@ use rumqttc::AsyncClient;
|
|||
use serde::Deserialize;
|
||||
use tracing::warn;
|
||||
|
||||
use crate::device_manager::ConfigExternal;
|
||||
use crate::device_manager::DeviceConfig;
|
||||
use crate::config::MqttDeviceConfig;
|
||||
use crate::device_manager::{ConfigExternal, DeviceConfig};
|
||||
use crate::devices::Device;
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::OnDarkness;
|
||||
use crate::event::OnPresence;
|
||||
use crate::{
|
||||
config::MqttDeviceConfig,
|
||||
messages::{DarknessMessage, PresenceMessage},
|
||||
};
|
||||
use crate::event::{OnDarkness, OnPresence};
|
||||
use crate::messages::{DarknessMessage, PresenceMessage};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct DebugBridgeConfig {
|
||||
|
|
|
@ -4,13 +4,10 @@ use async_trait::async_trait;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use tracing::{error, trace, warn};
|
||||
|
||||
use crate::{
|
||||
device_manager::{ConfigExternal, DeviceConfig},
|
||||
devices::Device,
|
||||
error::DeviceConfigError,
|
||||
event::OnDarkness,
|
||||
event::OnPresence,
|
||||
};
|
||||
use crate::device_manager::{ConfigExternal, DeviceConfig};
|
||||
use crate::devices::Device;
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::{OnDarkness, OnPresence};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Flag {
|
||||
|
|
|
@ -1,25 +1,21 @@
|
|||
use std::{
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
time::Duration,
|
||||
};
|
||||
use std::net::{Ipv4Addr, SocketAddr};
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use google_home::{errors::ErrorCode, traits::OnOff};
|
||||
use google_home::errors::ErrorCode;
|
||||
use google_home::traits::OnOff;
|
||||
use rumqttc::Publish;
|
||||
use serde::Deserialize;
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use crate::{
|
||||
config::MqttDeviceConfig,
|
||||
device_manager::{ConfigExternal, DeviceConfig},
|
||||
error::DeviceConfigError,
|
||||
event::OnMqtt,
|
||||
messages::{RemoteAction, RemoteMessage},
|
||||
traits::Timeout,
|
||||
};
|
||||
|
||||
use super::Device;
|
||||
use crate::config::MqttDeviceConfig;
|
||||
use crate::device_manager::{ConfigExternal, DeviceConfig};
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::OnMqtt;
|
||||
use crate::messages::{RemoteAction, RemoteMessage};
|
||||
use crate::traits::Timeout;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct HueGroupConfig {
|
||||
|
@ -229,7 +225,8 @@ impl Timeout for HueGroup {
|
|||
mod message {
|
||||
use std::time::Duration;
|
||||
|
||||
use serde::{ser::SerializeStruct, Deserialize, Serialize};
|
||||
use serde::ser::SerializeStruct;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Action {
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use google_home::errors::ErrorCode;
|
||||
use google_home::{
|
||||
device,
|
||||
traits::{self, OnOff},
|
||||
types::Type,
|
||||
GoogleHomeDevice,
|
||||
};
|
||||
use google_home::traits::{self, OnOff};
|
||||
use google_home::types::Type;
|
||||
use google_home::{device, GoogleHomeDevice};
|
||||
use rumqttc::{matches, AsyncClient, Publish};
|
||||
use serde::Deserialize;
|
||||
use serde_with::serde_as;
|
||||
use serde_with::DurationSeconds;
|
||||
use std::time::Duration;
|
||||
use serde_with::{serde_as, DurationSeconds};
|
||||
use tokio::task::JoinHandle;
|
||||
use tracing::{debug, error, trace, warn};
|
||||
|
||||
|
@ -19,8 +16,7 @@ use crate::config::{InfoConfig, MqttDeviceConfig};
|
|||
use crate::device_manager::{ConfigExternal, DeviceConfig};
|
||||
use crate::devices::Device;
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::OnMqtt;
|
||||
use crate::event::OnPresence;
|
||||
use crate::event::{OnMqtt, OnPresence};
|
||||
use crate::messages::{OnOffMessage, RemoteAction, RemoteMessage};
|
||||
use crate::traits::Timeout;
|
||||
|
||||
|
|
|
@ -1,28 +1,19 @@
|
|||
use std::{
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
str::Utf8Error,
|
||||
};
|
||||
use std::net::{Ipv4Addr, SocketAddr};
|
||||
use std::str::Utf8Error;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use bytes::{Buf, BufMut};
|
||||
use google_home::{
|
||||
errors::{self, DeviceError},
|
||||
traits,
|
||||
};
|
||||
use google_home::errors::{self, DeviceError};
|
||||
use google_home::traits;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
use tokio::{
|
||||
io::{AsyncReadExt, AsyncWriteExt},
|
||||
net::TcpStream,
|
||||
};
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio::net::TcpStream;
|
||||
use tracing::trace;
|
||||
|
||||
use crate::{
|
||||
device_manager::{ConfigExternal, DeviceConfig},
|
||||
error::DeviceConfigError,
|
||||
};
|
||||
|
||||
use super::Device;
|
||||
use crate::device_manager::{ConfigExternal, DeviceConfig};
|
||||
use crate::error::DeviceConfigError;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct KasaOutletConfig {
|
||||
|
|
|
@ -3,15 +3,12 @@ use rumqttc::Publish;
|
|||
use serde::Deserialize;
|
||||
use tracing::{debug, trace, warn};
|
||||
|
||||
use crate::{
|
||||
config::MqttDeviceConfig,
|
||||
device_manager::{ConfigExternal, DeviceConfig},
|
||||
devices::Device,
|
||||
error::DeviceConfigError,
|
||||
event::OnMqtt,
|
||||
event::{self, Event},
|
||||
messages::BrightnessMessage,
|
||||
};
|
||||
use crate::config::MqttDeviceConfig;
|
||||
use crate::device_manager::{ConfigExternal, DeviceConfig};
|
||||
use crate::devices::Device;
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::{self, Event, OnMqtt};
|
||||
use crate::messages::BrightnessMessage;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct LightSensorConfig {
|
||||
|
|
|
@ -12,6 +12,9 @@ mod presence;
|
|||
mod wake_on_lan;
|
||||
mod washer;
|
||||
|
||||
use google_home::device::AsGoogleHomeDevice;
|
||||
use google_home::traits::OnOff;
|
||||
|
||||
pub use self::air_filter::AirFilterConfig;
|
||||
pub use self::audio_setup::AudioSetupConfig;
|
||||
pub use self::contact_sensor::ContactSensorConfig;
|
||||
|
@ -25,11 +28,8 @@ pub use self::ntfy::{Notification, Ntfy};
|
|||
pub use self::presence::{Presence, PresenceConfig, DEFAULT_PRESENCE};
|
||||
pub use self::wake_on_lan::WakeOnLANConfig;
|
||||
pub use self::washer::WasherConfig;
|
||||
|
||||
use google_home::{device::AsGoogleHomeDevice, traits::OnOff};
|
||||
|
||||
use crate::event::{OnDarkness, OnMqtt, OnNotification, OnPresence};
|
||||
use crate::traits::Timeout;
|
||||
use crate::{event::OnDarkness, event::OnMqtt, event::OnNotification, event::OnPresence};
|
||||
|
||||
#[impl_cast::device(As: OnMqtt + OnPresence + OnDarkness + OnNotification + OnOff + Timeout)]
|
||||
pub trait Device: AsGoogleHomeDevice + std::fmt::Debug + Sync + Send {
|
||||
|
|
|
@ -5,12 +5,9 @@ use serde::Serialize;
|
|||
use serde_repr::*;
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use crate::{
|
||||
config::NtfyConfig,
|
||||
devices::Device,
|
||||
event::{self, Event, EventChannel},
|
||||
event::{OnNotification, OnPresence},
|
||||
};
|
||||
use crate::config::NtfyConfig;
|
||||
use crate::devices::Device;
|
||||
use crate::event::{self, Event, EventChannel, OnNotification, OnPresence};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Ntfy {
|
||||
|
|
|
@ -5,13 +5,10 @@ use rumqttc::Publish;
|
|||
use serde::Deserialize;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use crate::{
|
||||
config::MqttDeviceConfig,
|
||||
devices::Device,
|
||||
event::OnMqtt,
|
||||
event::{self, Event, EventChannel},
|
||||
messages::PresenceMessage,
|
||||
};
|
||||
use crate::config::MqttDeviceConfig;
|
||||
use crate::devices::Device;
|
||||
use crate::event::{self, Event, EventChannel, OnMqtt};
|
||||
use crate::messages::PresenceMessage;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct PresenceConfig {
|
||||
|
|
|
@ -2,26 +2,20 @@ use std::net::Ipv4Addr;
|
|||
|
||||
use async_trait::async_trait;
|
||||
use eui48::MacAddress;
|
||||
use google_home::{
|
||||
device,
|
||||
errors::ErrorCode,
|
||||
traits::{self, Scene},
|
||||
types::Type,
|
||||
GoogleHomeDevice,
|
||||
};
|
||||
use google_home::errors::ErrorCode;
|
||||
use google_home::traits::{self, Scene};
|
||||
use google_home::types::Type;
|
||||
use google_home::{device, GoogleHomeDevice};
|
||||
use rumqttc::Publish;
|
||||
use serde::Deserialize;
|
||||
use tracing::{debug, error, trace};
|
||||
|
||||
use crate::{
|
||||
config::{InfoConfig, MqttDeviceConfig},
|
||||
device_manager::{ConfigExternal, DeviceConfig},
|
||||
error::DeviceConfigError,
|
||||
event::OnMqtt,
|
||||
messages::ActivateMessage,
|
||||
};
|
||||
|
||||
use super::Device;
|
||||
use crate::config::{InfoConfig, MqttDeviceConfig};
|
||||
use crate::device_manager::{ConfigExternal, DeviceConfig};
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::OnMqtt;
|
||||
use crate::messages::ActivateMessage;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct WakeOnLANConfig {
|
||||
|
|
|
@ -3,15 +3,13 @@ use rumqttc::Publish;
|
|||
use serde::Deserialize;
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use crate::{
|
||||
config::MqttDeviceConfig,
|
||||
device_manager::{ConfigExternal, DeviceConfig},
|
||||
error::DeviceConfigError,
|
||||
event::{Event, EventChannel, OnMqtt},
|
||||
messages::PowerMessage,
|
||||
};
|
||||
|
||||
use super::{ntfy::Priority, Device, Notification};
|
||||
use super::ntfy::Priority;
|
||||
use super::{Device, Notification};
|
||||
use crate::config::MqttDeviceConfig;
|
||||
use crate::device_manager::{ConfigExternal, DeviceConfig};
|
||||
use crate::error::DeviceConfigError;
|
||||
use crate::event::{Event, EventChannel, OnMqtt};
|
||||
use crate::messages::PowerMessage;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct WasherConfig {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::{error, fmt, result};
|
||||
|
||||
use axum::{http::status::InvalidStatusCode, response::IntoResponse};
|
||||
use axum::http::status::InvalidStatusCode;
|
||||
use axum::response::IntoResponse;
|
||||
use bytes::Bytes;
|
||||
use rumqttc::ClientError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use async_trait::async_trait;
|
||||
use impl_cast::device_trait;
|
||||
use rumqttc::Publish;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use impl_cast::device_trait;
|
||||
|
||||
use crate::devices::Notification;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
25
src/main.rs
25
src/main.rs
|
@ -1,23 +1,22 @@
|
|||
#![feature(async_closure)]
|
||||
use std::process;
|
||||
|
||||
use axum::{
|
||||
extract::FromRef, http::StatusCode, response::IntoResponse, routing::post, Json, Router,
|
||||
};
|
||||
use automation::auth::{OpenIDConfig, User};
|
||||
use automation::config::Config;
|
||||
use automation::device_manager::DeviceManager;
|
||||
use automation::devices::{Ntfy, Presence};
|
||||
use automation::error::ApiError;
|
||||
use automation::mqtt;
|
||||
use axum::extract::FromRef;
|
||||
use axum::http::StatusCode;
|
||||
use axum::response::IntoResponse;
|
||||
use axum::routing::post;
|
||||
use axum::{Json, Router};
|
||||
use dotenvy::dotenv;
|
||||
use google_home::{GoogleHome, Request};
|
||||
use rumqttc::AsyncClient;
|
||||
use tracing::{debug, error, info};
|
||||
|
||||
use automation::{
|
||||
auth::{OpenIDConfig, User},
|
||||
config::Config,
|
||||
device_manager::DeviceManager,
|
||||
devices::{Ntfy, Presence},
|
||||
error::ApiError,
|
||||
mqtt,
|
||||
};
|
||||
use google_home::{GoogleHome, Request};
|
||||
|
||||
#[derive(Clone)]
|
||||
struct AppState {
|
||||
pub openid: OpenIDConfig,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use tracing::{debug, warn};
|
||||
|
||||
use rumqttc::{Event, EventLoop, Incoming};
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use crate::event::{self, EventChannel};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user