redphx / esphome-ugreen-hdmi-switcher

Control UGREEN HDMI Switcher/Splitter over WiFi using ESPHome
67 stars 6 forks source link

Double press? #1

Open nwithan8 opened 1 year ago

nwithan8 commented 1 year ago

Everytime I hit the "Toggle" button, it switches between the two ports in rapid succession, rather than staying on the next port.

image

Logs via ESPHome:

[D][button:010]: 'Toggle HDMI Port' Pressed.
[D][button:010]: 'Toggle HDMI Port' Pressed.
[D][binary_sensor:036]: 'HDMI Port Status': Sending state OFF
[D][text_sensor:064]: 'HDMI Port': Sending state 'hdmi1'
[D][binary_sensor:036]: 'HDMI Port Status': Sending state ON
[D][text_sensor:064]: 'HDMI Port': Sending state 'hdmi2'
[D][button:010]: 'Toggle HDMI Port' Pressed.
[D][binary_sensor:036]: 'HDMI Port Status': Sending state OFF
[D][text_sensor:064]: 'HDMI Port': Sending state 'hdmi1'
[D][binary_sensor:036]: 'HDMI Port Status': Sending state ON
[D][text_sensor:064]: 'HDMI Port': Sending state 'hdmi2'
ildar7070 commented 1 year ago

I have the same problem. Also it shows always the status 'hdmi2'. Even if I press the button manually on the device to switch the inputs.

KR4DIO commented 12 months ago

@nwithan8 and @ildar7070 -- Connect a wire from the ground pin on your ESP board to ground on the HDMI switch. I used one of the HDMI port lugs. Note that I also switched the "DAT" connection from D4 to D1, as my ESP board didn't seem like having that pin pulled low during boot.

See attached image: PXL_20231114_023056934

I changed the board type and pin numbers to match my particular board/connections:

esphome:
  name: esphome-web-d739ff
  friendly_name: hdmi-switch

esp8266:
  board: d1_mini_lite

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxx"

ota:

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-xxxxxx"
    password: "xxxxxxxxxxxx"

captive_portal:

output:
  - platform: gpio
    pin:
      number: D2
      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: D1
    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"   
ildar7070 commented 12 months ago

This did the trick for me. Thank you for providing help on this. I think we can close this issue

djjoereece94 commented 6 months ago

I'm still having a problem with this if anyone can help me, It keeps jumping back to the same port. Ive tried adding the connection between the GND pin and a lug on the HDMI and this just stops the device from functioning alltogether, it seems to set the LOLIN D1 into flash mode. Any help would be grately appreciated.

KR4DIO commented 6 months ago

I'm still having a problem with this if anyone can help me, It keeps jumping back to the same port. Ive tried adding the connection between the GND pin and a lug on the HDMI and this just stops the device from functioning alltogether, it seems to set the LOLIN D1 into flash mode. Any help would be grately appreciated.

If connecting the grounds together makes the esp8266 go into flash mode, you have connected something wrong. Make sure you didn't connect pin D3 to anything.