# 433mhz receiver board. Facing the board:
#  pins: 3v3  | N.C. (cs)  | D15   | gnd

esphome:
  name: "li-rf-recv"
  platform: esp32
  board: lolin32

logger:
  level: INFO

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

ota:
  platform: esphome
  password: !secret ota_password_1

mqtt:
  id: mqtt_client
  broker: "mqtt2.bigasterisk.com"

light:
  - platform: status_led
    id: "status_out"
    pin: 2

remote_receiver:
  - id: rf_in
    pin:
      number: GPIO15
    tolerance: 30%
    filter: 250us
    idle: 8ms
    dump: rc_switch
    on_rc_switch:
      then:
        # - logger.log:
        #     level: INFO
        #     tag: out
        #     format: "RF read; proto %d; code %08llx"
        #     args: [x.protocol, x.code]
        - light.turn_on:
            id: status_out
            flash_length: 30ms
        - mqtt.publish:
            topic: !lambda |-
              return "li-rf-recv/rf_received/" + 
                std::to_string(x.protocol) +
                "/" + std::to_string(static_cast<unsigned long>(x.code >> 32)) +
                "/" + std::to_string(static_cast<unsigned long>(x.code & 0xffff));
            payload: ""
