This library adds blocks to determine whether a given phase in today’s astro events have already passed, and retrieve time intervals between the current time and the time of the event. You need the Astro binding installed, and a Sun thing configured.
Blocks
This block will return whether or not the specified phase (start or end), like sunrise or sunset, is still to come or has already passed. Don’t forget to pick the Sun thing from the Astro binding!
This block will return the number of seconds, minutes or hours (rounded) until the specified phase (start or end), like sunrise or sunset. If it has already passed, the result will be negative. Don’t forget to pick the Sun thing from the Astro binding!
Changelog
Version 0.1
- initial release
Resources
uid: astro
tags: []
props:
parameters: []
parameterGroups: []
component: BlockLibrary
config:
name: Astro
slots:
blocks:
- component: BlockType
config:
type: compare_event_time
message0: the %1 of today's %2 according to %3 %4
args0:
- type: field_dropdown
name: MOMENT
options:
- - start
- START
- - end
- END
- type: field_dropdown
name: PHASE
options:
- - sunrise
- SUN_RISE
- - sunset
- SUN_SET
- - astro dawn
- ASTRO_DAWN
- - nautic dawn
- NAUTIC_DAWN
- - civil dawn
- CIVIL_DAWN
- - astro dusk
- ASTRO_DUSK
- - nautic dusk
- NAUTIC_DUSK
- - civil dusk
- CIVIL_DUSK
- - daylight
- DAYLIGHT
- - noon
- NOON
- - night
- NIGHT
- - morning night
- MORNING_NIGHT
- - evening night
- EVENING_NIGHT
- type: input_value
name: THING
- type: field_dropdown
name: DIRECTION
options:
- - is still to come
- After
- - has already passed
- Before
output: Boolean
colour: 0
tooltip: ""
helpUrl: ""
slots:
code:
- component: BlockCodeTemplate
config:
template: "{{utility:things}}.getActions('astro', {{input:THING}}).getEventTime('{{field:PHASE}}', null, '{{field:MOMENT}}').is{{field:DIRECTION}}({{utility:zdt}}.now())"
toolbox:
- component: PresetInput
config:
name: THING
type: oh_thing
shadow: true
- component: BlockType
config:
type: time_until_event
message0: number of %1 until the %2 of today's %3 according to %4
args0:
- type: field_dropdown
name: UNIT
options:
- - seconds
- SECONDS
- - minutes
- MINUTES
- - hours
- HOURS
- type: field_dropdown
name: MOMENT
options:
- - start
- START
- - end
- END
- type: field_dropdown
name: PHASE
options:
- - sunrise
- SUN_RISE
- - sunset
- SUN_SET
- - astro dawn
- ASTRO_DAWN
- - nautic dawn
- NAUTIC_DAWN
- - civil dawn
- CIVIL_DAWN
- - astro dusk
- ASTRO_DUSK
- - nautic dusk
- NAUTIC_DUSK
- - civil dusk
- CIVIL_DUSK
- - daylight
- DAYLIGHT
- - noon
- NOON
- - night
- NIGHT
- - morning night
- MORNING_NIGHT
- - evening night
- EVENING_NIGHT
- type: input_value
name: THING
output: Boolean
colour: 0
tooltip: Determines the amount of time until the specified event. If it has already passed, the result will be negative.
helpUrl: ""
slots:
code:
- component: BlockCodeTemplate
config:
template: "{{utility:zdt}}.now().until({{utility:things}}.getActions('astro', {{input:THING}}).getEventTime('{{field:PHASE}}', null, '{{field:MOMENT}}'), {{utility:ChronoUnit}}.{{field:UNIT}})"
toolbox:
- component: PresetInput
config:
name: THING
type: oh_thing
shadow: true
utilities:
- component: UtilityJavaType
config:
name: things
javaClass: org.openhab.core.model.script.actions.Things
- component: UtilityJavaType
config:
name: zdt
javaClass: java.time.ZonedDateTime
- component: UtilityJavaType
config:
name: ChronoUnit
javaClass: java.time.temporal.ChronoUnit