{"id":20989155,"url":"https://github.com/latchdevel/pyrcswitch","last_synced_at":"2025-12-28T11:00:17.212Z","repository":{"id":240351054,"uuid":"802394147","full_name":"latchdevel/pyRCSwitch","owner":"latchdevel","description":"Python module to wrap the RCSwitch Common Library","archived":false,"fork":false,"pushed_at":"2025-02-01T18:49:59.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T19:32:03.838Z","etag":null,"topics":["315mhz","433mhz","ask","cmake","extension","module","ook","pybind11","python","rc-switch","rc-switch-lib","rcswitch","rcswitch-library","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/latchdevel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-18T07:11:10.000Z","updated_at":"2025-02-01T18:50:03.000Z","dependencies_parsed_at":"2024-05-18T08:24:31.092Z","dependency_job_id":"e964aa2f-0db3-4b31-81b6-ab0e0a04c959","html_url":"https://github.com/latchdevel/pyRCSwitch","commit_stats":null,"previous_names":["latchdevel/pyrcswitch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2FpyRCSwitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2FpyRCSwitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2FpyRCSwitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2FpyRCSwitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/latchdevel","download_url":"https://codeload.github.com/latchdevel/pyRCSwitch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243401482,"owners_count":20285051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["315mhz","433mhz","ask","cmake","extension","module","ook","pybind11","python","rc-switch","rc-switch-lib","rcswitch","rcswitch-library","wrapper"],"created_at":"2024-11-19T06:23:59.285Z","updated_at":"2025-12-28T11:00:12.134Z","avatar_url":"https://github.com/latchdevel.png","language":"Python","readme":"# pyRCSwitch\nPython C++ extension module to wrap the **RCSwitch Common Library**.\n\nWorks on any **libc++** compatible system with Python v3.8 or higher, such as macOS, FreeBSD, Linux, and even Windows.\n\n[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)\n[![Build tests](https://github.com/latchdevel/pyRCSwitch/actions/workflows/BuildTests.yml/badge.svg)](https://github.com/latchdevel/pyRCSwitch/actions/workflows/BuildTests.yml)\n\nThe [RCSwitch Common Library](https://github.com/latchdevel/rc-switch-lib) simulates capturing and reproducing operation codes of radio control devices like the popular low cost power outlet sockets, which works on the 315Mhz or 433MHz frequency in AM ASK/OOK modulation.\nIts main use is to **encode** RC codes into pulse trains and **decode** pulse trains into RC codes, based on some supported protocols.\n\nThere are other similar projects that support a large number of protocols, including some very complex ones, with a large number of pulses, such as [PiCode](https://github.com/latchdevel/PiCode). However, RCSwitch is very popular for its simplicity and ease of use.\n\n## Build and install\nPackage installation builds the C++ extension module, so some OS tools are required like these packages on Debian-based Linux systems:\n- Python3 development tools: `python3-dev`\n- C++ compiler suite: `build-essential`\n- CMake make system: `cmake`\n- Git version control system: `git`\n\n### Install by \"setuptools\" on user location\nRequire **setuptools** Python module, which can be installed in several ways:\n   - Install via OS package manager: `apt install python3-setuptools`\n   - Or install via **pip** Python package manager:\n     - Install pip: `apt install python3-pip` and `pip install setuptools`\n\n```\ngit clone --recursive https://github.com/latchdevel/pyRCSwitch\ncd pyRCSwitch\npython3 setup.py develop --user\n```\nNote the `--recursive` option which is needed for **pybind11** and **rc-switch-lib** submodules.\n\n### Install by \"pip\" on virtual environment\nRequire **venv** Python module, which can be installed via OS package manager: `apt install python3-venv`\n\n```\npython3 -m venv pyRCSwitch_env\nsource pyRCSwitch_env/bin/activate\npython3 -m pip install --upgrade pip setuptools wheel\npython3 -m pip install -v git+https://github.com/latchdevel/pyRCSwitch.git\n```\n\n## Tests\npyRCSwitch provides a unit tests module to verify its correct operation: `python3 -m unittest discover -v pyRCSwitch`\n\n```\npython3 -m unittest discover -v pyRCSwitch \ntest_RCSwitchDecode (tests_pyRCSwitch.test_pyRCSwitch) ... ok\ntest_RCSwitchObjectInstance (tests_pyRCSwitch.test_pyRCSwitch) ... ok\ntest_RCSwitchSendCodeBinary (tests_pyRCSwitch.test_pyRCSwitch) ... ok\ntest_RCSwitchSendCodeTriState (tests_pyRCSwitch.test_pyRCSwitch) ... ok\ntest_RCSwitchSendCodeValue (tests_pyRCSwitch.test_pyRCSwitch) ... ok\ntest_RCSwitchSendPiCodeValue (tests_pyRCSwitch.test_pyRCSwitch) ... ok\ntest_RCSwitchSendSliding (tests_pyRCSwitch.test_pyRCSwitch) ... ok\ntest_RCSwitchSendTypeCIntertechno (tests_pyRCSwitch.test_pyRCSwitch) ... ok\ntest_RCSwitchSendTypeD (tests_pyRCSwitch.test_pyRCSwitch) ... ok\ntest_moduleVersion (tests_pyRCSwitch.test_pyRCSwitch) ... ok\n\n----------------------------------------------------------------------\nRan 10 tests in 0.002s\n\nOK\n```\n\n## Usage\nExample of encode and decode RC command for **switch on** \"11111\", \"00010\" (Type B with two rotary/sliding switches):\n```python\n\u003e\u003e\u003e from pyRCSwitch import RCSwitch\n\u003e\u003e\u003e mySwitch = RCSwitch()\n\u003e\u003e\u003e \n\u003e\u003e\u003e pulse_list = mySwitch.switchOn(\"11111\", \"00010\") # Generate a pulse train from an RC command\n\u003e\u003e\u003e pulse_list\n[350, 1050, 350, 1050, 350, 1050, 350, 1050, 350, 1050, 350, 1050, 350, 1050, 350, 1050, 350, 1050, 350, 1050, 350, 1050, 1050, 350, 350, 1050, 1050, 350, 350, 1050, 1050, 350, 350, 1050, 350, 1050, 350, 1050, 1050, 350, 350, 1050, 350, 1050, 350, 1050, 1050, 350, 350, 10850]\n\u003e\u003e\u003e \n\u003e\u003e\u003e mySwitch.decodePulseTrain(pulse_list) # Try to pulse train decode\nTrue\n\u003e\u003e\u003e mySwitch.getReceivedValue() # Get RC code value\n5393\n\u003e\u003e\u003e mySwitch.getReceivedBitlength() # Get RC code bit length\n24\n\u003e\u003e\u003e mySwitch.getReceivedProtocol() # Get RC code protocol\n1\n\u003e\u003e\u003e mySwitch.send(5393,24) == pulse_list # Verify that RC code value obtained is the same as generated pulse train\nTrue\n\u003e\u003e\u003e \n```\n\nIt can be used together with [pyPiCode](https://github.com/latchdevel/pyPiCode) to perform cross encoding and decoding by exchanging pulse trains.\n\nExample of RC code generation for **switch off** via decoding and re-encoding using **pyPiCode** library.\n```python\n\u003e\u003e\u003e import pypicode as picode\n\u003e\u003e\u003e \n\u003e\u003e\u003e from pyRCSwitch import RCSwitch\n\u003e\u003e\u003e mySwitch = RCSwitch()\n\u003e\u003e\u003e \n\u003e\u003e\u003e picode.decodePulseTrain( mySwitch.switchOn(\"11111\", \"00010\") ) # \u003c---- Same RC command\n{'protocols': [{'arctech_screen_old': {'id': 14, 'unit': 0, 'state': 'up'}}, {'arctech_switch_old': {'id': 14, 'unit': 0, 'state': 'on'}}, {'beamish_switch': {'id': 21, 'unit': -1}}, {'elro_800_switch': {'systemcode': 31, 'unitcode': 8, 'state': 'on'}}, {'rev1_switch': {'id': 'F2', 'unit': 62, 'state': 'off'}}]}\n\u003e\u003e\u003e \n\u003e\u003e\u003e mySwitch.decodePulseTrain( picode.encodeToPulseTrainByName('arctech_switch_old', {'id': 14, 'unit': 0, 'state': 'off'}) ) # \u003c---- Set 'off' here\nTrue\n\u003e\u003e\u003e mySwitch.getReceivedValue() # Get RC code value for switch off\n5396\n\u003e\u003e\u003e mySwitch.getReceivedBitlength()\n24\n\u003e\u003e\u003e mySwitch.getReceivedProtocol()\n1\n\u003e\u003e\u003e mySwitch.send(5396,24) == mySwitch.switchOff(\"11111\", \"00010\") # Verify that RC code obtained is the same as that for switch off\nTrue\n\u003e\u003e\u003e picode.pulseTrainToString( mySwitch.send(5396,24) ) # Converts RC code value to 'picode' string format\n'c:01010101010101010101011001100110010101100110010102;p:350,1050,10850@'\n```\n\n# License\nCopyright (c) 2024 Jorge Rivera. All right reserved.\n\nLicense GNU Lesser General Public License v3.0.\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with this program; if not, write to the Free Software Foundation,\nInc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\nSee the [LICENSE](LICENSE.txt) file for license rights and limitations (lgpl-3.0).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flatchdevel%2Fpyrcswitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flatchdevel%2Fpyrcswitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flatchdevel%2Fpyrcswitch/lists"}