Skip to content

Sun card: moon-phase view after sunset — v0.17.0 - #34

Merged
ryanbuiltthat merged 1 commit into
mainfrom
claude/prism-smart-dashboard-card-rjlks3
Jul 28, 2026
Merged

Sun card: moon-phase view after sunset — v0.17.0#34
ryanbuiltthat merged 1 commit into
mainfrom
claude/prism-smart-dashboard-card-rjlks3

Conversation

@ryanbuiltthat

Copy link
Copy Markdown
Owner

What

The sun card keeps its daytime sun-path arc, and now after sunset it flips to a moon view:

  • A moon-phase glyph drawn to the current illuminated fraction (all 8 phases).
  • The phase name + illumination % (from an optional sensor, or computed from the phase).
  • The next sunrise.
  • Moonrise / moonset on a second row when those sensors are configured.

Behaviour

  • Daytime → the existing sun-path arc, countdown, sunrise/sunset (extracted verbatim into _sunView, unchanged).
  • After sunset (below_horizon / elevation ≤ 0) → the moon view, when show_moon is on (default) and a moon-phase sensor is available. Otherwise the arc rests with a moon on the horizon as before.

Config (new)

Key Default Notes
show_moon true Show the moon view after sunset.
moon_entity sensor.moon Moon-phase sensor (the Moon integration). Phase name or numeric.
moonrise_entity Optional moonrise timestamp sensor.
moonset_entity Optional moonset timestamp sensor.
moon_illumination_entity Optional illumination-% sensor; else computed from the phase.

The editor gains a Moon section (switch + four pickers). Moon colours are theme-safe (silver lit path + secondary-text outline), and moon icons use the secondary text colour rather than the accent so the moon reads distinctly from the sun.

Implementation note

moonLitPath(cx, cy, r, k) renders the lit region as an outer semicircle on the lit side plus a terminator half-ellipse of x-radius |cos(2πk)|·r (waxing lights the right; new moon = nothing lit, full = full circle). moonInfo() maps the 8 HA phase names (or a numeric phase) to {label, k}.

Testing

  • Verified in Chromium across all 8 phases: moon view active at night, correct lit geometry (first/last quarter = half-width, gibbous > half, full = complete circle, crescents thin), illumination 0→100%, correct phase labels, moonrise/moonset subrow, zero console errors.
  • bash build.sh + node test/smoke.js green (added a night + moon fixture and 2 cases). Preview gains a "Sun & Moon" demo, so the showcase picks it up.

VERSION 0.16.5 → 0.17.0.

🤖 Generated with Claude Code


Generated by Claude Code

Refactor prism-sun-card to keep the daytime sun-path arc unchanged (extracted
into _sunView) and add a night moon view (_moonView), shown after sunset when
the new `show_moon` option is on and a moon-phase sensor is available.

The moon view draws a moon-phase glyph to the current illuminated fraction
(moonLitPath: outer semicircle on the lit side + a terminator half-ellipse;
waxing lights the right, new = unlit, full = full circle), plus illumination %
(from an optional sensor, else computed from the phase), the phase name, the
next sunrise, and a moonrise/moonset row when those sensors are configured.

New config: show_moon (default true), moon_entity (default sensor.moon),
moonrise_entity, moonset_entity, moon_illumination_entity. Editor gains a Moon
section. Colours are theme-safe and moon elements use the secondary text colour
rather than the accent.

Wired smoke (night + moon fixtures, 2 cases) and preview (Sun & Moon demo);
updated README + docs/cards.md. Verified in Chromium across all 8 phases.
VERSION 0.16.5 -> 0.17.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014cpNPVU8j1iiU9CnXgr5JY
@ryanbuiltthat
ryanbuiltthat merged commit aba88a7 into main Jul 28, 2026
1 check failed
@ryanbuiltthat
ryanbuiltthat deleted the claude/prism-smart-dashboard-card-rjlks3 branch July 28, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants