Okay I have created this flow which check every x seconds the sunset time.
[{"id":"a7987329d4afde76","type":"tab","label":"Save sunset","disabled":false,"info":"","env":[]},{"id":"2fbb3755fab7965a","type":"inject","z":"a7987329d4afde76","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":150,"y":120,"wires":[["28726be2112e8118"]]},{"id":"11cb8da493787d68","type":"function","z":"a7987329d4afde76","name":"Save sunset","func":"var sunset = new Date(msg.data.attributes.next_setting);\nsunsetDay = sunset.getDate();\nsunsetMonth = sunset.getMonth();\nsunsetFullYear = sunset.getFullYear();\n\nvar today = new Date(Date.now());\ntodayDay = today.getDate();\ntodayMonth = today.getMonth();\ntodayFullYear = today.getFullYear();\n\nif (todayDay != sunsetDay)\n{\n sunset.setDate(todayDay);\n sunset.setMonth(todayMonth);\n sunset.setFullYear(todayFullYear);\n}\n\nglobal.set(\"sunset\", sunset);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":120,"wires":[[]]},{"id":"41e8b3e78091955f","type":"comment","z":"a7987329d4afde76","name":"Save sunset","info":"","x":150,"y":80,"wires":[]},{"id":"28726be2112e8118","type":"api-current-state","z":"a7987329d4afde76","name":"Sun.sun","server":"63f26c18.71f4f4","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":340,"y":120,"wires":[["11cb8da493787d68"]]},{"id":"48962da532cb9558","type":"inject","z":"a7987329d4afde76","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":140,"y":280,"wires":[["aa614b479393ceaa"]]},{"id":"aa614b479393ceaa","type":"function","z":"a7987329d4afde76","name":"Get sunset","func":"var sunset = global.get(\"sunset\");\nmsg.sunset = sunset;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":280,"wires":[["8209f172eaad0efa"]]},{"id":"8209f172eaad0efa","type":"debug","z":"a7987329d4afde76","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":550,"y":280,"wires":[]},{"id":"283a073d3639c302","type":"comment","z":"a7987329d4afde76","name":"Get sunset","info":"","x":130,"y":240,"wires":[]},{"id":"63f26c18.71f4f4","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
Checking it once at midnight is ofcourse better, but what If there is some malfunction about that time then you don’t have correct sunset?