Multipurpose RGB sensor (ESPHome)

Last Updated or created 2024-04-01

A few years ago, I made a little light metering sensor using a light resistor and a NodeMCU (using analog read).
This would measure if a Led was turned on from my Alarm system. (I had no other way to read this state.
(I also had it connected to our washing machine for a while, to read the state.)

Now I wanted to read the state of the TV set-top box.
This Arcadyan hmb2260 has a green/led state LED, so measuring light is not enough.
(I can only toggle the device from Home Assistant, so there is no way to know the current state!)
Toggling on/off and portscanning the device gave me not another way to get the state (no extra open ports/web state pages) than using an RGB Sensor.

Flashing this with ESP Home and integrating it in HA was a breeze.

I wanted to turn the Illuminance LED also off, because the Set-top box already emits light.

Now I’m going to 3D print a holder which can be used to press the button manually when needed.

The yellow part needs to be 3D printed.
Output of the sensor

ESPHome Code

esphome:
  name: rgbsensor
  friendly_name: RgbSensor

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx="

ota:
  password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Rgbsensor Fallback Hotspot"
    password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

captive_portal:

i2c:
  sda: 4
  scl: 5

sensor:
  - platform: tcs34725
    red_channel:
      name: "TCS34725 Red Channel"
    green_channel:
      name: "TCS34725 Green Channel"
    blue_channel:
      name: "TCS34725 Blue Channel"
    clear_channel:
      name: "TCS34725 Clear Channel"
    illuminance:
      name: "TCS34725 Illuminance"
    color_temperature:
      name: "TCS34725 Color Temperature"
    glass_attenuation_factor: 1.0
    address: 0x29
    update_interval: 5s

light:
  - platform: binary
    name: "RgbSensorVerlichting"
    output: light_output

output:
  - id: light_output
    platform: gpio
    pin: 2

Automation in HA:

If Red Channel > 60% then device is OFF.

Other ideas:

Measure the dishwasher machine LED.

Using color cards to (program) the wleds I’m using.


Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *