Git Product home page Git Product logo

rf-doorbell-serial's Introduction

RF-doorbell-serial

Using an Arduino with RF receiver to detect when my doorbell has been pressed.

I purchased a cheap RF doorbell and receiver on Amazon. I wish to integrate it to Home-assistant so that I can receive mobile notifications when someone presses the doorbell. I previously did this using a dedicated raspberry pi that relayed RF events via MQTT. Here I use an Arduino relaying RF messages over the serial port. My reason for swapping pi for Arduino is mostly because it is overkill to use a pi and I would rather use mine for other projects. The reason for swapping MQTT for serial is that I can read from serial using Home-assistant and I now am not reliant on an MQTT server.

Usage

I'm using a Mac. To check which port the Arduino is on I run:

ls /dev/cu.*

In my case the Arduino is connected on /dev/cu.usbmodem14341. I now use screen to check the data transmitted over the serial when the Arduino receives an RF input. In the terminal I launch screen with:

screen /dev/cu.usbmodem14341 9600

I then press the doorbell remote and see Doorbell pressed at 730. I then kill the screen session using ctrl + a + k, and can now configure Home-assistant to display the message from the Arduino. I add to my Home-assistant config:

sensor:
  - platform: serial
    serial_port: /dev/cu.usbmodem14341

I restart Home-assistant and confirm that the state of this sensor is the message sent from the Arduino. Now I am only interested in displaying when the doorbell is pressed, and I would like a binary sensor which is ON when the doorbell is pressed. I will use a little trick I learned recently, of creating an input_boolean, and using an automation to toggle this ON/OFF when the state of the serial sensor changes. I first add the input_boolean to my Home-assistant config. However I wan't to see a boolean indicator on the front-end (rather than the input-slider) so I also add a template binary sensor and restart Home-assistant to make the changes take effect.

input_boolean:
  doorbell:
    name: Doorbell
    icon: mdi:alarm-bell

binary_sensor:
  - platform: template
    sensors:
      doorbell:
        value_template: "{{ is_state('input_boolean.doorbell', 'on') }}"

I now use the automations editor to create automations to toggle the input_boolean when the serial sensor changes state (after a doorbell button press). Additionally I publish ON/OFF on the MQTT topic 'doorbell' so that a remote HA instance can receive the doorbell state. I now have in automations.yaml.

- action:
  - service: input_boolean.turn_on
  - alias: ''
    data:
      payload: 'ON'
      topic: doorbell
    service: mqtt.publish
  alias: Doorbell_on
  condition: []
  id: '1513433912908'
  trigger:
  - entity_id: sensor.serial_sensor
    platform: state
- action:
  - service: input_boolean.turn_off
  - data:
      payload: 'OFF'
      topic: doorbell
    service: mqtt.publish
  alias: Doorbell_off
  condition: []
  id: '1513433982733'
  trigger:
  - entity_id: input_boolean.doorbell
    for:
      seconds: 2
    platform: state
    to: 'on'

I now have a boolean on my Home-assistant front end which turns on when the doorbell is pressed. I can also view the state of the doorbell on a remote HA instance using an MQTT binary sensor, with the following in my config:

binary_sensor:
  - platform: mqtt
    name: "Doorbell"
    state_topic: "doorbell"

Finally I create an automation to send me a notification when the doorbell is pressed:

- action:
  - data:
      message: The doorbell was pressed
    service: notify.robins_and_marias_iphones
  alias: Doorbell notification
  condition: []
  id: '1513507538746'
  trigger:
  - entity_id: binary_sensor.doorbell
    platform: state
    to: 'on'

Hassio

I'm running Hassio on a pi3. To check the serial port that the Arduino is connected on I SSH into the Hassio and run hassio host hardware, and find that the Arduino is on /dev/ttyACM0.

Synology

My main HA instance runs in Docker on a Synology. To try https://philhawthorne.com/installing-home-assistant-io-on-a-synology-diskstation-nas/

Refs

rf-doorbell-serial's People

Contributors

robmarkcole avatar

Stargazers

Robin Larsson avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.