ESP8266 door sensor

Tags: #<Tag:0x00007f73b4b60998> #<Tag:0x00007f73b4b608d0>

Hi. I’m a noob to Home Assistant. I have an esp8266 flashed with tasmota detected by home assistant through mqtt but I can’t work out how to configure either so Home assistant detects the change in sensor status. The sensor at the moment being a piece of wire shorting a gpio.

I’m a newbie and a bit stuck.

I have a nodemcu flashed with Tasmota and I’m trying to use as a door sensor.

I have home assistant with mosquito installed.

I’ve got the tasmota to show up on the dashboard.

With the tasmota pretending to be a sonoff basic. I get a handy switch on my dashboard but in generic mode I get nothing. I have a switch set up on the tasmota and when I trigger it (detach the wire) it shows up on the tasmota console but not on home assistant.

What I want is for it to send me a notification.

I’ve looked into it but I don’t understand what I’m supposed to do, now. Could someone give me s shove in the right direction?

what does it look like

What do you want to see? I can only post one picture.

there are heap of esp8266

I have a D1 min (wemos)

have a micro switch on D6 or D8 its in the wall been there for over 3 years

as i open close the door

the console say

so in my binarysensor.yaml i have

  - platform: mqtt    
    name: "Cupboard Door"
    state_topic: "stat/H_Cupboard/POWER"
    qos: 2
    payload_on: "ON"
    payload_off: "OFF"
    device_class: door

then in lovelace

image

remember note for other new beee

in the states page we see a on/off

but as we have put a device_class: to it

it will show a open/close

so just remember

in the automation we check for the STATE of it so

#=======================================================================
# Cupboard Door Open
#=======================================================================
- id: 'Cupboard Door Open'
  alias: Cupboard Door Open
  initial_state: true
  trigger:
  - entity_id: binary_sensor.cupboard_door
    platform: state
    to: 'on'  # < not the open / close
  condition:
  - condition: state
    entity_id: switch.cupboard_heater
    state: 'on' 
  action:
  - data:
      entity_id: switch.cupboard_heater
    service: switch.turn_off
  - data:
      entity_id: input_boolean.notify_heater
    service: input_boolean.turn_on
#=======================================================================
# Cupboard Door Closed
#=======================================================================
- id: Cupboard Door Closed
  alias: Cupboard Door Closed
  trigger:
  - entity_id: binary_sensor.cupboard_door
    platform: state
    to: 'off'
  condition:
  - condition: state
    entity_id: input_boolean.notify_heater
    state: 'on'
  action:
  - data:
      entity_id: switch.cupboard_heater
    service: switch.turn_on
  - data:
      entity_id: input_boolean.notify_heater
    service: input_boolean.turn_off

now lets make smarter

what about turn the hall light on when i open the door and it nite

#=======================================================================
# Hall Light On Cupboard Open at nite time
#=======================================================================
- id: Hall Light On Cupboard Open
  alias: Hall Light On Cupboard/linen Open
  initial_state: true
  trigger:
  - entity_id: 
    - binary_sensor.cupboard_door
    - binary_sensor.linen_door
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: light.hallway
    state: 'off'
  - condition: state
    entity_id: sensor.day_night
    state: Night
  action:
  - data:
      entity_id: light.hallway
    service: light.turn_on
  - data:
      entity_id: input_boolean.hall_light
    service: input_boolean.turn_on

and when I close it

#=======================================================================
#  Hall Light On Cupboard and linen Closed
#=======================================================================
- id: Hall Light On Cupboard Closed
  alias: Hall Light Off Cupboard/linen Closed
  initial_state: true
  trigger:
  - entity_id: 
    - binary_sensor.cupboard_door
    - binary_sensor.linen_door
    platform: state
    to: 'off'
  condition:
  - condition: state
    entity_id: input_boolean.hall_light
    state: 'on'
  action:
  - delay: 00:00:03
  - data:
      entity_id: light.hallway
    service: light.turn_off
  - data:
      entity_id: input_boolean.hall_light
    service: input_boolean.turn_off

added a delay so i get to where im going before the light goes off.

OK. I’d not touched the yaml. I have the tasmota on the dashboard but it only reports the connection strength.
I’ve got as far as adding the binarysensor.yaml, modified to reflect what happens in my tasmota console. Do I have to refer to the new file in confiuration.yaml?

Yes. Look at the docs regarding splitting configuration.yaml.
Or you can put the code directly on configuration.yaml (binary_sensor: and the code)