Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
robzr committed Sep 22, 2016
1 parent 0b26b67 commit bfdc85f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 47 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Ecobee BitBar plugin for monitoring and controlling an Ecobee thermostat from yo
alt="Example output from one line bot" width=344 height=330>

Features:
- Runs in macOS menu bar, works in regular mode and dark mode
- Runs in macOS menu bar, optimized for regular mode and dark mode
- Works with one or more Ecobee thermostats including the excellent ecobee3
- Allows control of temperature setpoints, fan mode, thermostat mode, readout of sensors
- Sync's Ecobee API token and settings via iCloud Drive if available
Expand All @@ -27,6 +27,6 @@ Known issues:
- When multiple Macs are running this, and one goes to sleep and wakes up, there can be refresh token collisions resulting in re-registration being required (being addressed)

TODO:
- rewriting file load/save logic for better cloud awareness, to avoid token collisions
- Port to BitBar v2 for faster refresh, static menu bar, fewer processes
- Update registration process for instant refresh
- Add more control/display features
- Add more control/display features or customization/preferences
Binary file modified ecoBar.dmg
Binary file not shown.
13 changes: 9 additions & 4 deletions eco_bar/eco_bar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@

module EcoBar
APP_KEY = 'MKDvfwwyGib0ZFhUdgKP4wDIRzYooM1o'
COLOR = {
COLOR = Hash.new({ true => '#ffffff', false => '#000000' }).merge({
cold: { true => '#1010ff', false => '#0000c0' },
dark: { true => '#ffffff', false => '#000000' },
hot: { true => '#ff1010', false => '#c00000' },
light: { true => '#404040', false => '#707070' }
}

}).freeze

# COLOR = {
# cold: { true => '#1010ff', false => '#0000c0' },
# dark: { true => '#ffffff', false => '#000000' },
# hot: { true => '#ff1010', false => '#c00000' },
# light: { true => '#404040', false => '#707070' }
# }

ECOBEE_URL = 'https://www.ecobee.com/consumerportal/index.html'

