sense-energy


Namesense-energy JSON
Version 0.12.3 PyPI version JSON
download
home_pagehttps://github.com/scottbonline/sense
SummaryAPI for the Sense Energy Monitor
upload_time2024-02-01 21:28:15
maintainer
docs_urlNone
authorscottbonline
requires_python
license
keywords sense energy api
VCS
bugtrack_url
requirements async_timeout orjson requests websocket-client websockets aiohttp
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # sense_api
## Sense Energy Monitor API Interface
The Sense API provides access to the unofficial API for the Sense Energy Monitor.  Through the API,
one can retrieve both realtime and trend data including individual devices.

Systematic access to the Sense monitor data. Exploratory work on pulling data from Sense
to be used in other tools - HomeASsistant, Smartthings, ActiveTiles, etc. 

Python version based on the work done here in Powershell:
https://gist.github.com/mbrownnycnyc/db3209a1045746f5e287ea6b6631e19c

## Local Device Emulation
The SenseLink class emulates the energy monitoring functionality of TP-Link Kasa HS110 Smart Plugs
 and allows you to report "custom" power usage to your Sense Home Energy Monitor.  This requires 
enabling "TP-Link HS110/HS300 Smart Plug" in the Sense app.

Based off the work of https://github.com/cbpowell/SenseLink

### Contributors

Feel free to fork and PR! 

https://github.com/kbickar

### Todo

- Add POST/PUT where/if applicable
- CLI
- Improved error handling


### Install

```
pip install sense_energy
```

### Web API Example Usage:
```python
    from sense_energy import Senseable
    sense = Senseable()
    sense.authenticate(username, password)
    sense.update_realtime()
    sense.update_trend_data()
    print ("Active:", sense.active_power, "W")
    print ("Active Solar:", sense.active_solar_power, "W")
    print ("Daily:", sense.daily_usage, "KWh")
    print ("Daily Solar:", sense.daily_production, "KWh")
    print ("Active Devices:",", ".join(sense.active_devices))
```

There are plenty of methods for you to call so modify however you see fit

If using the API to log data, you should only create one instance of Senseable and 
then reuse that to get the updated stats.  Creating the instance authenticates 
with the Sense API which should only be once every 15-20 minutes at most.  
Calling the `update_trend_data()` function will update all the trend stats 
and `get_realtime()` will retrieve the latest real time stats.

The get_realtime() is by default rate limited to one call per 30 seconds. This can
be modified by setting the Senseable object attribute `rate_limit` to a different value.

