Taking a dumb ir moon IR device and making it actually show moon fazes with m3 hub in home assistant

So I purchased one of these 2 years ago for my son,

its £14.99 in the uk and shows all moon phases based on a single ir press, so 1 press is on full moon, 2 presses waxing, 3 presses cresent ect etc it cycles through each changes to each phaze.

So the task using any IR blaster compatitble with home assistant is to make this device smart, so when a smart button is pushed it cycles to the correct moon phaze that is actual acoording to the moon phaze for were you are.

first add moon under home assistant integrations

So first of is to learn the ir commands, if you have a home assistant compatible blaster that imports custom ir commands straight to ha then thats fine.

If you have the aqara m3 you need to learn the comand through that and then share it via a signal sync over matter.

So create one button press for power (which is power and cycle button of the moon device)

Then create one button for the off switch

Noiw go to helpers and create a toggle called moon_toggle

Then open up your stuidio code server in matter and add this under config/scripts.yaml

moon_phase_full:
  alias: Moon Phase third quater
  sequence:
  - service: remote.send_command
    data:
      num_repeats: 10
      delay_secs: 1
      hold_secs: 0
      device: moon
      command: power
    target:
      entity_id: "your ir blaster or your signal from m3 hub here"
  mode: single
  icon: mdi:moon-last-quarter
moon_phase_waning_gibbous:
  alias: Moon Phase waning gibbous
  sequence:
  - service: remote.send_command
    data:
      num_repeats: 11
      delay_secs: 1
      hold_secs: 0
      device: moon
      command: power
    target:
      entity_id: "your ir blaster or your signal from m3 hub here"
  mode: single
  icon: mdi:moon-waning-gibbous
moon_phase_waning_full:
  alias: Moon Phase full
  sequence:
  - service: remote.send_command
    data:
      num_repeats: 1
      delay_secs: 1
      hold_secs: 0
      device: moon
      command: power
    target:
      entity_id: "your ir blaster or your signal from m3 hub here"
  mode: single
  icon: mdi:moon-full
moon_phase_waxing_gibbous:
  alias: Moon Phase waxing cresent
  sequence:
  - service: remote.send_command
    data:
      num_repeats: 5
      delay_secs: 1
      hold_secs: 0
      device: moon
      command: power
    target:
      entity_id: "your ir blaster or your signal from m3 hub here"
  mode: single
  icon: mdi:moon-waxing-crescent
moon_phase_waxing_cresent:
  alias: Moon Phase new moon
  sequence:
  - service: remote.send_command
    data:
      num_repeats: 7
      delay_secs: 1
      hold_secs: 0
      device: moon
      command: power
    target:
      entity_id: "your ir blaster or your signal from m3 hub here"
  mode: single
  icon: mdi:moon-new
moon_phase_first_qauter:
  alias: Moon Phase first qauter
  sequence:
  - service: remote.send_command
    data:
      num_repeats: 4
      delay_secs: 1
      hold_secs: 0
      device: moon
      command: power
    target:
      entity_id: "your ir blaster or your signal from m3 hub here"
  mode: single
  icon: mdi:moon-first-quarter
moon_phase_waning_cresent:
  alias: Moon Phase waning cresent
  sequence:
  - service: remote.send_command
    data:
      num_repeats: 9
      delay_secs: 1
      hold_secs: 0
      device: moon
      command: power
    target:
      entity_id: "your ir blaster or your signal from m3 hub here"
  mode: single
  icon: mdi:moon-waning-crescent
moon_phase_waxing_gibous:
  alias: Moon Phase waxing gibous
  sequence:
  - service: remote.send_command
    data:
      num_repeats: 3
      delay_secs: 1
      hold_secs: 0
      device: moon
      command: power
    target:
      entity_id: "your ir blaster or your signal from m3 hub here"
  mode: single
  icon: mdi:moon-waxing-gibbous
moon_phase_off:
  alias: Moon Phase off
  sequence:
  - service: remote.send_command
    data:
      num_repeats: 1
      delay_secs: 1
      hold_secs: 0
      device: moon
      command: 'off'
    target:
      entity_id: "your ir blaster or your signal from m3 hub here"

now you have added this reboot home assistant then create this automation

alias: 8.moon IR on
description: ""
triggers:
  - entity_id:
      - input_boolean.moon_toggle
    to: "on"
    from: "off"
    trigger: state
conditions: []
actions:
  - if:
      - condition: state
        entity_id: sensor.moon_phase
        state: full_moon
    then:
      - data: {}
        action: script.moon_phase_waning_full
    else:
      - if:
          - condition: state
            entity_id: sensor.moon_phase
            state: waxing_gibbous
        then:
          - data: {}
            action: script.moon_phase_waxing_gibous
        else:
          - if:
              - condition: state
                entity_id: sensor.moon_phase
                state: first_quarter
            then:
              - data: {}
                action: script.moon_phase_first_qauter
            else:
              - if:
                  - condition: state
                    entity_id: sensor.moon_phase
                    state: waning_crescent
                then:
                  - data: {}
                    action: script.moon_phase_waxing_gibbous
                else:
                  - if:
                      - condition: state
                        entity_id: sensor.moon_phase
                        state: waning_crescent
                    then:
                      - data: {}
                        action: script.moon_phase_waning_cresent
                    else:
                      - if:
                          - condition: state
                            entity_id: sensor.moon_phase
                            state: last_quarter
                        then:
                          - data: {}
                            action: script.moon_phase_full
                        else:
                          - if:
                              - condition: state
                                entity_id: sensor.moon_phase
                                state: waning_gibbous
                            then:
                              - data: {}
                                action: script.moon_phase_waning_gibbous
mode: single

then create one for the off button

alias: 8.moon off
description: ""
triggers:
  - entity_id:
      - input_boolean.moon_toggle
    from: "on"
    to: "off"
    trigger: state
conditions: []
actions:
  - data: {}
    action: script.moon_phase_off
mode: single

Once this is done assing the input_bootlean.moon_toggle to a button, then when pressed the automation and script combined will check the current moon phaze and make the appropriate number of presses to set the mood light to match that nights moon phaze.

so for a cheap price you have a working moon phaze light for your kids.

example of how it lights up

Now if only aqara app team will allow moon fazes to be added:)

1 Like

Very cool idea! Love how you turned the moon lamp smart and synced it with real moon phases.

3 Likes

Give you a big thumbs-up for your practical skills!

1 Like

its all in the automation, would be able to do in just aqara app if they add moon phases (which they should due to going out to create a simple home automation platform as most people have young kids at one stage that nice automations can be based off moon phase)

also would like the new automations to impliment the if-then-else as the else at the end should allow you to add another if-then-else over and over.