Package: homescript
HomeScriptPython script for command line control ofHomeBridge(HomeKit)Used to toggle Homebridge accessories On or Off via python script, no Home app required. You can set up a cronjob to enable automation, scripting and mimic other HomeKit functionalitiesNote:as of HomeScript 4.1 the minimum requirement is Python3+ and HomeBridge 1.x.x+Exampleshs.py -s MainLight 0| Switch offhs.py -s MainLight 1| Switch onhs.py -s MainLight| Togglehs.py -s lifx -hue 140| RGB Lights Support  (brightness, hue, saturation, temperature)hs.py -s desk -b +10| Increment/Decrement valuesEasy MatchThe script doesn't require full names of the accessories.For example, if your light is called "MainLight", you can run:hs.py -s MainLight 0orhs.py -s main 0The script will automatically search for matching substrings and set the accessory valueGroup ActionsYou can set multiple accessories (of the same type) in a single command:hs.py -s all lights 1hs.py -s all switches 0Looking for maintainers: If you are interested in maintaining this project, feel free to reach out.SetupImportant: HomeBridgemustbe run in insecure mode for this script to work!Running HomeBridge in Insecure Modevia Command Linehomebridge -Ivia SystemdHOMEBRIDGE_OPTS=-U /var/lib/homebridge -Ivia pm2pm2 stop homebridge; pm2 delete homebridge; pm2 start homebridge -- -IInstallationInstall the HomeScript APIpip install homescriptorpip3 install homescriptOn your client computer: Downloadhs.pyand move it to a convenient locationEdit the script to include your homebridge URL, port and authorization keyChange permissionschmod +x /path/to/hs.py(on linux)UsageUsage:hs.py [option] [value]Options:-l, --list    : Lists all available HomeKit accessoriesUsage:hs.py -l [argument]Arguments:<none> : lists accessory namesaid : lists accessory names with AID valueiid : lists accessory names with IID valueid : lists accessory names with AID and IIDtype : lists accessory names with typevalue : lists accessory names current state-g, --get     :  [EasyMatch] gets current value of accessoryUsage:hs.py -g <accessory-name>-s, --set     :  [EasyMatch] toggles the accessory On or Off, or sets to the specified valueUsage:hs.py -s <accessory-name> [value]Arguments:<accessory-name> : accessory that you want to change-b : adjusts accessory brightness-hue : adjusts accessory hue-sat : adjusts accessory saturation-t : adjusts accessory color temperature[value] : value that you want to set it to. Prefix +/- to inc/decall     :  Gets or sets value of multiple HomeKit accessoriesUsage:hs.py -g all <accessory-type>hs.py -s all <accessory-type> value-d, --debug   : generates debug log file.Usage:hs.py -d <command>Eg:hs.py -d -s all lights 0-h, --help    : prints usage info-v, --version : prints HomeScript versionAPIAs of v5.1+ HomeScript is now a fully importable APIimporthomescript# Initialize with hostname, port and auth code. Debug and sys.argv are optionalhs=homescript.HomeScript(hostname,port,auth,[debug],[sys.argv])# Select an accessory or group of accessories. Any get/set/print operation requires accessories to be selected first.hs.selectAccessory('mainlight')hs.selectGroup('lights')hs.printSelectedItems()# Operates on all selected itemshs.setStates(1)hs.setValues('Brightness',250)FunctionDescriptionHomeScript( hostname: str, port: str, auth: str, debug: Boolean, argv: list )Constructor to initialize HomeBridge Connection. Debug: Set toTrueif you want to create debug and exception logfile. Default: None. argv: Only required if debug isTruegetAccessories()Returns raw list of all available accessories on the BridgeselectAccessories( searchString: str )Saves matching accessory into selectedAccessories and returns themselectGroup( searchString: str )Saves all matching accessories into selectedAccessories and returns themprintAccessories()Prints all available accessories on the BridgeprintSelectedItems()Prints selectedAccessoriesgetSelectedItems()Returns selectedAccessoriessetStates(state: Boolean)Setsstateas the on/off value of all item(s) in selectedAccessories. If no argument is specified it toggles the state of all selectedAccessoriessetValues(attribute: str, value: int)Sets numericvalueto attribute of the item(s) in selectedAccessories. Attrubute: Brightness/Hue/Saturation/Color TemperaturegetVersion()Does what it says on the can...Troubleshooting/Error Reporting/ContributingThedebugoption helps generate a logfile for troubleshooting and error detection.If you face an error, open a new issue on this repo prefixed by [Error] describing the error and attach yourbothyour debug log and your exception log, along with any other outputs you receive.If you would like to help improve the tool or request features, open an issue prefixed by [Feature Request] describing the functionality.Youmustattach your debug log or else your issue will be closed. A simple debug log can be obtained fromhs.py -d -lPRs and Commit TemplatePRs and commits that you make to this repo must include the following:Type: bug-fix or enhancementDescription: Brief description about what the commit achievesNotes: (heads ups/pointers to other developers if necessary)To Do☑️ Color control for RGB and Hue Lights⬜️ Control for PositionOpeners, GarageDoorOpener, LockMechanism⬜️ WebColors⬜️ Increment/Decrement values☑️ Querying API interface to return status of devices tostdout☑️ Automation creation, viewing and monitoring without Home HubChangelogv5.2Added support for Increment/Decrement valuesv5.1.1Fixed import bugv5.1Rewritten from the ground up to be object orientedNow features an importable APIv5.0Support for RGB lights! Now lets you control brightness, hue, saturation and color temperature of your lights!Added additional value format recognitionDevice type detectionUpdated accessory structureAdded smart toggle support for integer valuesAdded validity checks for integer valuesIgnore bridge in accessory listUpdated listing formatFiner control over listing parameters for devices with multiple interfacesUpdated exclusive value-only listing for easier interfacing in programsCleaned up accessory name recognitionBackward compatibility with v4.x syntax for all devicesv4.1Update to python 3Update to support HomeBridge v1.0+v4.0Syntax update to be POSIX compliantGet option to return item statusIntroducing Automation and scripting supportModularity and Third-party HomeScript AppsVersion loggingImproved Debugging
Note: Some parts of release withheld until the next minor releasev3.0.2Bug fix: HomeBridge was displayed as "0"v3.0.1Added debug supportv3.0Added group actions. You can now set values for all matching accessory typesv2.2Added json listing supportv2.1Added type support to identify accessory typeUpdated help docv2.0List of accessories are now automatically fetched from the homebridge, instead of having to manually set them up in the scriptv1.3Added easy name matchingv1.2Added help docAdded listingv1.1Added togglingv1.0Initial release