Skip to content

Custom-Chip "Moon"

Moon_light Moon_dark

Credits

Author: JStaegerino - 2025 Version 1.0.0

Changelog

1.0.0 Initial release

Usage

- type: "custom:button-card"
  template: custom_chip_moon
  entity: sensor.moon_phasee

Requirements

Add the official Moon integration from Home Assistant

Variables

Variable Default Required Notes
entity Your moon phase sensor

Template code

Template Code
custom_chip_moon.yaml
---
custom_chip_moon:
  template: "chips"
  tap_action:
    action: "more-info"
  show_icon: true
  icon: |
    [[[
      var state = entity.state;
      var icon = {
        "new_moon": "mdi:moon-new",
        "waxing_crescent": "mdi:moon-waxing-crescent",
        "first_quarter": "mdi:moon-first-quarter",
        "waxing_gibbous": "mdi:moon-waxing-gibbous",
        "full_moon": "mdi:moon-full",
        "waning_gibbous": "mdi:moon-waning-gibbous",
        "last_quarter": "mdi:moon-last-quarter",
        "waning_crescent": "mdi:moon-waning-crescent"
        }
      return (icon[state] || icon["default"]);
    ]]]
  styles:
    grid:
      - grid-template-areas: "'i'"