This commit is contained in:
2025-05-19 20:25:53 +02:00
parent 234323c766
commit 0a76c5feca
4 changed files with 99 additions and 59 deletions

View File

@@ -27,7 +27,8 @@ import (
var (
port string
scheduler gocron.Scheduler
ticktick *ticktickutil.TicktickUtilImpl
ticktick ticktickutil.TicktickUtil
ha *homeassistant.HomeAssistant
)
// serveCmd represents the serve command
@@ -55,7 +56,7 @@ func initComponent() {
// init location recorder
locationRecorder.Init()
// init homeassistant
homeassistant.Init(ticktick)
ha = homeassistant.NewHomeAssistant(ticktick)
}
func serve(cmd *cobra.Command, args []string) {
@@ -108,7 +109,7 @@ func serve(cmd *cobra.Command, args []string) {
router.HandleFunc("/poo/latest", pooRecorder.HandleNotifyLatestPoo).Methods("GET")
router.HandleFunc("/poo/record", pooRecorder.HandleRecordPoo).Methods("POST")
router.HandleFunc("/homeassistant/publish", homeassistant.HandleHaMessage).Methods("POST")
router.HandleFunc("/homeassistant/publish", ha.HandleHaMessage).Methods("POST")
router.HandleFunc("/location/record", locationRecorder.HandleRecordLocation).Methods("POST")