Code Monkey home page Code Monkey logo

powerspycli's Introduction

Joular Project PowerSpyCli

PowerSpyCli is a tool to connect and collect power metrics from a PowerSpy 2 powermeter.

PowerSpyCli is tested on GNU/Linux and works with Python 3.

Installation

  • To run PowerSpyCli, you need to install bluez and python-bluez.

On Debian/Ubuntu: apt install bluez python-bluez. On Arch-based distros: install bluez and python-pybluez.

On recent distributions, pybluez is not available in the repositories anymore (the development of pybluez stopped). You can still download and install the latest version with pip directly from their git repository: pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez

  • Then clone the repo (or just download the powerspycli.py file), and run it.

Installing on SailfishOS

On the Linux-based mobile OS, SailfishOS, you can run PowerSpyCli by installing the following packages:

devel-su zypper install bluez5-libs-devel make gcc glib2-devel
python3 -m venv venv
source venv/bin/activate
pip install wheel
pip install pybluez

Running PowerSpyCli

To run PowerSpyCli and start collecting power metrics, just run the python file: python powerspycli.py or directly ./powerspycli.py.

The tool requires the bluetooth device address of the PowerSpy in order to run: ./powerspycli.py 00:11:22:33:44:55.

Arguments

PowerSpyCli, by default, will display the power consumption of the PowerSpy every second. To show all the collected metrics (i.e., voltage, ampere, etc.), run it with the -a argument.

The -v argument will display all the logs and connection info (verbose mode).

To save the power data along with the timestamp to a CSV file, use the -f argument: ./powerspycli.py 00:11:22:33:44:55 -f file.csv.

License

PowerSpyCli is forked from: https://github.com/patrickmarlier/powerspy.py/ with support for Python 3 and additional updates.

It is licensed under the GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later).

Copyright (c) 2021, Adel Noureddine, Université de Pau et des Pays de l'Adour. All rights reserved. This program and the accompanying materials are made available under the terms of the GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later) which accompanies this distribution, and is available at: https://www.gnu.org/licenses/lgpl-3.0.en.html

powerspycli's People

Contributors

adelnoureddine avatar

Stargazers

Yelle Lieder avatar  avatar

Watchers

James Cloos avatar  avatar

powerspycli's Issues

`pybluez` install instructions

I struggled to run the powerspycli script on my install (Ubuntu 23.10, Python 3.11.6) due to the pybluez dependency install instructions being somehow deprecated, so here's what I've done to make it work.


Installing pybluez through apt is not possible (package not found), I tried to install it with pip, and got the following error:

(powerspycli) remy@chimay:~/Travail/powerspycli$ pip install pybluez
Collecting pybluez
  Downloading PyBluez-0.23.tar.gz (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.6/97.6 kB 2.4 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in PyBluez setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

According to themagpimag/magpi-issue61#1 (comment), libbluetooth-dev install is required in order to install pybluez:

sudo apt install libbluetooth-dev

pybluez install would still fail at this point:

(powerspycli) remy@chimay:~/Travail/powerspycli$ pip install pybluez
Collecting pybluez
  Using cached PyBluez-0.23.tar.gz (97 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in PyBluez setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

I had to install pybluez from its repository directly:

pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.