https://github.com/leandroalbero/pvpc-kasa-nicehash
Calculates the cost-effectiveness of mining. It queries data from TP-Link HS110, queries average cost/day of the electricity and also queries Nicehash API in order to get bitcoin mined per day on my machines.
https://github.com/leandroalbero/pvpc-kasa-nicehash
bitcoin kasa nicehash python spain tplink
Last synced: about 2 months ago
JSON representation
Calculates the cost-effectiveness of mining. It queries data from TP-Link HS110, queries average cost/day of the electricity and also queries Nicehash API in order to get bitcoin mined per day on my machines.
- Host: GitHub
- URL: https://github.com/leandroalbero/pvpc-kasa-nicehash
- Owner: leandroalbero
- License: gpl-3.0
- Created: 2022-01-11T02:39:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-01T08:18:19.000Z (over 4 years ago)
- Last Synced: 2024-01-29T20:16:50.438Z (over 2 years ago)
- Topics: bitcoin, kasa, nicehash, python, spain, tplink
- Language: Python
- Homepage:
- Size: 449 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# PVPC + Kasa smart plugs + Nicehash
This script calculates the cost-effectiveness of mining. It queries historical data from a *TP-Link HS110* smart plug, queries average cost/day of the electricity (Spanish grid only for now, PVPC) and also queries Nicehash's API in order to get bitcoin and EUR produced per day by the miners.
## Getting started
You can install the most recent release using pip while in the project root:
`pip3 install .`
Then you'll need to install its dependencies using:
`pip3 install -r requirements.txt`
Finally, run it by:
```
(venv) fengdu:pvpc-kasa-nicehash leandroalbero$ python3 pvpc-knh
[L] Current power consumption (W):
________________
Total energy cost: 237.53 EUR
Total produced BTC: 0.01009038 EUR: 390.40
Average produced per day BTC: 0.00017702 EUR: 6.85
Average energy cost per day: 4.85 EUR
________________
```
**Note**: If using Nicehash API v2 you need to create a file named 'secrets' with org_id, api_key and api_secret on each line.


## Requirements and supported devices
* TP-Link Kasa smart plug, this code has been tested with the HS110
* Nicehash API v2 org_id, api_key and api_secret
### Plugs
* HS100
* HS103
* HS105
* HS107
* HS110
* KP105
* KP115
* KP401
## TODO:
* We don't use 'ESIOS API' because it requires an API token, we use a web scraper on
[https://tarifaluzhora.es/](https://tarifaluzhora.es/?tarifa=pcb&fecha=10%2F01%2F2022) instead. This is slower,
but it is easier to set up. Will try to use ESIOS API by requesting a token on the CLI
* CLI doesn't have any parameters yet. Should have at least start_date and end_date or a default value for current month
* ~~Nicehash API~~
* Tidy the code for the plot function.
* Change start and end date to query data for the current month by default
## Resources
### Links
[Reverse engineering the TP-Link HS110](https://www.softscheck.com/en/reverse-engineering-tp-link-hs110/)
[TP-Link WiFi SmartPlug Client and Wireshark Dissector](https://github.com/softScheck/tplink-smartplug)
[Python-kasa GitHub repository](https://github.com/python-kasa/python-kasa)