# Sunset and sunrise times to Homey Script

**URL:** <https://community.homey.app/t/sunset-and-sunrise-times-to-homey-script/80456>\
**Category:** Questions & Help\
**Tags:** homey-pro\
**Created:** [May 13, 2023, 11:17am UTC](https://community.homey.app/t/sunset-and-sunrise-times-to-homey-script/80456 "2023-05-13T11:17:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![peltsi51](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peltsi51/32/12564_2.png) [@peltsi51](https://community.homey.app/u/peltsi51)\
**Post date:** [May 13, 2023, 11:17am UTC](https://community.homey.app/t/sunset-and-sunrise-times-to-homey-script/80456/1 "2023-05-13T11:17:47Z")

</div>

I’m new to Homey Script so bear with me 😉

I like to get hour of the sunrise and sunset to Homey Script. I have the Sun Events app in which there are tags available for sunset and sunrise, but I have only found the way to get the capability values from other devices to Homey Script but the Sun Events app doesn’t have devices at all. What to do?

Also other ways of getting the sunrise and sunset hours to Homey Script would be appreciated.

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [May 13, 2023, 11:22am UTC](https://community.homey.app/t/sunset-and-sunrise-times-to-homey-script/80456/2 "2023-05-13T11:22:31Z")

</div>

This should get you started:

```auto
await Homey.apps.getAppSettings({id: 'com.cyclone-software.sunevents'})
  .then(result => {
    log('sunrise:', result.myEventsTimes.sunrise.date);
    log('sunset:', result.myEventsTimes.sunset.date);
  })
  .catch(err => log(err));

```

---

<div class="post-metadata">

**Author:** ![peltsi51](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peltsi51/32/12564_2.png) [@peltsi51](https://community.homey.app/u/peltsi51)\
**Post date:** [May 13, 2023, 11:48am UTC](https://community.homey.app/t/sunset-and-sunrise-times-to-homey-script/80456/3 "2023-05-13T11:48:29Z")

</div>

Thanks a lot! That will do it.

---

<div class="post-metadata">

**Author:** ![OlaSt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/olast/32/17168_2.png) [@OlaSt](https://community.homey.app/u/OlaSt)\
**Post date:** [February 13, 2026, 11:56am UTC](https://community.homey.app/t/sunset-and-sunrise-times-to-homey-script/80456/4 "2026-02-13T11:56:32Z")

</div>

Do this still work? Seems like there has been some changes…?

---

<div class="post-metadata">

**Author:** ![OlaSt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/olast/32/17168_2.png) [@OlaSt](https://community.homey.app/u/OlaSt)\
**Post date:** [February 13, 2026, 1:15pm UTC](https://community.homey.app/t/sunset-and-sunrise-times-to-homey-script/80456/5 "2026-02-13T13:15:12Z")

</div>

I have an almost complete solution, but I do want this as a date object. And that is not easy, unless I split and build text into a parseable string. Anyone got a solution?

```auto
let sun=await Homey.apps.getAppSettings({id: 'com.cyclone-software.sunevents'})
// returns format 13.2.2026, 08:01
let sunrise=(JSON.parse(sun.myEventsTimes)).find(({ name }) => name === "Sunrise").date
let sunset=(JSON.parse(sun.myEventsTimes)).find(({ name }) => name === "Sunset").date

```
