Skip to content

Macro Controlled Broadlink RM/RM2/RM Pro/RM3/BlackBean/A1 Web server with REST API (like..)

License

Notifications You must be signed in to change notification settings

uudruid74/RestHome

 
 

Repository files navigation

RestHome - Home Automation Backend Server with REST API

Supported devices: Most broadlink devices, anything supported by IFTTT, others via shell script

PYTHON 3.x READY and 2.x is no longer supported! Min version: 3.6!

Uses python-broadlink Based and inspired by BlackBeanControl Originally forked from broadlink-http-rest

The PDF Documentation is considered authoratative. This is outdated. Also, there is RestHome YOUTUBE Video!

System Features

  • Multithreaded Responsive, handles multiple clients, programmable events and timers
  • Programmable Macro Language contains variables, loops, conditions, and shell integration
  • IFTTT Integration Send or Recieve commands from IFTTT to control anything IFTTT can control
  • Virtual Devices A single broadlink can control multiple virtual devices
  • Fast Learning No more waiting 20 seconds to learn every command!
  • Web Scraping Read information from websites into variables
  • State Safety Define startup/shutdown commands to restore sane state
  • Webserver Internal web server for media (think Chromecast and UI) in progress!
  • Security Understands SSL proxies with appropriate whitelist security
  • Definable UI The "testing" UI is just starting. Currently view only while I standardize controls some

Theory Of Operation

RestHome was designed to be lightweight and easy to configure. Rather than a complex programming language or configuration syntax, RestHome uses a simple INI file to control its operation.

Example usage

  1. Update settings.ini with your configuration

After viewing the sample settings.ini, erase it! The system will autodetect your devices. It should tell you what optional modules need to be installed for various features

The [General] section contains the following optional parameters

  • ServerAddress = IP to listen on, rather than 0.0.0.0
  • ServerPort = listen port (defaults to 8080)
  • Timeout = Default timeout for network operations in seconds (default 8)
  • DiscoverTimeout = Device discovery timeout, defaults to the same as Timeout
  • LearnFrom = IP addresses that can issue new commands to learn from (default is any)
  • BroadcastAddress = a pending patch to python-broadlink will allow device discover to use a specified broadcast IP
  • Autodetect = if set to a number, do device discover for the given number of seconds. This option removes itself.
  • AllowOverwrite = if set to anything, allow learned commands to overwrite an existing entry. The default is to deny a command that is already learned
  • RestrictAccess = restrict all operations to this list of IPs
  • Password = allow password-protected POST operations from any address
  • Hostname = remote hostname for forming URLs in local media and UI tools
  • House = name of a device representing the entire house

If Password is specified, then GET operations are only allowed from hosts in RestrictAccess. GET operations won't need a password, but they'll only be allowed from specific hosts. There is currently no way to restrict hosts AND require a password, but serverAddress combined with firewall rules on the underlying host would be solution for the security paranoid, setting Password and not RestrictAccess.

  1. Start python server.py

Note the names of the devices found. These will be named by the hostname, so make sure the IP address resolves or enter it in /etc/hosts before you begin. You can also manually rename the devices in settings.ini

  1. In your browser:
http://localhost:8080/deviceName/learnCommand/mute  # learn command with name lamp
http://localhost:8080/deviceName/sendCommand/lampon # send command with name lamp, set lamp to 1
  1. Get and Set status of devices having COMMANDon and COMMANDoff abilities
http://localhost:8080/deviceName/sendCommand/lampon # automatically set status of "lamp" to "on"
http://localhost:8080/deviceName/getStatus/lamp     # return lamp status as 0 or 1
  1. Check pending events (client must be on the restrictAccess list)
http://localhost:8080/listEvents                    # list all pending events

Response:

{
        "ok": "eventList",
        "104": "POLL_BeagleBone_temp = thermostat",
        "3404": "fetchTempLoop = >fetchTemp fetchTempLoop"
}
  1. List Devices (client must be on the restrictAccess list)
http://localhost:8080/listDevices

Response:

{
        "ok": "deviceList",
        "Fireplace": "Duraflame Heater",
        "Alice": "Vizio SmartCast TV",
        "LivingRoom-BlackBean": "LivingRoom-BlackBean",
        "AV": "Sony DH770 AV Reciever",
        "AC": "GREE Air Conditioner",
        "default": "Unknown",
        "IFTTT": "IFTTT",
        "LG": "Ultra Blueray Player",
        "BeagleBone": "On-board GPIO Pins",
        "StrayScampsDen": "Entire House"
}
  1. List Status Variables (client must be on the restrictAccess list)
http://localhost:8080/BeagleBone/listStatus

Response:

{
        "ok": "BeagleBone Status",
        "temp": "70"
}
  1. List all devices by Room (if assigned to a room), starting with Household name:
http://localhost:8080/listRooms

Response:

{
        "ok": "StrayScampsDen",
        "KitchenHeater": "Kitchen",
        "Fireplace": "LivingRoom",
        "BedroomHeater": "Bedroom",
        "Kitchen": "Kitchen",
        "CoffeePot": "Kitchen",
        "BathroomHeater": "Bathroom",
        "Alice": "LivingRoom",
        "LG": "LivingRoom",
        "AC": "LivingRoom",
        "BeagleBone": "LivingRoom",
        "Bedroom": "Bedroom",
        "AV": "LivingRoom"
}
  1. Check the PDF documentation on how to program loops, conditionals, and integrate with IFTTT, etc

About

Macro Controlled Broadlink RM/RM2/RM Pro/RM3/BlackBean/A1 Web server with REST API (like..)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 59.5%
  • TeX 20.3%
  • JavaScript 16.5%
  • HTML 2.3%
  • CSS 1.4%