Skip to content

KTibow/infinity-mirror

Repository files navigation

infinity-mirror

Example code for a smart infinity mirror! Okay, so first of all, here's some credits:

And here's the fourm discussion: https://community.home-assistant.io/t/212410?u=ktibow

Okay, now for some pictures:

Screenshot of full control in HA Picture of screen Picture of infinity mirror

Now let's go to the parts.

  1. (Only tested on) HelTec Wifi Kit 32
  2. Any USB cable
  3. Any breadboard
  4. Any couple male-to-male jumper wires
  5. (Only tested on) LED strip
  6. (Only tested on) Infinity mirror to hack

Okay, let's do this.

Pry apart the infinity mirror

Bottom

  1. First, remove the battery base. Do that by pushing apart the bottom part, and while you do that, pull away the battery holder.
  2. Disconnect all of the wires. Just pull/chop them off.
  3. Push out the stuff. You might need to push on some stuff really hard in order to push out the switch and power plug.
  4. Make the hole between the base and top bigger for the light strip connector.

Note: Don't put the battery base back on, not even later.

Middle

  1. Pry off the coverings. The mirror is made of 3 parts, the middle, and the two covers. Pry off the glue.
  2. Pull off one of the mirrors. Be very gentle, or you'll have a scratched-up mirror like I do.
  3. Detach the provided light strip. Just pull off the adhesive.

Cut and place the light strip

  1. Place the light strip around the mirror.
  2. Find which side is the input and output of the LED strip, and cut off any excess. It's okay to cut off the other connector, too.
  3. Count the number of LEDs in the strip.
  4. Peel off the adhesive backing and place the light strip. Make sure to put the connector through the hole you made earlier.
  5. Route the connector through the light switch hole.

Yahoo! You've done most of the hardware.

Set up the connections

  1. Find your WiFi Kit 32.
  2. Place it in the middle of your breadboard.
  3. If the header's aren't soldered on yet, solder them on now.
  4. Put one wire at pin 5. Put the other two at 5V and GND.
  5. Put the pin 5 wire to the middle, green wire of the connector.
  6. Put the 5V wire to the red wire of the connector, and the GND wire to the white wire of the connector.

Set up Home Assistant

  1. Add the Local IP integration using the GUI.
  2. Add these input_number helpers:
  • input_number.mirror_brightness
    • Name: Mirror Brightness
    • Icon: mdi:mirror
    • Max value: 255
    • Leave everything else
  • input_number.hue
    • Name: Hue
    • Icon: mdi:mirror
    • Max value: 255
    • Leave everything else
  • input_number.saturation
    • Name: Saturation
    • Icon: mdi:mirror
    • Max value: 255
    • Leave everything else
  1. Add these input_select helpers:
  • input_select.mirror_force_weather
    • Name: Mirror force weather

    • Icon: mdi:mirror

    • Options:
      • clear_night
      • cloudy
      • fog
      • lightning
      • storm
      • storm_night
      • mostly_cloudy
      • mostly_cloudy_night
      • heavy_rain
      • rainy
      • snowy
      • mixed_rain
      • sunny
  • Leave everything else
  • input_select.mirror_mode
    • Name: Mirror mode

    • Icon: mdi:mirror

    • Options:
      • Light
      • Clock
      • Weather
      • Force weather
      • Rainbow
      • Random
      • More patterns
  • Leave everything else
  • input_select.mirror_pattern
    • Name: Mirror pattern

    • Icon: mdi:mirror

    • Options:
      • Cyan and Magenta
      • Cyan and Orange
      • Cyan and Green
      • Cyan and Purple
      • Orange and Magenta
      • Orange and Green
      • Orange and Purple
      • Green and Magenta
      • Green and Purple
      • Purple and Magenta
  • Leave everything else
  1. Add these input_text helpers:
  • input_text.mirror_status
    • Name: Mirror status
    • Icon: mdi:mirror
    • Maximum length: 10
    • Leave everything else
  1. Add this stuff to your configuration.yaml (replace weather.kbfi_hourly with your weather sensor):
