Skip to content

Commit

Permalink
feat: custom dimmer interval, extended testing and default config
Browse files Browse the repository at this point in the history
  • Loading branch information
kribor committed Nov 14, 2021
1 parent 0f2947f commit 4324b79
Show file tree
Hide file tree
Showing 8 changed files with 1,330 additions and 116 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ RUN mkdir -p /opt/app
WORKDIR /opt/app

COPY *.json yarn.lock *.yaml /opt/app/
COPY src /opt/app/src

RUN yarn --pure-lockfile

COPY src /opt/app/src

CMD yarn start
19 changes: 19 additions & 0 deletions config-defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timezone: Europe/Stockholm

# Location & max sun angle for artificial light
max_sun_angle: 7 # degrees over the horizon at which time light can be turned off as it's light-enough anyway
latitude: 60.025369
longitude: 17.669363

fake_noon_hour: 11 # Treat as mid-day
hours_of_full_light: 10
minutes_of_sunrise: 120 # interval for dimming between 0 and 100% (both sunrise and sundown)

dimmer_step: 3
dimmer_min: 0 # Start dimming upwards from here. Although 0 is 0
dimmer_max: 100 # Start dimming downwards from here. Although 100 is 100.
dimmer_controller: telldus

telldus:
dimmer_id: 111

5 changes: 2 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Location & max sun angle for artificial light
max_sun_angle: 7 # degrees over the horizon at which time light can be turned off as it's light-enough anyway
latitude: 60.025369
longitude: 17.669363

fake_noon_hour: 11 # Treat as mid-day
hours_of_full_light: 10
minutes_of_sunrise: 120 # interval for dimming between 0 and 100% (both sunrise and sundown)

dimmer_step: 2
dimmer_controller: telldus
dimmer_step: 3
dimmer_max: 50 # Start dimming downwards from here. Although 100 is 100.

timezone: Europe/Stockholm
telldus:
dimmer_id: 9611251
4 changes: 3 additions & 1 deletion src/sunrise-timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export function runScript(fn: (...args: any[]) => any): void {
})()
}

process.env['TZ'] = config.timezone

runScript(async () => {

console.log("Start sunrise timer")
console.log(`Using controller: ${config.dimmer_controller}`)
console.log(`Timezone: ${process.env['TZ']}`)

await run()
await run(config)

})
Loading

0 comments on commit 4324b79

Please sign in to comment.