esphome: name: ugreen-hdmi-switcher friendly_name: "Ugreen HDMI Switcher" esp8266: board: d1_mini # Enable logging logger: level: INFO # Enable Home Assistant API api: encryption: key: "QWthU1d2dUFlTSRhTlA5bW9yR1JrdUhCajlRI3Y5eUA=" # Change this ota: password: "changethis" # Change this wifi: ssid: !secret wifi_ssid password: !secret wifi_password # Enable fallback hotspot (captive portal) in case wifi connection fails # ap: # ssid: "Test Fallback Hotspot" # password: "changethis" output: - platform: gpio pin: number: 2 inverted: true id: 'output_toggle' button: - platform: output name: "Toggle HDMI Port" output: 'output_toggle' duration: 500ms binary_sensor: - platform: gpio name: "HDMI Port Status" id: hdmi_pin internal: true pin: 4 publish_initial_state: true on_state: then: - lambda: !lambda |- if (id(hdmi_pin).state) { id(hdmi_port).publish_state("hdmi2"); } else { id(hdmi_port).publish_state("hdmi1"); } text_sensor: - platform: template id: hdmi_port name: "HDMI Port" # captive_portal: