GithubHelp home page GithubHelp logo

chomman / record-and-replay-rf-remote Goto Github PK

View Code? Open in Web Editor NEW

This project forked from defcon24bit/record-and-replay-rf-remote

0.0 1.0 0.0 10.31 MB

record & replay RF signal with Raspberry Pi & RTL-SDR dongle (optional) integrate with Home Assistant, Alexa and Google Home

License: Creative Commons Zero v1.0 Universal

record-and-replay-rf-remote's Introduction

record and replay Radio Frequency (RF) remote signal

Record any replay any RF signal. (optional) Integrate with Home Assistant. Trigger replay with Alexa or Google Home.
        Common use cases: airconditioners, remote power plugs, fans, garage doors, shades and kitchen hoods.

required hardware

  • Raspberry Pi
  • radio receiver USB dongle (RTL-SDR with RTL2832U chipset)

record and replay RF signal

on your Pi

  1. Install Raspberry Pi OS.
  2. Install https://github.com/F5OEO/rpitx
  3. Connect the RTL-SDR dongle to your Pi.
  4. Record remote signal.

To find the frequency, your can install SDR software. If the remote has an FCC id, you can look that up here. Common frequencies are: 433.92, 868.3, 315, 288, 300, 303, 306, 310, 318, 330, 390, 403.55 and 418 MHz.

cd rpitx
# this records on 868.00 MHz frequency and writes it to a fan-on-button.iq file
rtl_sdr -s 250000 -g 35 -f 868.0000e6 fan-on-button.iq

      above can also be done through the rtlmenu.sh GUI

  1. CTRL + C to stop recording.

You can remove the RTL-SDR dongle when you're done recoding. It's not required for sending.

  1. Add electrical wire to GPIO pin#7 (4th pin down, left row) - see picture.
  2. Replay recording.
sudo ./rpitx/sendiq -s 250000 -f 868.0000e6 -t u8 -i ./rpitx/fan-on-button.iq

integrate with Home Assistant

If you don't have HA, start here.

add as switch

Create a command line switch for everyone recording you want to replay.

# configuration.yaml
switch:
  - platform: command_line
    switches:
      fan_on:
# ssh is only required if HA and rpitx run on different machines
        command_on: "ssh -i /config/id_rsa -o StrictHostKeyChecking=no -q pi@<YOUR.PI.IP.ADDRESS> sudo ./rpitx/sendiq -s 250000 -f 868.0000e6 -t u8 -i ./rpitx/fan-all-on.iq"
        command_off: off
# HA doesn't get feedback if the device is on or off.  This returns the switch always back to the off-state.  
        command_state: off
        friendly_name: Fan On

expose switch to 'emulated hue' component

This will allow Alexa to see the switch as a Philips Hue light.

# configuration.yaml
emulated_hue:
  listen_port: 80
  expose_by_default: false
  entities:
    switch.fan_on:
      name: "fan on"
      hidden: false

Alexa gets confused if you create multiple devices with simular names.
To work around this, create Alexa Routines with a unique trigger sentences and avoid the words 'on' or 'off'.
I used start- and stop cooking - see example.

create automation that exposes switch as a webhook

This will allow you to remotely trigger the switch via an HTTP POST request.
Can be used with Google Home for example.

# configuration.yaml
automation:
  - alias: webhook_fan_on
    trigger:
    - platform: webhook
      webhook_id: <PICK-A-RANDOM-WEBHOOK-ID>
    condition: []
    action:
    - data: {}
      entity_id: switch.fan_on
      service: switch.turn_on
    mode: single

Test the webhook

curl -X POST https://<YOUR-HA>.duckdns.org/api/webhook/<YOUR-WEBHOOK-ID>

create certificate on HA

Only required if HA and rpitx run on different machines.
The certificate allows to remote execute ssh commands on another machine without a password prompt.

create certificate

ssh-keygen -t rsa -b 4096

send certificate to your pi (command still run on HA)

ssh-copy-id pi@<YOUR.PI.IP.ADDRESS>

Initially, HA gave errors when running the remote ssh commands. I can't remember the exact fix. It was either the HA user context not having access to the key files or the file and folder permissions for the certificate keys were not set correctly. I think below two things fixed it. Let me know if this works for you.

on HA copy the id_rsa to the HA /config folder

on your Pi

chmod 700 ~/.ssh/
chmod 600 ~/.ssh/*

create webhooks without HA

If you don't have HA, you can try creating webhooks with https://github.com/ncarlier/webhookd.
Protecting this setup is beyond the scope of this repository. It's not a question if you get hacked, but when.
Consider using an nginx proxy, Let's Encrypt and Duck DNS.

credits

All rights of the original authors reserved.

Creative Commons Zero v1.0 Universal license

record-and-replay-rf-remote's People

Contributors

defcon24bit avatar

Watchers

James Cloos 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.