This gem provides a Ruby interface to the Mixergy Hot Water Tank REST API, making it easy to interact with tanks in a Rubyish way. There is also a CLI tool included to help with fetching an authentication token and interacting with the API.
Add this line to your application's Gemfile:
gem 'mixergy', git: 'https://github.com/njh/ruby-mixergy.git'Or install it directly:
git clone https://github.com/njh/ruby-mixergy.git
cd ruby-mixergy
bundle installIncluded in the gem is a command line tool, to perform actions with the Mixergy API:
$ mixergy help
Commands:
mixergy boost # Charge tank to 100%
mixergy charge PERCENT # Charge tank to target percentage
mixergy help [COMMAND] # Describe available commands or one specific command
mixergy login # Login to Mixergy API and store token
mixergy status # Display the current status of a tank
mixergy tanks # List all your tanks
mixergy version # Prints the Mixergy gem versionThe mixergy status command displays some stats and a visualisation of the tank:
To disable colour, set the NO_COLOR environment variable.
To avoid logging-in before each API request, there is support for saving the authentication token to a configuration file, stored as YAML in ~/.mixergy.
This file can be generated using the mixergy login CLI command.
The default tank ID is also stored, to avoid having to lookup a list of tanks each time too.
Example ~/.mixergy file:
---
token: user/ooShoh7naaR1lai0Ahtie5miechaig7ei/12ab/Tie6sha0vah7onohchifeich2aipheifaiqu9beiphoim4queitheinoMoo2a
default_tank_id: fcee127d-dad9-4ab4-a734-64586d0c0d68After checking out the repo, run bin/setup to install dependencies. You can also 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, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/njh/ruby-mixergy.
The gem is available as open source under the terms of the MIT License.
