UART Sensor or Switch Feedback

Hello!

i was getting nowhere using LAN to control my Sharp Interactive Whiteboard that I use as my TV.

As an alternative, I have wired up an ESP8266 to an RS232 level converter to the TVs serial port.
I have achieved one way control, and I am now looking at how I can get feedback from the panel on the current state.

uart:
  baud_rate: 38400
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);
  tx_pin: D4
  rx_pin: D3

switch:
  - platform: uart
    name: "Power On"
    data: [0x50, 0x4F, 0x57, 0x52, 0x20, 0x20, 0x20, 0x31, 0x0D, 0x0A]
    on_turn_on:
      then:
      - mqtt.publish:
          topic: esphome/rs232/sharp/state
          payload: "ON"
          retain: true

  - platform: uart
    name: "Power Off"
    data: [0x50, 0x4F, 0x57, 0x52, 0x20, 0x20, 0x20, 0x30, 0x0D, 0x0A]
    on_turn_on:
      then:
      - mqtt.publish:
          topic: esphome/rs232/sharp/state
          payload: "OFF"
          retain: true

  - platform: uart
    name: "HDMI 1"
    data: [0x49, 0x4E, 0x50, 0x53, 0x20, 0x20, 0x31, 0x30, 0x0D, 0x0A]
    on_turn_on:
      then:
      - mqtt.publish:
          topic: esphome/rs232/sharp/input
          payload: "HDMI1"
          retain: true

  - platform: uart
    name: "HDMI 2"
    data: [0x49, 0x4E, 0x50, 0x53, 0x20, 0x20, 0x31, 0x33, 0x0D, 0x0A]
    on_turn_on:
      then:
      - mqtt.publish:
          topic: esphome/rs232/sharp/input
          payload: "HDMI2"
          retain: true

  - platform: uart
    name: "HDMI 3"
    data: [0x49, 0x4E, 0x50, 0x53, 0x20, 0x20, 0x31, 0x38, 0x0D, 0x0A]
    on_turn_on:
      then:
      - mqtt.publish:
          topic: esphome/rs232/sharp/input
          payload: "HDMI3"
          retain: true

  - platform: uart
    name: "DISPLAYPORT"
    data: [0x49, 0x4E, 0x50, 0x53, 0x20, 0x20, 0x31, 0x34, 0x0D, 0x0A]
    on_turn_on:
      then:
      - mqtt.publish:
          topic: esphome/rs232/sharp/input
          payload: "DISPLAYPORT" 
          retain: true

  - platform: uart
    name: "Buffer Clear"
    id: bufferclear
    data: [0x0D, 0x0A]

  - platform: uart
    name: "MQTT to UART"
    data: 'id(mqttcommand).state.c_str()'
    on_turn_on:
      then:
      - mqtt.publish:
          topic: sharptv/switch/mqtt_to_uart/payload
          payload: 'id(mqttcommand).state.c_str()'

This is my current config, I was looking through the uart pages on ESPHome but I cannot see if it is even possible to check the response of a command or use a command as a sensor?

Anybody able to shed some light ? :slight_smile:

Thank you !

To get UART feedback you need to write a custom component or use this approach to process responses in using the uart debug lambda:

2 Likes