Esphomelib - library to greatly simplify Home Assistant integration with ESP32

hi @OttoWinter,

i was wondering what is best practice to integrate 433mhz door/window sensors with ESPHome.
I see remote receiver component

is what I would use, but it is not completely clear to me how to create a binary sensor which “stays on” for the whole time while the door/window is open.
Accoding to the link, in fact, this:

Binary Sensor

The remote_receiver binary sensor lets you track when a button on a remote control is pressed.

Each time the pre-defined signal is received, the binary sensor will briefly go ON and then immediately OFF.

binary_sensor:
  - platform: remote_receiver
    name: "my door/window sensor"
    panasonic:
      address: 0x4004
      command: 0x100BCBD

will not work.
Would be best practice to create an automation and another binary sensor to switch on/off with some logic?

I’m having the same issue and my wiring is correct, so I’d agree with Future Tense something is not working with Esphome…I’m not smart enough to work it out though :rofl:

I too would like to know this, this setup works great for an RF doorbell I have.

I was using openmqttgateway which worked really well, may be worth checking that out if no one comments with a solution.

A door or window is a cover, not a binary sensor. see post below.

Not correct. a ‘cover’ is a blind or garage door etc, where there is control to open / close. Monitoring of an existing door as being open of closed is a binary sensor.

That said, it’s not 100% clear what @mspinolo is trying to do here, control or monitor…?

Actually yes, I’ll amend that. good point.

assuming the same as my use case, a sensor to detect wether the door is open or closed, my sensors send an RF code when the door is going from closed to open and a different code when going from open to closed, I found a thread on the forum that helped me put this together which seems to work well for me.

  - platform: remote_receiver
    name: "Back Door (RF-On)"
    device_class: opening
    internal: true
    on_press:
      then:
        - binary_sensor.template.publish:
            id: switchbackdoor
            state: OFF
    rc_switch_raw:
      code: '110100000100010000001110'
      protocol: 1
  - platform: remote_receiver
    name: "Back Door (RF-Off)"
    internal: true
    on_press:
      then:
        - binary_sensor.template.publish:
            id: switchbackdoor
            state: ON
    rc_switch_raw:
      code: '110100000100010000001010'
      protocol: 1
  - platform: template
    name: "Back Door"
    device_class: door
    id: switchbackdoor

So if that’s the case @mspinolo needs to clarify, and it is in fact a binary_sensor as per your code. Hopefully what you have posted will help @mspinolo out. Thanks for sharing

I have a question regarding the scope of ID variables. For instance, the ID deep_sleep_1 in the code below. Is that a global variable or local variable? Specifically, I want to know if I have to change the name of the ID for each ESP when I have several ESPs with identical code. I do use substitutions for the main name of the ESP. Thanks in advance for your responses.

substitutions:
  devicename: blind_1
  devicename_friendly: Blinds Master

esphome:
  name: ${devicename}
  platform: ESP8266
  board: nodemcuv2

This is the ID I am referring to.

deep_sleep:
  
  id: deep_sleep_1

mqtt:

  on_message:
    topic: livingroom/ota_mode
    payload: 'ON'
    then:
      - deep_sleep.prevent: deep_sleep_1

I am trying to control my blinds with Esphome because those are my last ESP devices that are not using it. I am using servos to open/close the blinds automatically depending on the light measured by the LDR. All the hardware is hosted inside the blinds and it is not visible from the outside for aesthetic reasons. The nodemcu wakes up every 30 minutes, measures the light level outside and opens/closes the blinds automatically and then goes into deep sleep. Everything runs with rechargeable batteries connected to solar panels. So far I was successful until I was implementing the Prevent action for deep sleep. I want to prevent deep sleep in case I want to perform an update via OTA. The documentation to do that suggests to use and mqtt message to trigger the prevent action.

mqtt:
  # ...
  on_message:
    topic: livingroom/ota_mode
    payload: 'ON'
    then:
      - deep_sleep.prevent: deep_sleep_1

However, if I want to enable mqtt then I can’t use the native API that I need to control the servo. Any suggestions would be greatly appreciated.

api:
  services:
    - service: control_servo
      variables:
        level: float
      then:
        - servo.write:
            id: blind_1_servo
            level: !lambda 'return level / 100.0;'

When enabling MQTT and you do not use the “native API” for Home Assistant, you must remove the api: line from your ESPHome configuration, otherwise the ESP will reboot every 5 minutes because no client connected to the native API.

check api docs you can disable the reboot by configuring reboot_timeout to 0

Can anybody close this topic? New questions should be asked on new topics
@OttoWinter
thanks

I guess you’re right @glmnet, one topic per question is probably the best way.

Please open a new topic here (https://community.home-assistant.io/c/third-party/esphome) for asking questions, thanks