M5NanoH2 as an IR proxy

I purchased an M5Stack NanoH2 for $7 to experiment with, and was able to have it communicate with Home Assistant using my Apple TV as a thread border router. Home Assistant is now able to control both my Daikin and Mitsubishi ACs thanks to this tiny widget. The only tricky part was getting both the IR transmitter and the RGB LED working at the same time. I couldn't quite figure out how to make them use different RMT channels, but setting the rmt_symbols to 48 for both seems to work. I don't know if setting rmt_symbols to 48 for the IR transmitter affects the length of the IR codes it can transmit, but so far all the codes seem to be transmitting correctly to my ACs.
The device seems to use around 18mA on average. In the future I plan to experiment with making this a battery powered sleepy end device. I also want to report double clicks and long presses on the built-in button to HA, but for now it only reports reports presses and releases.

Here's the config in case it's useful to someone else:

substitutions:
  devicename: bedroom-nanoh2
  upper_devicename: Bedroom Nano-H2

esphome:
  name: ${devicename}
  name_add_mac_suffix: False
  project:
    name: m5stack.nano-h2
    version: "1.0"

esp32:
  board: esp32-h2-devkitm-1
  variant: ESP32H2
  framework:
    type: esp-idf

api:
  encryption:
    key: !secret api_encryption_key

network:
 enable_ipv6: true

openthread:
 tlv: !secret openthread_tlv

ota:
  - platform: esphome
    password: !secret ota_password

remote_transmitter:
  id: ir_tx
  pin: GPIO3
  rmt_symbols: 48
  non_blocking: True
  carrier_duty_percent: 50%

climate:
  - platform: mitsubishi
    name: "Mitsubishi AC"
    supports_heat: False
    set_fan_mode: quiet_4levels
    supports_dry: True
    horizontal_default: middle
    vertical_default: down

infrared:
  - platform: ir_rf_proxy
    name: IR Proxy Transmitter
    id: ir_proxy_tx
    remote_transmitter_id: ir_tx

power_supply:
  - id: rgb_pwr
    pin: GPIO10

light:
  - platform: status_led
    name: "Status"
    pin: GPIO04
  - platform: esp32_rmt_led_strip
    name: "RGB LED"
    id: nanoh2_rgb
    rgb_order: GRB
    pin: GPIO11
    power_supply: rgb_pwr
    num_leds: 1
    chipset: WS2812
    is_rgbw: true
    rmt_symbols: 48
    effects:
      - random:
      - flicker:
      - addressable_rainbow:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO9
      inverted: true
      mode: INPUT_PULLUP
    name: "Button"

button:
  - platform: factory_reset
    id: factory_reset_button
    name: "Factory Reset"
    entity_category: diagnostic
    internal: true
  - platform: restart
    id: restart_button
    name: "Restart"
    entity_category: config
    disabled_by_default: true
    icon: "mdi:restart"

1 Like

Thanks, this was actually very timely :slight_smile: I'm new and hadn't realized ESPHome would even work over Thread on a NanoH2.

What are you thinking of doing for the battery power? A USB-C power pack seems like such overkill for such a low-power device but every other option seems to require a soldering iron (maybe I'll get to that point but not quite yet)

It does work really well with thread. It even hops off an IKEA matter over thread air quality sensor to reach the Apple TV border router.
The M5Stack NanoH2 has the grove pins to supply power, so I don't think I'll have to do any soldering for powering it with a battery. I've yet to experiment with the sleep modes, but since I need the device/api to be responsive to requests for IR transmission, I think I'll be limited to the light sleep mode and can't use the deep sleep mode. I will post back when I get around to experimenting with the sleep modes.

Yeah, I'm just nervous about wiring something that's not exactly 5V to the Grove port, but maybe I'm just squeamish (as if I need to worry that much about a $7 part lol). Also I can't find any battery holders with Grove connectors? In any event is it reasonable to just use 3 AA batteries and call it good (i.e., is 4.5V close enough)?