2024-09-15 09:01:13 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-09-15 10:46:07 +02:00
|
|
|
"context"
|
2024-10-21 23:14:55 +02:00
|
|
|
"fmt"
|
2024-09-18 02:09:25 +02:00
|
|
|
"github.com/Crocmagnon/display-epaper/home_assistant"
|
2024-09-15 23:25:17 +02:00
|
|
|
"github.com/Crocmagnon/display-epaper/weather"
|
2024-09-15 09:01:13 +02:00
|
|
|
"github.com/llgcode/draw2d/draw2dimg"
|
2024-09-15 12:00:36 +02:00
|
|
|
"time"
|
2024-09-15 09:01:13 +02:00
|
|
|
)
|
|
|
|
|
2024-09-15 23:25:17 +02:00
|
|
|
func run(
|
|
|
|
ctx context.Context,
|
2024-09-16 14:12:51 +02:00
|
|
|
_ time.Duration,
|
2024-09-16 18:15:42 +02:00
|
|
|
_ time.Duration,
|
2024-09-15 23:25:17 +02:00
|
|
|
weatherClient *weather.Client,
|
2024-09-18 22:26:40 +02:00
|
|
|
hassClient *home_assistant.Client,
|
2024-09-15 23:25:17 +02:00
|
|
|
) error {
|
2024-12-16 19:40:10 +01:00
|
|
|
img, err := getImg(ctx, func() time.Time {
|
|
|
|
t, err := time.Parse(time.DateOnly, "2024-08-01zzz")
|
|
|
|
if err != nil {
|
|
|
|
return time.Now()
|
|
|
|
}
|
|
|
|
return t
|
|
|
|
}, weatherClient, hassClient)
|
2024-09-15 09:01:13 +02:00
|
|
|
if err != nil {
|
2024-10-21 23:14:55 +02:00
|
|
|
return err
|
2024-09-15 09:01:13 +02:00
|
|
|
}
|
2024-10-21 23:14:55 +02:00
|
|
|
|
2024-09-15 21:18:06 +02:00
|
|
|
if err := draw2dimg.SaveToPngFile("out/black.png", img); err != nil {
|
2024-10-21 23:14:55 +02:00
|
|
|
return fmt.Errorf("saving img: %w", err)
|
2024-09-15 21:18:06 +02:00
|
|
|
}
|
2024-09-15 09:01:13 +02:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|