{
"info": {
"author": "Sidney Kuyateh",
"author_email": "sidneyjohn23@icloud.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3"
],
"description": "# python-devoloDHC\n\n## python API for Devolo Home Control\n\nThis python API allows you to control your Devolo Home Control devices.\nThe following devices are currently supported:\n\n- Devolo Smart Metering Plug (get/set)\n- Devolo Wall Switch / Devolo Key Fob (get/set)\n- Devolo Siren (get/set)\n- Devolo Room Thermostat / Radiator Thermostat(valve) (get/set)\n- Devolo Flood Sensor (get)\n- Devolo Humidity Sensor (get)\n- Devolo Motion Sensor (get)\n- Devolo Door/Window Contact (get)\n- http devices (get/set)
\n- Scenes (get/set)\n- Groups (get/set)\n- Timers (get/set)\n- Rules (get/set)\n- Messages (get/set)
\n- Qubino \"Flush Shutter\" ZMNHCD1 (get/set)\n- Qubino \"Flush 1D Relay\" ZMNHND1 (get/set)\n- Qubino \"Flush 2 Relay\" ZMNHBD1 (get/set one or both contacts)\n- Qubino \"Flush Dimmer\" ZMNHDD1 (get/set/dim)
\n- Busch-Jaeger Duro 2000 - ZME_05461 (get/set) \n\nChanging settings will appear in Devolo web interface / Apps daily diary with your account as usual.\n\nFeel free to submit an issue or pull request to add more.\n\nNeed a php version of this API ? [php-devoloDHC](https://github.com/KiboOst/php-devoloDHC)\n\n*This isn't an official API | USE AT YOUR OWN RISK!
\nAnyway this API use exact same commands as your Devolo Home Control, which is based on ProSyst mBS SDK. When you ask bad stuff to the central, this one doesn't burn but just answer this isn't possible or allowed.
\nThis API is reverse-engineered, provided for research and development for interoperability.*\n\n---\n:exclamation: **WARNING** :exclamation:\n\nI'm sorry to say that I have switch to Jeedom and do not use anymore Devolo Home Control solution.\nThis API has work flawlessly since it's creation here, but in case of coming problems I won't be able to fix or extend it anymore.\n\nIf someone want to continue further development of this API, contact me.\n\n---\n\n[Requirements](#requirements)
\n[How-to](#how-to)
\n[Connection](#connection)
\n[Reading datas](#reading-operations)
\n[Changing datas](#changing-operations)
\n[Consumption](#consumption)
\n[Unsupported device](#unsupported-device)
\n[Version history](#version-history)
\n\n## Requirements\n- Python 2.7.11+ / Python 3+\n- The API require internet access (it will authenticate against Devolo servers).\n\n[⇑](#python-devolodhc)\n\n## How-to\n- Download module/pyDHC.py.\n- If you can, allow write permission for the API folder. It will support keeping DHC user session between consecutive executions of your script (also lot faster).\n- load pyDHC module.\n- Start it with your Devolo username/password.\n\n#### Connection\n\n```python\nimport sys\nsys.path.append(r'C:\\path\\to\\api')\nfrom pyDHC import pyDHC\n\nDHC = pyDHC('login', 'password')\nif DHC.error: print(DHC.error)\n```\n\nIf you have several Central Units, or keep the demo central on your *mydevolo* page, you can choose which to connect to:\n\n```python\n#(login | password | which central, default 0)\nDHC = pyDHC('login', 'password', 1)\nif DHC.error: print(DHC.error)\n```\n\nLet the fun begin:\n\n```python\n#for better looking print, we will use pprint:\nimport pprint\npp = pprint.PrettyPrinter(indent=4)\n\n#get some infos on your Devolo Home Control box:\ninfos = DHC.getInfos()\npp.pprint(infos)\n```\n[⇑](python-devolodhc)\n\n#### READING OPERATIONS
\n*Change devices names by yours!*\n\n```python\n#get all devices in a zone:\nzone = DHC.getDevicesByZone('living room')\npp.pprint(zone)\n\n#get rule or timer state:\nstate = DHC.isRuleActive(\"MyRule\")\npp.pprint(state)\nstate = DHC.isTimerActive(\"MyTimer\")\npp.pprint(state)\n\n#Check if a device is on (0=off, 1=on)\nstate = DHC.isDeviceOn(\"My Wall Plug\")\npp.pprint(state)\n\n#Check for devices with 2 relays (eg. Qubino Flush 2 Relay ZMNHBD1) is on (0=off, 1=on)\n#contact 1\nstate = DHC.isDeviceOn(\"myRelay\", 1)\npp.pprint(state['result'])\n#contact 2\nstate = DHC.isDeviceOn(\"myRelay\", 2)\npp.pprint(state['result'])\n#all contacts\nstate = DHC.isDeviceOn(\"myRelay\", all)\npp.pprint(state['result'])\n\n#check a device battery level:\nbatteryLevel = DHC.getDeviceBattery('My Motion Sensor')\npp.pprint(batteryLevel)\n\n#get all batteries level under 20% (ommit argument to have all batteries levels):\nBatLevels = DHC.getAllBatteries(20)\npp.pprint(BatLevels)\n\n#get daily diary, last number of events:\ndiary = DHC.getDailyDiary(10)\npp.pprint(diary)\n\n#get daily device stat:\n#0:today, 1:yesterday, 2:day before yesterday\nstats = DHC.getDailyStat('My MotionSensor', 0)\npp.pprint(stats)\n\n#get weather report:\nweather = DHC.getWeather()\npp.pprint(weather)\n\n#Get one device states (all sensors):\nstates = DHC.getDeviceStates('My Motion Sensor')\npp.pprint(states)\n\n#Get one sensor data for any device, like light from a Motion Sensor or energy from a Wall Plug:\ndata = DHC.getDeviceData('My Motion Sensor', 'light')\npp.pprint(data['result']['value'])\ndata = DHC.getDeviceData('Radiator', 'temperature')\npp.pprint(data['result']['value'])\n\n#You can first ask without data, it will return all available sensors datas for this device:\ndata = DHC.getDeviceData('My Wall Plug')\npp.pprint(data)\n\n#get url from http device:\nurl = DHC.getDeviceURL('myhttp device')\n\n#get message data:\nurl = DHC.getMessageData('MyAlert')\n```\n\n[⇑](#python-devolodhc)\n\n#### CHANGING OPERATIONS
\n*Change devices names by yours!*\n\n```python\n#TURN DEVICE ON(1) or OFF(0):\n#supported: all on/off devices and http devices\ndev = DHC.turnDeviceOnOff(\"My Room wallPlug\", 1)\npp.pprint(dev)\n\n#For devices with 2 relays as Qubino Flush 2 Relay ZMNHBD1 (device name, state, contact):\n#contact 1 on\nDHC.turnDeviceOnOff(\"myRelay\", 1, 1)\n#contact 2 on\nDHC.turnDeviceOnOff(\"myRelay\", 1, 2)\n#all contacts on\nDHC.turnDeviceOnOff(\"myRelay\", 1, \"All\")\n\n#TURN GROUP ON(1) or OFF(0):\nDHC.turnGroupOnOff(\"My Plugs Group\", 1)\n\n#RUN HTTP DEVICE:\nDHC.turnDeviceOnOff(\"My http device\", 1) #0 won't do anything of course.\n\n#START SCENE:\nDHC.startScene(\"We go out\")\n\n#SEND MESSAGE:\nDHC.sendMessage(\"Alert\")\n\n#CHANGE THERMOSTAT/VALVE VALUE:\ntargetValue = DHC.setDeviceValue('My radiator', 21)\nDHC.setDeviceValue('my thermostat', 19)\n#press thermostat button:\nDHC.pressDeviceKey('my thermostat', 1)\n\n#TURN SIREN ON: (last number is the indice of the tone in the interface list. For example, 1 is alarm and won't stop! 0 will!)\nDHC.setDeviceValue('My Devolo Siren', 5)\n\n#SET SHUTTER OPENING:\nDHC.setDeviceValue('qubShutter', 50)\n\n#SET DIMMER VALUE:\nDHC.setDeviceValue('qubDimmer', 50)\n\n#PRESS REMOTE SWITCH KEY OR KEY FOB KEY:\nDHC.pressDeviceKey('MySwitch', 3)\n\n#TURN RULE ACTIVE (1 or 0)\nDHC.turnRuleOnOff('MyRule', 1)\n\n#TURN TIMER ACTIVE (1 or 0)\nDHC.turnTimerOnOff('MyTimer', 1)\n\n#TURN OFF DAILY DIARY REPORT (true/false):\nDHC.setDeviceDiary('movekitchen', false)\n```\n\n[⇑](#python-devolodhc)\n\n#### Consumption\n\nSome people would like to have more than 3days consumption log for devices like Wall Plugs.\nHere are two functions to log consumptions, and read them between two dates of choice. So you can make a cron task to call this function everyday, it will log the yesterday total consumption of each Wall Plugs:\n\n```python\nDHC.logConsumption('log.json')\n```\nIf you don't provide a file path, or it can't write to, the api will return an error, but also provide the result (so you can write your own custom functions).
\nThen, to read the log and know consumption for a month, or along summer/winter etc:\n\n```python\nstats = DHC.getLogConsumption('log.json', '01.03.2017', '31.03.2017')\npp.pprint(stats)\n```\nOf course, it needs a valid previously saved log file by the api. You can provide no dates (full log), or only one (set first as null if needed). Just respect day.month.year (php 'd.m.Y').\n\nFor visual logs feedback with php script, have a look [here](https://github.com/KiboOst/php-devoloDHC/tree/master/ExtendedLogs)\n\n
