Skip to content

Instantly share code, notes, and snippets.

@navhaxs
Created November 11, 2025 08:54
Show Gist options
  • Select an option

  • Save navhaxs/2640d13a74ed09d335879b79e80f77e3 to your computer and use it in GitHub Desktop.

Select an option

Save navhaxs/2640d13a74ed09d335879b79e80f77e3 to your computer and use it in GitHub Desktop.
substitutions:
name: "hdmi-control-palakis"
friendly_name: "HDMI Control - palakis"
project_name: "SMLIGHT.SLWF-08-HDMI"
project_version: "1.0-Palakis"
target: <PUT_YOUR_IP_ADDRESS_HERE>
esphome:
name: esphome-web
friendly_name: hdmi-cec-control
min_version: 2025.9.0
name_add_mac_suffix: false
project:
name: "${project_name}"
version: "${project_version}"
esp8266:
board: esp12e
# Enable logging
logger:
external_components:
- source: github://Palakis/esphome-hdmi-cec
web_server:
port: 80
# Enable Home Assistant API
api:
encryption:
key: <PUT_ENCRYPTION_KEY_HERE>
services:
- service: hdmi_cec_send
variables:
cec_destination: int
cec_data: int[]
then:
- hdmi_cec.send:
destination: !lambda "return static_cast<unsigned char>(cec_destination);"
data: !lambda |-
std::vector<unsigned char> vec;
for (int i : cec_data) vec.push_back(static_cast<unsigned char>(i));
return vec;
# Allow Over-The-Air updates
ota:
- platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
use_address: ${target}
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "HDMI-AP"
password: "slwf0800"
dashboard_import:
package_import_url: github://smlight-tech/slwf-08/esphome-configs/slwf-08-Palakis.yaml
hdmi_cec:
pin: GPIO14
address: 0xE
physical_address: 0x1000
osd_name: "SLWF-08-HDMI" # Optional. Defaults to "esphome"
promiscuous_mode: true # Optional. Defaults to false
monitor_mode: false # Optional. Defaults to false
on_message:
# Trigger when a "Report Power Status: On" (opcode 0x90, data 0x00) message is received from any source
- opcode: 0x90 # Report Power Status
data: [0x90, 0x0] # On
then:
- logger.log: "CEC: TV reported power status: ON"
- binary_sensor.template.publish:
id: tv_power_status
state: ON
# Trigger when a "Report Power Status: Standby" (opcode 0x90, data 0x01) message is received from any source
- opcode: 0x90 # Report Power Status
data: [0x90, 0x1] # Standby
then:
- logger.log: "CEC: TV reported power status: STANDBY"
- binary_sensor.template.publish:
id: tv_power_status
state: OFF
button:
- platform: restart
name: "Restart ESP device"
# - platform: template
# name: "Turn TV on 0x04"
# on_press:
# hdmi_cec.send:
# destination: 0x0
# data: [0x04] # Works with Samsung TVs. For LG, try [0x0D]; for Sony, [0x44, 0x6D].
- platform: template
name: "Turn TV on 0x0D"
on_press:
hdmi_cec.send:
destination: 0x0
data: [0x0D]
- platform: template
name: "Give Device Power Status"
on_press:
hdmi_cec.send:
destination: 0x0
data: [0x8F]
- platform: template
name: "Turn TV off 36"
id: turn_on_tv
on_press:
hdmi_cec.send:
destination: 0x0
data: [0x36]
- platform: template
name: "Volume up"
on_press:
hdmi_cec.send:
destination: 0x0
data: [0x44, 0x41]
- platform: template
name: "Volume down"
on_press:
hdmi_cec.send:
destination: 0x0
data: [0x44, 0x42]
- platform: template
name: "Mute"
on_press:
hdmi_cec.send:
destination: 0x0
data: [0x44, 0x43]
binary_sensor:
- platform: template
name: "TV Power Status"
id: tv_power_status
device_class: power
interval:
- interval: 10s
then:
- hdmi_cec.send:
destination: 0x0
data: [0x8F] # "Give Device Power Status"
switch:
- platform: template
name: "Toggle TV Power"
id: toggle_tv_power
lambda: |-
return id(tv_power_status).state;
turn_on_action:
- if:
condition:
binary_sensor.is_off: tv_power_status
then:
- logger.log: "TV is OFF, sending power ON command"
- hdmi_cec.send:
destination: 0x0
data: [0x0D] # Power ON
else:
- logger.log: "TV is ON, sending power OFF command"
- hdmi_cec.send:
destination: 0x0
data: [0x36] # Standby
turn_off_action:
- if:
condition:
binary_sensor.is_on: tv_power_status
then:
- logger.log: "TV is ON, sending power OFF command"
- hdmi_cec.send:
destination: 0x0
data: [0x36] # Standby
else:
- logger.log: "TV is already OFF, no action taken"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment