Code Monkey home page Code Monkey logo

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, shades and kitchen hoods. This won't work with rolling codes often used for more secure communication to open doors for example.

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
command_line:
  - switch:
      name: fan_on
      unique_id: 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

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>
      allowed_methods:
        - POST
        - PUT
      local_only: false
    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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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

Range?

Thank you very much for the instructions, I have ordered a USB receiver.

How is the range with the wire antenna?
1m or more like 20m?

Signal strength

Hi, love your work.
Want to try for receiving my 868 MHz pir and door sensors Signal and send signals to my 433-868-315 devices on Home Assistant.

Also i want to ask you about how can i send Rf signals to all around my house, i need at least 20 meters range also Coupe of walls.

With rpitx and raspberry pi3B+ can i use some module to make my signals range longer?

Code not working with latest HomeAssistant Core 2024.1.3 Supervisor 2023.12.0?

Hi;
Your project is very interesting, and I'm trying to use it to command all my blinds from HA.
Managed to copy the signal and send it via the gpio 7. I need to find a proper antenna to send it trought my whole house now.

However, HA doesn't seem to accept your code now. Had to copy the "automation" part to automation.yam, but i still can't use the webhooks:
Service switch.store_desk_close not found.
Seems like there have been some changes in HA since june!

Thanks in advance

Missing part in the code

After a while it works perfect, thanks a lot!
My garage door is from GILGEN and shutters are GRIESSER.

I recommend in the configuration.yaml to add:
unique_id: Fan off

Does it work with 868t20d e32?

Hi
Totally newbie.
I got a remote control (868mhz) to unlock our gate connected to a relay Enocean 868mhz.
I bought an e32 868 mhz hoping to connect it to my home assistant on a rpi4... objective is to be able to open gate without searching for the remote control !
Still not found to way to do it.
Any help would be really appreciated. Thanks

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.