I've been meaning to do that using ESPEasy, which is open source firmware that runs on inexpensive ($10) ESP8266 and ESP32 WiFi devices.
https://github.com/letscontrolit/ESPEasy
ESPEasy has sunrise/sunset variables and a text based rule engine that can send http commands. So a single ESPEasy...