xively-rb-connector
xively-rb-connector is a ruby gem that provides an interface to Xively. It extends Sam Mulube's
excellent xively-rb gem. This gem adds convenience functions such as find_by_id
lookup functions, datastream compression (only saves datapoints when value changes), a datapoint recording buffer, etc.
Xively is a public cloud specifically built for the "Internet of Things". With their
platform, developers can connect physical devices, that produce one or more datastreams, to a managed data store. The
device's details and datastreams are accessible via key-based access to any service or application that has access to the
web. Xively provides a fantastic development portal and prototyping accounts are free.
Requirements
Contact, feedback and bugs
Please file bugs / issues and feature requests on the issue tracker
Install
gem install xively-rb-connector
Examples
require 'xively-rb-connector'
my_api_key = 'XIVELY-ACCOUNT-OR-DEVICE-API-KEY-HERE'
feed_id = '123456789'
d = XivelyConnector.find_device_by_id(feed_id, my_api_key)
d.id
d.feed
d.auto_feed_url
d.title
d.device_serial
d.description
d.tags
d.creator
d.email
d.website
d.icon
d.created
d.updated
d.private
d.is_private?
d.status
d.is_frozen?
d.has_location?
d.location_name
d.location_domain
d.location_lon
d.location_lat
d.location_ele
d.location_exposure
d.location_disposition
d.location_waypoints
l = d.location #<OpenStruct name="The location name on xively.com", latitude=35.12343454, longitude=-78.12343456, elevation="354 feet", exposure=nil, disposition=nil, waypoints=nil, domain="physical">
l.name
l.domain
l.longitude
l.latitude
l.elevation
l.exposure
l.disposition
l.waypoints
d.datastream_ids
d.datastream_values
d.has_channel?('Voltage')
d['Voltage']
d['Voltage'].current_value
ds = d['Volts']
ds.id
ds.unit_label
ds.unit_symbol
ds.current_value
ds.tags
ds.min_value
ds.max_value
ds.only_save_changes = true
ds.datapoint_buffer_size = 60
ds.only_save_changes
ds.only_saves_changes?
ds.datapoint_buffer_size
ds.datapoints.size
ds << Xively::Datapoint.new(:value => "10", :at => Time.now,())
ds << {:at=>':at => Time.now(), :value => "10"}
ds << "10"
ds << 10
ds << 10.0
ds << 11
# If ds.only_save_changes is true, the commands above only result in two datapoints being queued (because the only unique values recorded were 10 and 11)
ds.datapoints.size # 2
# Save datapoints to xively.com
ds.save_datapoints
ds.datapoints.size # 0
Resources
Special Thanks
- Xively - for an awesome data platform
- Sam Mulube - for xively-rb
- Ian Duggan - for introducing me to ruby