Skip to content

Instantly share code, notes, and snippets.

@scottt732
Last active April 2, 2024 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottt732/be976c250e246c8022936106690ebde4 to your computer and use it in GitHub Desktop.
Save scottt732/be976c250e246c8022936106690ebde4 to your computer and use it in GitHub Desktop.
MuteDeck Notifier Traffic Light

(from https://www.reddit.com/r/homeassistant/comments/1bsysto/comment/kxoym1m)

Bill of Materials:

Process:

  • office_notifier.yml (below): Flash something like this to the ESP32.
    • board: esp32dev worked for the M5 Atom Lite but you will need to tweak for other devices.
    • Pick any 3 available GPIO's to control Red/Yellow/Green. 4th pin on traffic light is for GND (I think). Took a little trial & error to get HA & colors mapped
    • I mapped the RGB LED and button on the ESP32 device to a light/button in HA. I've just got some veclro straps holding this to the (I think) Elgato Flex Arm bar that holds my camera. I don't think I'll actually use the button for anything just b/c the setup is a little delicate. Not sure what to use the RGB LED for just yet
  • configuration.yml: I followed this blog post to expose their local API as sensors in Home Assistant
  • traffic_light_automation.yml: This controls the 3 LED's on the traffic light based on the state of MuteDeck:
    • Red: Video is active
    • Yellow: Mic is active
    • Green: On a call
  • Bonus: hallway_light_automation.yml: this turns the Philips Hue lights outside of my office Red when I'm on a Google Meet so my kids don't come barging in during a call :-)
# ESPHome
substitutions:
name: "Office Notifier"
esphome:
name: office-notifier
friendly_name: Office Notifier
esp32:
board: esp32dev
framework:
type: arduino
logger:
api:
encryption:
key: !secret encryption_key
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: !secret wifi_ip
gateway: !secret wifi_gateway
subnet: !secret wifi_subnet
dns1: !secret wifi_dns
captive_portal:
binary_sensor:
- platform: gpio
pin:
number: 39
inverted: true
name: Dismiss
output:
- platform: ledc
id: green
pin: GPIO23
- platform: ledc
id: yellow
pin: GPIO21
- platform: ledc
id: red
pin: GPIO22
light:
- platform: fastled_clockless
chipset: WS2812B
pin: 27
num_leds: 1
rgb_order: GRB
id: status_led
name: RGB
effects:
- random:
name: "Random"
- flicker:
name: "Flicker"
- addressable_rainbow:
name: "Rainbow"
- pulse:
name: "Pulse"
- pulse:
name: "Fast Pulse"
transition_length: 0.5s
update_interval: 0.5s
- pulse:
name: "Slow Pulse"
update_interval: 2s
- platform: monochromatic
output: red
id: red_light
name: Red
- platform: monochromatic
output: yellow
id: yellow_light
name: Yellow
- platform: monochromatic
output: green
id: green_light
name: Green
# ... The rest of your HA configuration.yml
sensor:
- platform: rest
scan_interval: 1
name: macbook_mutedeck
# You'll need a fixed IP/DNS, maybe FW rules for your HA<->MuteDeck comms
resource: http://10.1.0.4:3491/v1/status
json_attributes:
- call
- control
- mute
- record
- share
- status
- video
- platform: template
sensors:
mutedeck_status_call:
value_template: "{{ state_attr('sensor.macbook_mutedeck', 'call') }}"
friendly_name: "MuteDeck Status - Call"
unique_id: mutedeck_status_call
mutedeck_status_control:
value_template: "{{ state_attr('sensor.macbook_mutedeck', 'control') }}"
friendly_name: "MuteDeck Status - Control"
unique_id: mutedeck_status_control
mutedeck_status_mute:
value_template: "{{ state_attr('sensor.macbook_mutedeck', 'mute') }}"
friendly_name: "MuteDeck Status - Mute"
unique_id: mutedeck_status_mute
mutedeck_status_record:
value_template: "{{ state_attr('sensor.macbook_mutedeck', 'record') }}"
friendly_name: "MuteDeck Status - Record"
unique_id: mutedeck_status_record
mutedeck_status_share:
value_template: "{{ state_attr('sensor.macbook_mutedeck', 'share') }}"
friendly_name: "MuteDeck Status - Share"
unique_id: mutedeck_status_share
mutedeck_status_status:
value_template: "{{ state_attr('sensor.macbook_mutedeck', 'status') }}"
friendly_name: "MuteDeck Status - Status"
unique_id: mutedeck_status_status
mutedeck_status_video:
value_template: "{{ state_attr('sensor.macbook_mutedeck', 'video') }}"
friendly_name: "MuteDeck Status - Video"
unique_id: mutedeck_status_video
# ...
alias: MuteDeck Notifier
trigger:
- platform: state
entity_id: sensor.macbook_mutedeck
attribute: call
to: active
action:
- repeat:
while:
- condition: state
entity_id: sensor.macbook_mutedeck
attribute: call
state: active
sequence:
- if:
- condition: state
entity_id: sensor.mutedeck_status_video
state: active
then:
service: light.turn_on
target:
entity_id: light.office_notifier_red
data:
brightness: 255
transition: 0
else:
service: light.turn_off
target:
entity_id: light.office_notifier_red
data:
transition: 0
- if:
- condition: state
entity_id: sensor.mutedeck_status_mute
state: active
then:
service: light.turn_off
target:
entity_id: light.office_notifier_yellow
data:
transition: 0
else:
service: light.turn_on
target:
entity_id: light.office_notifier_yellow
data:
brightness: 255
transition: 0
- if:
- condition: state
entity_id: sensor.mutedeck_status_call
state: active
then:
service: light.turn_on
target:
entity_id: light.office_notifier_green
data:
brightness: 255
transition: 0
else:
service: light.turn_off
target:
entity_id: light.office_notifier_green
data:
transition: 0
- wait_for_trigger:
- platform: state
entity_id:
- sensor.macbook_mutedeck
- service: light.turn_off
target:
entity_id:
- light.office_notifier_red
- light.office_notifier_yellow
- light.office_notifier_green
data:
transition: 0
mode: single
alias: Office Call
description: ""
trigger:
- platform: state
entity_id:
- sensor.mutedeck_status_call
to: active
condition: []
action:
- service: scene.create
metadata: {}
data:
snapshot_entities:
- light.office_call
scene_id: office_call_before
- service: hue.activate_scene
metadata: {}
data:
brightness: 255
transition: 2
target:
entity_id: scene.office_call_red
- wait_for_trigger:
- platform: state
entity_id:
- sensor.mutedeck_status_call
from: active
- service: scene.turn_on
metadata: {}
target:
entity_id: scene.office_call_before
- service: scene.delete
metadata: {}
data: {}
target:
entity_id: scene.office_call_before
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment