Giter VIP home page Giter VIP logo

power_snoop's Introduction

To support my open-source work, consider adding me on Patreon.

PowerSnoop

FOSSA Status

Scan, monitor, and calculate power consumption for common devices on and off a network. Support for generic devices will also be included. Special emphasis on consumer home automation equipment (since it often reduces power consumption over time and tracking this will be useful).

Features:

  • define and calculate power consumption for a variety of common and specialty electronic devices
  • scan network for known device types
  • monitor and report power consumption over time
  • export reports to data formats and PDFs

Installation

Add this line to your application's Gemfile:

gem 'power_snoop'

And then execute:

$ bundle

Or install it yourself as:

$ gem install power_snoop

Usage

require 'power_snoop'

Determine defined consumption for a WeMo Smart LED Bulb when it is turned off

This is from the manufacturer or one-time measured data. Not real-time.

PowerSnoop::Devices::Wemo::SmartLEDBulb.consumption_when_off
#<Unitwise::Measurement value=0.5 unit=watt>

Determine defined maximum consumption for the WeMo Smart LED Bulb

This is from the manufacturer or one-time measured data. Not real-time.

PowerSnoop::Devices::Wemo::SmartLEDBulb.consumption_when_max
#<Unitwise::Measurement value=10 unit=watt>

Determine defined consumption of the WeMo Smart LED Bulb when at dim level 200 (78%)

This is from the manufacturer or one-time measured data. Not real-time.

PowerSnoop::Devices::Wemo::SmartLEDBulb.consumption_when_at_dim(200)
#<Unitwise::Measurement value=7.91 unit=watt>

Scan for WeMo devices on the network

wemo = PowerSnoop::Network::Wemo.new
link = wemo.scan_for_devices
link.scan_for_devices
Binding to 10.0.0.61:54321
Discovering devices
Sent multicast datagram to 239.255.255.250:1900
Finished waiting 5 seconds
Found device 'WeMo Link' at 10.0.0.29:49154

Generic scan for devices on the network using UPnP

upnp = PowerSnoop::Network::UPnP.new
upnp.ssdp_discover
 => [#<PowerSnoop::Network::UPnPRootDevice:0x007fac629b7a38 @protocol="HTTP/1.1 200 OK", @headers={"Cache-Control"=>"max-age=3600", "ST"=>"upnp:rootdevice", "USN"=>"uuid:824ff22b-8c7d-41c5-a131-44f534e125551::upnp:rootdevice", "EXT:"=>nil, "Server"=>"Arris/1.0 UPnP/1.0 miniupnpd/1.0", "Location"=>"http://10.0.0.1:5000/rootDesc.xml"}>, #<PowerSnoop::Network::UPnPRootDevice:0x007fac629b65e8 @protocol="HTTP/1.1 200 OK", @headers={"CACHE-CONTROL"=>"max-age=86400", "DATE"=>"Sat, 13 Jun 2015 08:01:06 GMT", "EXT:"=>nil, "LOCATION"=>"http://10.0.0.29:49154/setup.xml", "OPT"=>"\"http://schemas.upnp.org/upnp/1/0/\"; ns=01", "01-NLS"=>"97303dd0-1dd1-11b2-bf8b-ebcd1f3911f0", "SERVER"=>"Unspecified, UPnP/1.0, Unspecified", "X-User-Agent"=>"redsonic", "ST"=>"upnp:rootdevice", "USN"=>"uuid:Bridge-1_0-231447B010024F::upnp:rootdevice"}>, #<PowerSnoop::Network::UPnPRootDevice:0x007fac629b4d38 @protocol="HTTP/1.1 200 OK", @headers={"CACHE-CONTROL"=>"max-age = 1800", "EXT:"=>nil, "LOCATION"=>"http://10.0.0.23:1400/xml/device_description.xml", "SERVER"=>"Linux UPnP/1.0 Sonos/29.4-90021 (ZPS3)", "ST"=>"upnp:rootdevice", "USN"=>"uuid:RINCON_B8E93739D48A01400::upnp:rootdevice", "X-RINCON-HOUSEHOLD"=>"Sonos_hnBTlpIiWoW0bdq8DvQbngazWc", "X-RINCON-BOOTSEQ"=>"5030", "X-RINCON-PROXY"=>"RINCON_000E58B80FF801400"}>, #<PowerSnoop::Network::UPnPRootDevice:0x007fac6299abb8 @protocol="HTTP/1.1 200 OK", @headers={"CACHE-CONTROL"=>"max-age = 1800", "EXT:"=>nil, "LOCATION"=>"http://10.0.0.21:1400/xml/device_description.xml", "SERVER"=>"Linux UPnP/1.0 Sonos/29.4-90021 (ZPS1)", "ST"=>"upnp:rootdevice", "USN"=>"uuid:RINCON_B8E93751CE3801400::upnp:rootdevice", "X-RINCON-HOUSEHOLD"=>"Sonos_hnBTlpIiWoW0bdq8DvQbngazWc", "X-RINCON-BOOTSEQ"=>"57"}>, #<PowerSnoop::Network::UPnPRootDevice:0x007fac6298bcd0 @protocol="HTTP/1.1 200 OK", @headers={"CACHE-CONTROL"=>"max-age = 1800", "EXT:"=>nil, "LOCATION"=>"http://10.0.0.22:1400/xml/device_description.xml", "SERVER"=>"Linux UPnP/1.0 Sonos/29.4-90021 (ZPS1)", "ST"=>"upnp:rootdevice", "USN"=>"uuid:RINCON_B8E9375243EA01400::upnp:rootdevice", "X-RINCON-HOUSEHOLD"=>"Sonos_hnBTlpIiWoW0bdq8DvQbngazWc", "X-RINCON-BOOTSEQ"=>"43"}>, #<PowerSnoop::Network::UPnPRootDevice:0x007fac629886c0 @protocol="HTTP/1.1 200 OK", @headers={"CACHE-CONTROL"=>"max-age = 1800", "EXT:"=>nil, "LOCATION"=>"http://10.0.0.19:1400/xml/device_description.xml", "SERVER"=>"Linux UPnP/1.0 Sonos/29.4-90021 (ZPS3)", "ST"=>"upnp:rootdevice", "USN"=>"uuid:RINCON_B8E93739D49E01400::upnp:rootdevice", "X-RINCON-HOUSEHOLD"=>"Sonos_hnBTlpIiWoW0bdq8DvQbngazWc", "X-RINCON-BOOTSEQ"=>"5156", "X-RINCON-PROXY"=>"RINCON_000E58B80FF801400"}>, #<PowerSnoop::Network::UPnPRootDevice:0x007fac629782e8 @protocol="HTTP/1.1 200 OK", @headers={"CACHE-CONTROL"=>"max-age = 1800", "EXT:"=>nil, "LOCATION"=>"http://10.0.0.13:1400/xml/device_description.xml", "SERVER"=>"Linux UPnP/1.0 Sonos/29.4-90021 (ZPS9)", "ST"=>"upnp:rootdevice", "USN"=>"uuid:RINCON_000E58B80FF801400::upnp:rootdevice", "X-RINCON-HOUSEHOLD"=>"Sonos_hnBTlpIiWoW0bdq8DvQbngazWc", "X-RINCON-BOOTSEQ"=>"44"}>, #<PowerSnoop::Network::UPnPRootDevice:0x007fac62969f18 @protocol="HTTP/1.1 200 OK", @headers={"CACHE-CONTROL"=>"max-age = 1800", "EXT:"=>nil, "LOCATION"=>"http://10.0.0.20:1400/xml/device_description.xml", "SERVER"=>"Linux UPnP/1.0 Sonos/29.4-90021 (ZPS1)", "ST"=>"upnp:rootdevice", "USN"=>"uuid:RINCON_B8E93751CDA601400::upnp:rootdevice", "X-RINCON-HOUSEHOLD"=>"Sonos_hnBTlpIiWoW0bdq8DvQbngazWc", "X-RINCON-BOOTSEQ"=>"73"}>, #<PowerSnoop::Network::UPnPRootDevice:0x007fac63007690 @protocol="HTTP/1.1 200 OK", @headers={"ST"=>"upnp:rootdevice", "USN"=>"uuid:aca7befe-fba0-4564-842b-05abda43ac97::upnp:rootdevice", "Location"=>"http://10.0.0.16:2869/upnphost/udhisapi.dll?content=uuid:aca7befe-fba0-4564-842b-05abda43ac97", "OPT:\"http://schemas.upnp.org/upnp/1/0/\"; ns=01"=>nil, "01-NLS"=>"5cdfd8fb775616fb24a010021fea042d", "Cache-Control"=>"max-age=1800", "Server"=>"Microsoft-Windows/6.2 UPnP/1.0 UPnP-Device-Host/1.0", "Ext"=>nil}>, #<PowerSnoop::Network::UPnPRootDevice:0x007fac63006f60 @protocol="HTTP/1.1 200 OK", @headers={"ST"=>"upnp:rootdevice", "USN"=>"uuid:ca3b1b50-195b-4e1b-95f6-6b3ab4e85b32::upnp:rootdevice", "Location"=>"http://10.0.0.16:2869/upnphost/udhisapi.dll?content=uuid:ca3b1b50-195b-4e1b-95f6-6b3ab4e85b32", "OPT:\"http://schemas.upnp.org/upnp/1/0/\"; ns=01"=>nil, "01-NLS"=>"5cdfd8fb775616fb24a010021fea042d", "Cache-Control"=>"max-age=1800", "Server"=>"Microsoft-Windows/6.2 UPnP/1.0 UPnP-Device-Host/1.0", "Ext"=>nil}>]

Known Devices

Home Automation

manufacturer device power details real-time monitoring status
Belkin WeMo Link no yes in progress
Belkin WeMo Smart LED Bulb yes yes in progress
Belkin WeMo Switch some yes planned
Philips Vue yes yes planned

Televisions

manufacturer device power details real-time monitoring status
Samsung 55" SmartTV yes yes planned
Sony 50" Grand WEGA yes no planned

Routers & Modems

manufacturer device power details real-time monitoring status
Arris Touchstone TG862G/CT Cable Modem yes yes planned

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/power_snoop/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

FOSSA Status

power_snoop's People

Contributors

dependabot-support avatar fossabot avatar kevinelliott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

fossabot

power_snoop's Issues

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "nori":
  In Gemfile:
    power_snoop was resolved to 0.0.1, which depends on
      nori (<= 2.6.0, >= 2.6.0)

Could not find gem 'nori (<= 2.6.0, >= 2.6.0)', which is required by gem 'power_snoop', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "nori":
  In Gemfile:
    power_snoop was resolved to 0.0.1, which depends on
      nori (~> 2.6.0)

Could not find gem 'nori (~> 2.6.0)', which is required by gem 'power_snoop', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "nori":
  In Gemfile:
    power_snoop was resolved to 0.0.1, which depends on
      nori (~> 2.6.0)

Could not find gem 'nori (~> 2.6.0)', which is required by gem 'power_snoop', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "nori":
  In Gemfile:
    power_snoop was resolved to 0.0.1, which depends on
      nori (<= 2.6.0, >= 2.6.0)

Could not find gem 'nori (<= 2.6.0, >= 2.6.0)', which is required by gem 'power_snoop', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

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.