Package: cec
python-cec - libcec bindings for Pythonpython-cecallows you to control your TV, reciever and other CEC-compliant HDMI devices from a python script on a computer. Most computer graphics cards don't support CEC; you'll need aPulse-Eight USB-CEC adapteror a Raspberry Pi (tested on Raspberry Pi 3 Model B Rev 1.2).Installing:Install dependenciesTo build python-cec, you need version 1.6.1 or later of the libcec development libraries:On Gentoo:sudo emerge libcecOn OS X:brew install libcecUbuntu, Debian and Raspbian:sudo apt-get install libcec-dev build-essential python-devInstall from PIPpip install cecInstalling on WindowsYou need tobuild libcecfrom source, because libcec installer doesn't providecec.libthat is necessary for linking.Then you just need to set up your paths, e.g.:set INCLUDE=path_to_libcec\build\amd64\include
set LIB=path_to_libcec\build\amd64Getting StartedA simple example to turn your TV on:importceccec.init()tv=cec.Device(cec.CECDEVICE_TV)tv.power_on()APIimportcecadapters=cec.list_adapters()# may be called before init()cec.init()# use default adaptercec.init(adapter)# use a specific adaptercec.close()# not implemented yetcec.add_callback(handler,events)# the list of events is specified as a bitmask of the possible events:cec.EVENT_LOGcec.EVENT_KEYPRESScec.EVENT_COMMANDcec.EVENT_CONFIG_CHANGE# not implemented yetcec.EVENT_ALERTcec.EVENT_MENU_CHANGEDcec.EVENT_ACTIVATEDcec.EVENT_ALL# the callback will receive a varying number and type of arguments that are# specific to the event. Contact me if you're interested in using specific# callbackscec.remove_callback(handler,events)devices=cec.list_devices()classDevice:__init__(id)is_on()power_on()standby()addressphysical_addressvendorosd_stringcec_versionlanguageis_active()set_av_input(input)set_audio_input(input)transmit(opcode,parameters)cec.is_active_source(addr)cec.set_active_source()# use default device typecec.set_active_source(device_type)# use a specific device typecec.set_inactive_source()# not implemented yetcec.volume_up()cec.volume_down()cec.toggle_mute()# TODO: audio statuscec.set_physical_address(addr)cec.can_persist_config()cec.persist_config()cec.set_port(device,port)# set arbitrary active source (in this case 2.0.0.0)destination=cec.CECDEVICE_BROADCASTopcode=cec.CEC_OPCODE_ACTIVE_SOURCEparameters=b'\x20\x00'cec.transmit(destination,opcode,parameters)Changelog0.2.8 ( 2022-01-05 )Add support for libCEC >= 5Windows supportSupport for setting CEC initiatorPython 3.10 compatibility0.2.7 ( 2018-11-09 )Implement cec.EVENT_COMMAND callbackFix several crashes/memory leaks related to callbacksAdd possibility to use a method as a callbackLimit maximum number of parameters passed to transmit()Fix compilation error with GCC >= 80.2.6 ( 2017-11-03 )Python 3 support ( @nforro )Implement is_active_source, set_active_source, transmit ( @nforro )libcec4 compatibility ( @nforro )0.2.5 ( 2016-03-31 )re-release of version 0.2.4. Original release failed and version number is now lost0.2.4 ( 2016-03-31 )libcec3 compatibility0.2.3 ( 2014-12-28 )Add device.h to manifestInitial pip release0.2.2 ( 2014-06-08 )Fix deadlockAdd repr for Device0.2.1 ( 2014-03-03 )Fix deadlock in Device0.2.0 ( 2014-03-03 )Add initial callback implementationFix libcec 1.6.0 backwards compatibility support0.1.1 ( 2013-11-26 )Add libcec 1.6.0 backwards compatibilityKnown Bug: no longer compatible with libcec 2.1.0 and later0.1.0 ( 2013-11-03 )First stable releaseCopyrightCopyright (C) 2013 Austin Hendrixnamniart@gmail.comThis program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program.  If not, seehttp://www.gnu.org/licenses/.