Car lock/unlock/remote start esp8266 and a spare keyfob

A car remote start/lock/unlock for 2 cars using a spare keyfob. Simply pushing a button on the fob usually shortens 2 contacts and trigger the fob. The same thing can be done with a relay board and an esp8266. Esp must close the relay for 0.5 second for the first car and 1.5 seconds for the second car. The relay is wired normally open (obviously). My relay board is low trigger (bought by mistake) which means when the esp is not sending a command (switch turned off), the relay is triggering, hence, all switches outputs are inverted.



esphome:
  name: esphome-web-099498
  friendly_name: keyfob-gate-garage

esp8266:
  board: nodemcuv2

# Enable logging
logger:

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

ota:
  password: "xxxxxxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  use_address: 192.168.2.xxxx

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

captive_portal:

    
#Define sensors
sensor:
  - platform: wifi_signal
    name: ${upper_devicename} Wifi Signal
    update_interval: 60s

  - platform: uptime
    name: ${upper_devicename} Uptime
   

#Wifi status
binary_sensor:
  - platform: status
    name: ${upper_devicename} Status

#firmware status
text_sensor:
  - platform: version
    name: ${upper_devicename} ESPHome Version


#switches
switch:
  - platform: gpio
    pin: D4 #Internal LED switching
    name: "NodeMCU Internal LED"
    id: internal_led
    inverted: true
    restore_mode: ALWAYS_ON

  
  - platform: gpio
    pin: D0
    name: "Bravada Unlock"
    id: BRUNLOCK
    restore_mode: ALWAYS_OFF
    inverted: true
    on_turn_on:
    - delay: 500ms
    - switch.turn_off: BRUNLOCK
    - delay: 500ms
    - lock.unlock: Bravada

  - platform: gpio
    pin: D1
    name: "Bravada lock"
    id: BRLOCK
    restore_mode: ALWAYS_OFF
    inverted: true
    on_turn_on:
    - delay: 500ms
    - switch.turn_off: BRLOCK
    - delay: 500ms
    - lock.lock: Bravada

  - platform: gpio
    pin: D3
    name: "RAV4 Unlock"
    id: RV4UNLOCK
    restore_mode: ALWAYS_OFF
    inverted: true
    on_turn_on:
    - delay: 1500ms
    - switch.turn_off: RV4UNLOCK
    - delay: 500ms
    - lock.unlock: Rav4

  - platform: gpio
    pin: D2
    name: "Rav4 Lock"
    id: RV4LOCK
    restore_mode: ALWAYS_OFF
    inverted: true
    on_turn_on:
    - delay: 1500ms
    - switch.turn_off: RV4LOCK
    - delay: 500ms
    - lock.lock: Rav4

  - platform: gpio
    pin: D6
    name: "Rav 4 Gate"
    id: RV4GT
    restore_mode: ALWAYS_OFF
    inverted: true
    on_turn_on:
    - delay: 1500ms
    - switch.turn_off: RV4GT

  - platform: gpio
    pin: D5
    name: "Rav 4 remote start"
    id: remote
    restore_mode: ALWAYS_OFF
    inverted: true
    on_turn_on:
    - delay: 1500ms
    - switch.turn_off: remote

#just to fool home assistant into creating a lock entity
output:
  - platform: gpio
    pin: D8
    id: dummybravada
    inverted: true

  - platform: gpio
    pin: D8
    id: dummyrav4
    inverted: true
                                                                         
   

lock:
  - platform: output
    id: Bravada
    output: dummybravada
    name: "Bravada"
    on_lock:
      - switch.toggle: BRLOCK
    on_unlock:
      - switch.toggle: BRUNLOCK

  - platform: output
    id: Rav4
    output: dummyrav4
    name: "Rav4"
    on_lock:
      - switch.toggle: RV4LOCK
    on_unlock:
      - switch.toggle: RV4UNLOCK
    

2 Likes