### Local emulation Example Usage:
```python
	async def test():
		import time
		def test_devices():
			devices = [PlugInstance("lamp1", start_time=time()-20, alias="Lamp", power=10), 
					   PlugInstance("fan1", start_time=time()-300, alias="Fan", power=140)]
			for d in devices:
				yield d
		sl = SenseLink(test_devices)
		await sl.start()
		try:
			await asyncio.sleep(180)  # Serve for 3 minutes
		finally:
			await sl.stop()

	if __name__ == "__main__":
		asyncio.run(test())
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/scottbonline/sense",
    "name": "sense-energy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "sense,energy,api",
    "author": "scottbonline",
    "author_email": "scottbonline@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/43/87/294acd493994d618ae35036f6444a12ff341d4b4ea2a158df0b6dfbd906d/sense_energy-0.12.3.tar.gz",
    "platform": null,
    "description": "# sense_api\n## Sense Energy Monitor API Interface\nThe Sense API provides access to the unofficial API for the Sense Energy Monitor.  Through the API,\none can retrieve both realtime and trend data including individual devices.\n\nSystematic access to the Sense monitor data. Exploratory work on pulling data from Sense\nto be used in other tools - HomeASsistant, Smartthings, ActiveTiles, etc. \n\nPython version based on the work done here in Powershell:\nhttps://gist.github.com/mbrownnycnyc/db3209a1045746f5e287ea6b6631e19c\n\n## Local Device Emulation\nThe SenseLink class emulates the energy monitoring functionality of TP-Link Kasa HS110 Smart Plugs\n and allows you to report \"custom\" power usage to your Sense Home Energy Monitor.  This requires \nenabling \"TP-Link HS110/HS300 Smart Plug\" in the Sense app.\n\nBased off the work of https://github.com/cbpowell/SenseLink\n\n### Contributors\n\nFeel free to fork and PR! \n\nhttps://github.com/kbickar\n\n### Todo\n\n- Add POST/PUT where/if applicable\n- CLI\n- Improved error handling\n\n\n### Install\n\n```\npip install sense_energy\n```\n\n### Web API Example Usage:\n```python\n    from sense_energy import Senseable\n    sense = Senseable()\n    sense.authenticate(username, password)\n    sense.update_realtime()\n    sense.update_trend_data()\n    print (\"Active:\", sense.active_power, \"W\")\n    print (\"Active Solar:\", sense.active_solar_power, \"W\")\n    print (\"Daily:\", sense.daily_usage, \"KWh\")\n    print (\"Daily Solar:\", sense.daily_production, \"KWh\")\n    print (\"Active Devices:\",\", \".join(sense.active_devices))\n```\n\nThere are plenty of methods for you to call so modify however you see fit\n\nIf using the API to log data, you should only create one instance of Senseable and \nthen reuse that to get the updated stats.  Creating the instance authenticates \nwith the Sense API which should only be once every 15-20 minutes at most.  \nCalling the `update_trend_data()` function will update all the trend stats \nand `get_realtime()` will retrieve the latest real time stats.\n\nThe get_realtime() is by default rate limited to one call per 30 seconds. This can\nbe modified by setting the Senseable object attribute `rate_limit` to a different value.\n\n### Local emulation Example Usage:\n```python\n\tasync def test():\n\t\timport time\n\t\tdef test_devices():\n\t\t\tdevices = [PlugInstance(\"lamp1\", start_time=time()-20, alias=\"Lamp\", power=10), \n\t\t\t\t\t   PlugInstance(\"fan1\", start_time=time()-300, alias=\"Fan\", power=140)]\n\t\t\tfor d in devices:\n\t\t\t\tyield d\n\t\tsl = SenseLink(test_devices)\n\t\tawait sl.start()\n\t\ttry:\n\t\t\tawait asyncio.sleep(180)  # Serve for 3 minutes\n\t\tfinally:\n\t\t\tawait sl.stop()\n\n\tif __name__ == \"__main__\":\n\t\tasyncio.run(test())\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "API for the Sense Energy Monitor",
    "version": "0.12.3",
    "project_urls": {
        "Download": "https://github.com/scottbonline/sense/archive/0.12.3.tar.gz",
        "Homepage": "https://github.com/scottbonline/sense"
    },
    "split_keywords": [
        "sense",
        "energy",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c90e8d6d77a41fc21ff7e20022a57e3169817b9bf0b6c036e480074ecf403810",
                "md5": "90b941b101724edf779355aad55c5bec",
                "sha256": "b070297b44b8973192127325e21596bf18f00a31b0e85bddde59e85570d8fe14"
            },
            "downloads": -1,
            "filename": "sense_energy-0.12.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "90b941b101724edf779355aad55c5bec",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14244,
            "upload_time": "2024-02-01T21:28:14",
            "upload_time_iso_8601": "2024-02-01T21:28:14.324464Z",
            "url": "https://files.pythonhosted.org/packages/c9/0e/8d6d77a41fc21ff7e20022a57e3169817b9bf0b6c036e480074ecf403810/sense_energy-0.12.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4387294acd493994d618ae35036f6444a12ff341d4b4ea2a158df0b6dfbd906d",
                "md5": "c827c273dc11affe4ee4174bec0dbcd6",
                "sha256": "46d8fad4b68a8dc3854d715d3e444e8754383a226eb353c283f71603daae8903"
            },
            "downloads": -1,
            "filename": "sense_energy-0.12.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c827c273dc11affe4ee4174bec0dbcd6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13130,
            "upload_time": "2024-02-01T21:28:15",
            "upload_time_iso_8601": "2024-02-01T21:28:15.874545Z",
            "url": "https://files.pythonhosted.org/packages/43/87/294acd493994d618ae35036f6444a12ff341d4b4ea2a158df0b6dfbd906d/sense_energy-0.12.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-01 21:28:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "scottbonline",
    "github_project": "sense",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "async_timeout",
            "specs": []
        },
        {
            "name": "orjson",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "websocket-client",
            "specs": []
        },
        {
            "name": "websockets",
            "specs": []
        },
        {
            "name": "aiohttp",
            "specs": []
        }
    ],
    "lcname": "sense-energy"
}
        
Elapsed time: 0.17507s