light:
  - platform: template
    lights:
      infinity_mirror:
        friendly_name: Infinity Mirror
        value_template: '{{is_state(''input_text.mirror_status'', ''on'')}}'
        level_template: '{{((states(''input_number.mirror_brightness'') | int - 10) / 68 * 100) | int}}'
        color_template: '({{(states(''input_number.hue'') | int / 255 * 360) | int}}, {{(states(''input_number.saturation'') | int / 255 * 100) | int}})'
        turn_on:
          service: input_text.set_value
          data:
            entity_id: input_text.mirror_status
            value: 'on'
        turn_off:
          service: input_text.set_value
          data:
            entity_id: input_text.mirror_status
            value: 'off'
        set_level:
          service: input_number.set_value
          data_template:
            entity_id: input_number.mirror_brightness
            value: '{{(brightness | int / 100 * 68 + 10) | int}}'
        set_color:
          - service: input_number.set_value
            data_template:
              value: "{{(h | int / 360 * 255) | int}}"
              entity_id: input_number.hue
          - service: input_number.set_value
            data_template:
              value: "{{(s | int / 100 * 255) | int}}"
              entity_id: input_number.saturation
sensor:
  - platform: template
    sensors:
      mtms:
        value_template: '{{states(''weather.kbfi_hourly'')}}|{{states(''input_text.mirror_status'')}}|{{states(''input_number.mirror_brightness'')}}|{{states(''input_number.hue'')}}|{{states(''input_number.saturation'')}}|{{states(''input_select.mirror_mode'')}}|{{states(''sun.sun'')}}|{{states(''input_select.mirror_pattern'')}}|{{states(''input_select.mirror_force_weather'')}}'
shell_command:
  update_mirror: '/usr/bin/curl -d "info={{states(''sensor.mtms'')}}" "http://192.168.1.97/collect"'
  1. Restart Home Assistant
  2. UI control option #1 (requires slider-entity-row, rgb-light-card):
entities:
  - entity: light.infinity_mirror
    full_row: true
    toggle: true
    type: 'custom:slider-entity-row'
  - colors:
      - hs_color:
          - 315
          - 85
        icon_color: 'hsl(315, 100%, 75%)'
      - hs_color:
          - 0
          - 77
        icon_color: 'hsl(0, 100%, 75%)'
      - hs_color:
          - 40
          - 85
        icon_color: 'hsl(40, 100%, 75%)'
      - hs_color:
          - 99
          - 85
        icon_color: 'hsl(99, 100%, 75%)'
      - hs_color:
          - 140
          - 85
        icon_color: 'hsl(140, 100%, 75%)'
      - hs_color:
          - 180
          - 80
        icon_color: 'hsl(180, 100%, 75%)'
      - hs_color:
          - 215
          - 80
        icon_color: 'hsl(215, 100%, 75%)'
      - hs_color:
          - 270
          - 80
        icon_color: 'hsl(270, 100%, 75%)'
    entity: light.infinity_mirror
    justify: center
    size: 35
    type: 'custom:rgb-light-card'
show_header_toggle: false
type: entities
  1. UI control option #2 with light-entity-card:
entities:
  - entity: light.infinity_mirror
  - brightness: true
    brightness_icon: weather-sunny
    child_card: true
    color_picker: true
    color_temp: true
    color_wheel: true
    consolidate_entities: false
    entity: light.infinity_mirror
    full_width_sliders: false
    hide_header: true
    persist_features: false
    shorten_cards: true
    show_slider_percent: true
    smooth_color_wheel: false
    temperature_icon: thermometer
    type: 'custom:light-entity-card'
    white_icon: file-word-box
    white_value: true
  - entity: input_select.mirror_mode
  - entity: input_select.mirror_pattern
  - entity: input_select.mirror_force_weather
show_header_toggle: false
title: Infinity mirror
type: entities
  1. And add this automation too, so HA can tell the mirror when anything changes:
- id: 'let_mirror_know_when_status_changes'
  alias: Let mirror know when anything changes
  description: ''
  trigger:
  - entity_id: sensor.mtms
    platform: state
  condition: []
  action:
  - data: {}
    service: shell_command.update_mirror

Set up your environment and upload

  1. Make sure the Arduino IDE is installed, and set up for HelTec's board. Here's HelTec's guide.
  2. Download the zip, unzip it, and open mirror.ino in mirror.
  3. Open token.h and change the stuff, and open mirror.ino and change the number of LEDS. You might also need to change your gateway, subnet, and DNS IP addresses in setup.h.
  4. Upload it!

You're done!

Let me know if you have any problems in an issue. BTW: You can upload via a custom OTA web server with these instructions, so you don't have to physically plug it in to your computer as long as it has power.