Add homeassistant to ticktick

This commit is contained in:
2024-09-19 15:10:33 +02:00
parent 271368bf52
commit 9c414d28ad
3 changed files with 333 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ import (
"github.com/t-liu93/home-automation-backend/components/locationRecorder"
"github.com/t-liu93/home-automation-backend/components/pooRecorder"
"github.com/t-liu93/home-automation-backend/util/notion"
"github.com/t-liu93/home-automation-backend/util/ticktick"
)
var port string
@@ -41,6 +42,8 @@ func initUtil() {
slog.Error("Notion token not found in config file, exiting..")
os.Exit(1)
}
// init ticktick
ticktick.Init()
}
func initComponent() {
@@ -55,8 +58,8 @@ func serve(cmd *cobra.Command, args []string) {
viper.SetConfigName("config") // name of config file (without extension)
viper.SetConfigType("yaml")
viper.AddConfigPath(".") // . is used for dev
viper.AddConfigPath("$HOME/.config/home-automation")
viper.AddConfigPath(".") // optionally look for config in the working directory
err := viper.ReadInConfig()
if err != nil {
slog.Error(fmt.Sprintf("Cannot read config file, %s, exiting..", err))
@@ -105,6 +108,8 @@ func serve(cmd *cobra.Command, args []string) {
router.HandleFunc("/location/record", locationRecorder.HandleRecordLocation).Methods("POST")
router.HandleFunc("/ticktick/auth/code", ticktick.HandleAuthCode).Methods("GET")
srv := &http.Server{
Addr: ":" + port,
Handler: router,