Package: raspyrfm-client
raspyrfm-clientA python 3.4+ library that allows the generation of network codes for the RaspyRFM rc module (and other gateways too!).Build StatusMasterBetaDevHow to useInstallationpip install raspyrfm-clientUsageFor a basic example have a look at theexample.pyfile.If you need more info have a look at thedocumentationwhich should help.Basic ExampleImport required modulesfromraspyrfm_clientimportRaspyRFMClientfromraspyrfm_client.device_implementations.controlunit.actionsimportActionfromraspyrfm_client.device_implementations.controlunit.controlunit_constantsimportControlUnitModelfromraspyrfm_client.device_implementations.gateway.manufacturer.gateway_constantsimportGatewayModelfromraspyrfm_client.device_implementations.manufacturer_constantsimportManufacturerCreate theRaspyRFMClientobjectGet a client instance by calling:rfm_client=RaspyRFMClient()Create aGatewayinstanceYou can let the library search automatically for gateways available in LAN using:gateways=rfm_client.search()This will return a list of Gateways that can later be used to send signals to.To get a quick overview of what gatewaymanufacturersandmodelsare supported call:rfm_client.list_supported_gateways()Create a gateway instance with the specifiedIPandPortof your Gateway by using:gateway=rfm_client.get_gateway(Manufacturer.SEEGEL_SYSTEME,GatewayModel.RASPYRFM,"192.168.2.10",9876)orgateway=rfm_client.get_gateway(Manufacturer.SEEGEL_SYSTEME,GatewayModel.RASPYRFM,"192.168.2.10")# defaults to 49880 or the gateway implementations defaultGet aControlUnitControlUnits are the devices that receive the RC signals sent using the gateway, f.ex. a power outlet.To get a quick overview of what ControlUnitsmanufacturersandmodelsare supported call:rfm_client.list_supported_controlunits()which will give you an indented list of supported manufacturers and their supported models similar to this:Elro
  RC3500-A IP44 DE
  AB440S
  AB440D 200W
  AB440D 300W
  AB440ID
  AB440IS
  AB440L
  AB440SC
  AB440WD
BAT
  RC AAA1000-A IP44 Outdoor
Brennenstuhl
  RCS 1000 N Comfort
  RCS 1044 N Comfort
Intertek
  Model 1919361
[...]To generate codes for a deviceyou first have to get an instance of its implementationlike this:brennenstuhl_rcs1000=rfm_client.get_controlunit(manufacturer_constants.BRENNENSTUHL,manufacturer_constants.RCS_1000_N_COMFORT)The parameters of theget_controlunit()method always need to be an enum value of the specified type.
You can get an enum constant by its name though using:manufacturer=Manufacturer("Intertechno")model=ControlUnitModel("IT-1500")ControlUnitchannel configurationBefore you can generate codes with your shiny new gateway andControlUnitimplementations you have to specify a channel configuration for yourControlUnit. Theseconfigurations can be very different for every device. The best way to know the correct way of specifying the channel configuration for a specific device is to look at the source code (yes I know…) or by trial and error (even worse). A goodControlUnitimplementation should tell you how the configuration should look like when specifying it in a wrong way.However all configurations are akeyed dictionary.
So in general there are two ways of passing the channel configuration argument.
One (inline):device.set_channel_config(value1=1,value2=2)Two (as a dictionary):device.set_channel_config(**{'value1':1,'value2':2})Notethat thekeys always need to be astring.
The second one is the recommended one as it will often result in a much more readable source code.For our Brennenstuhl device it would look like this:brennenstuhl_rcs1000.set_channel_config(**{'1':True,'2':True,'3':True,'4':True,'5':True,'CH':'A'})Generate action codesNow that you have a properly set upControlUnityou can generate codes for it’s supported actions by using anActionenum constant that you imported previously.To get a list of supported actions for aControlUnitcall:brennenstuhl_rcs1000.get_supported_actions()and generate a code for one of them using yourGatewayinstance:code=gateway.generate_code(brennenstuhl_rcs1000,Action.ON)Send the code to theRaspyRFMmoduleTo send a code for your device of choice you can combine the objects in this call:rfm_client.send(gateway,brennenstuhl_rcs1000,Action.ON)This will generate a code specific to the passed in gateway implementation and send it to it’s host address immediately after.Custom implementationsTheraspyrfm-clientlibrary is designed so you can implement custom devices in a (hopefully) very easy way.File StructureAllControlUnitimplementations are located in the/device_implementations/controlunit/manufacturer/module and implement the base classDevicethat can be found in/device_implementations/controlunit/base.py.Create a newControlUnitTo create a newControlUnitimplementation for a new manufacturer and model create a new subdirectory for your manufacturer and a python file for your model:â”€â”€â”€raspyrfm_client
â”‚   â”‚   client.py
â”‚   â”‚
â”‚   â””â”€â”€â”€device
â”‚       â”‚   actions.py
â”‚       â”‚   base.py
â”‚       â”‚
â”‚       â””â”€â”€â”€manufacturer
â”‚           â”‚   manufacturer_constants.py
â”‚           â”‚
â”‚           â”œâ”€â”€â”€intertek
â”‚           â”‚       Model1919361.py
â”‚           â”‚
â”‚           â”œâ”€â”€â”€rev
â”‚           â”‚       Ritter.py
â”‚           â”‚       Telecontrol.py
â”‚           â”‚
â”‚           â”œâ”€â”€â”€universal
â”‚           â”‚       HX2262Compatible.py
â”‚           â”‚
â”‚           â””â”€â”€â”€yourmanufacturer
â”‚                   yourmodel.py
â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€Implement aControlUnitNow the basic implementation of yourControlUnitshould looks like this:fromraspyrfm_client.device_implementations.controlunit.actionsimportActionfromraspyrfm_client.device_implementations.controlunit.baseimportControlUnitclassYourModel(ControlUnit):def__init__(self):fromraspyrfm_client.device_implementations.manufacturer_constantsimportManufacturerfromraspyrfm_client.device_implementations.controlunit.controlunit_constantsimportControlUnitModelsuper().__init__(Manufacturer.YourManufacturer,ControlUnitModel.YourModel)defget_channel_config_args(self):return{}defget_pulse_data(self,action:Action):return[[0,0],[0,0]],0,0defget_supported_actions(self)->[str]:return[Action.ON]Most importantly you have to call thesuper().__init__method like shown. This will ensure that your implementation is found by theRaspyRFMClientand you can get an instance of your device usingrfm_client.get_controlunit()as shown before.If your manufacturer does not exist yetcreate a new enum constantin themanufacturer_constants.pyfile and use its value in your__init__.Do the same thing for your model namein thecontrolunit_constants.pyfile.You also have to implement all abstract methods from theDeviceclass. Have a look at it’s documentation to get a sense of what those methods are all about.After you have implemented all methods you are good to go!
Just callrfm_client.reload_implementation_classes()andrfm_client.list_supported_controlunits()to check if your implementation is listed.
If everything looks good you can use your implementation like any other one.Exclude a WIP implementationTo prevent the RaspyRFM client from importing your half baked or base class implementation just include a class field like this:classYourModel(ControlUnit):DISABLED=True[...]ContributingGitHub is for social coding: if you want to write code, I encourage contributions through pull requests from forks
of this repository. Create GitHub tickets for bugs and new features and comment on the ones that you are interested in.Licenseraspyrfm-client by Markus Ressel
Copyright (C) 2017  Markus Ressel

This 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 3 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, see <http://www.gnu.org/licenses/>.