Expand Down
67 changes: 29 additions & 38 deletions eco_bar/eco_bar/bar_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(
end

def about
render("ecoBar v#{VERSION}", color: :dark, href: GITHUB_URL)
render("ecoBar v#{VERSION}", href: GITHUB_URL)
render('Update Available',
color: :hot,
param1: 'update',
Expand Down Expand Up @@ -71,14 +71,12 @@ def dark_mode
end

def fan_mode
render("Fan Mode: #{Ecobee::FanMode(thermostat.desired_fan_mode)}",
color: :dark)
render "Fan Mode: #{Ecobee::FanMode(thermostat.desired_fan_mode)}"
Ecobee::FAN_MODES.each do |mode|
if mode == thermostat.desired_fan_mode
render("--#{check true}#{Ecobee::FanMode(mode)}", color: :dark)
render "--#{check true}#{Ecobee::FanMode(mode)}"
else
render("--#{check false}#{Ecobee::FanMode(mode)}",
color: :dark,
param1: "set_fan_mode=#{mode}",
run_self: true)
end
Expand All @@ -97,53 +95,49 @@ def mode_menu
render "Mode: #{Ecobee::Mode(thermostat.mode)}"
Ecobee::HVAC_MODES.each do |mode|
if mode == thermostat.mode
render("--#{check true}#{Ecobee::Mode(mode)}", color: :dark)
render "--#{check true}#{Ecobee::Mode(mode)}"
else
render("--#{check false}#{Ecobee::Mode(mode)}",
color: :dark,
param1: "set_mode=#{mode}",
run_self: true)
end
end
end

def name_menu
render("#{thermostat.name} (#{thermostat.model})", color: :dark)
render "#{thermostat.name} (#{thermostat.model})"
if max_index > 0
@thermostats.each_index do |index|
thermostat = @thermostats[index]

if @index == index
render("--#{check true}#{thermostat.name} (#{thermostat.model})",
color: :dark)
render "--#{check true}#{thermostat.name} (#{thermostat.model})"
else
render("--#{check false}#{thermostat.name} (#{thermostat.model})",
color: :dark,
param1: "set_index=#{index}",
run_self: true)
end
end
end
end

def render(msg, *args)
def render(msg, arg = {})
msg += '|'
if (arg = args.shift).is_a? Hash
msg += " #{arg[:attrib]}" if arg.key? :attrib
msg += " bash=\"#{arg[:bash]}\"" if arg.key? :bash
msg += " #{color(arg[:color])}" if arg.key? :color
if arg.key? :font
msg += " font=#{arg[:font]}"
elsif @font
msg += " font=#{@font}"
end
msg += " href=\"#{arg[:href]}\"" if arg.key? :href
msg += " #{@base_command}" if arg.key? :run_self
msg += " trim=#{arg[:trim] ? 'true' : 'false'}"
arg.keys.sort.select do |key|
if key.to_s =~ /^param(\d+)/
msg += " param#{$1}=#{arg[key]}"
end
arg.merge!({:color => :dark}) unless arg[:color]
msg += " #{arg[:attrib]}" if arg.key? :attrib
msg += " bash=\"#{arg[:bash]}\"" if arg.key? :bash
msg += " #{color(arg[:color])}" if arg.key? :color
if arg.key? :font
msg += " font=#{arg[:font]}"
elsif @font
msg += " font=#{@font}"
end
msg += " href=\"#{arg[:href]}\"" if arg.key? :href
msg += " #{@base_command}" if arg.key? :run_self
msg += " trim=#{arg[:trim] ? 'true' : 'false'}"
arg.keys.sort.select do |key|
if key.to_s =~ /^param(\d+)/
msg += " param#{$1}=#{arg[key]}"
end
end
puts msg
Expand All @@ -158,7 +152,7 @@ def sensors
msg += %Q{ #{thermostat.unitize(val[0][:value])}#{DEG}} if val.length > 0
val = sensor[:capability].select { |cap| cap[:type] == 'humidity' }
msg += %Q{ #{val[0][:value].to_i}%} if val.length > 0
render(msg, color: :dark)
render msg
end
end

Expand Down Expand Up @@ -206,7 +200,7 @@ def separator
def status
status = thermostat[:equipmentStatus]
status = 'none' if status == ''
render("Status: #{status}", color: :dark)
render "Status: #{status}"
end

def thermostat
Expand All @@ -219,14 +213,11 @@ def weather
render("Weather: #{unit_temp}#{DEG} #{forecast[:relativeHumidity]}%",
href: "https://www.wunderground.com/cgi-bin/findweather/" +
"getForecast?query=#{thermostat[:location][:mapCoordinates]}")
render("--#{forecast[:condition]}", color: :dark)
render("--Low temp of #{thermostat.unitize(forecast[:tempLow])}#{DEG}",
color: :dark)
render("--High temp of #{thermostat.unitize(forecast[:tempHigh])}#{DEG}",
color: :dark)
render("--Wind blowing #{forecast[:windDirection]} at " +
"#{forecast[:windSpeed] / 1000} mph",
color: :dark)
render "--#{forecast[:condition]}"
render "--Low temp of #{thermostat.unitize(forecast[:tempLow])}#{DEG}"
render "--High temp of #{thermostat.unitize(forecast[:tempHigh])}#{DEG}"
render "--Wind blowing #{forecast[:windDirection]} at " +
"#{forecast[:windSpeed] / 1000} mph"
end

def website
Expand Down
4 changes: 2 additions & 2 deletions eco_bar/eco_bar/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module EcoBar
VERSION = '0.1.10'
DMG_VERSION = '0.1.10'
VERSION = '0.1.11'
DMG_VERSION = '0.1.11'
end

0 comments on commit bfdc85f

Please sign in to comment.