Add solar usage reporting

This commit is contained in:
2025-04-12 16:57:19 +05:30
parent 3cd448d9ee
commit 9ed6c8cd99
7 changed files with 193 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ import (
"os/signal"
"syscall"
"github.com/robfig/cron"
"go.mau.fi/whatsmeow"
"go.mau.fi/whatsmeow/store/sqlstore"
"go.mau.fi/whatsmeow/types"
@@ -41,10 +42,24 @@ func main() {
client.Register()
client.Connect()
deyeUser := os.Getenv("DEYE_USER")
deyePassword := os.Getenv("DEYE_PASSWORD")
if deyeUser == "" || deyePassword == "" {
panic("Deye user/password must be provided")
}
solar := internal.NewSolar(client, deyeUser, deyePassword)
myCron := cron.New()
myCron.AddFunc("0 0 19 * * *", solar.SendDailyReport)
myCron.Start()
// Listen to Ctrl+C (you can also do something else that prevents the program from exiting)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c
myCron.Stop()
client.Disconnect()
}