Skip to content

Commit bda4ee6

Browse files
committed
Fixed several bugs.
1 parent a6c663e commit bda4ee6

File tree

6 files changed

+246
-186
lines changed

6 files changed

+246
-186
lines changed

src/HomeAutio.Mqtt.Ecobee/EcobeeMqttService.cs

Lines changed: 210 additions & 158 deletions
Large diffs are not rendered by default.

src/HomeAutio.Mqtt.Ecobee/HomeAutio.Mqtt.Ecobee.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
<HintPath>..\packages\HomeAutio.Mqtt.Core.1.0.0.18\lib\net452\HomeAutio.Mqtt.Core.dll</HintPath>
3838
<Private>True</Private>
3939
</Reference>
40-
<Reference Include="I8Beef.Ecobee, Version=1.0.0.11, Culture=neutral, processorArchitecture=MSIL">
41-
<HintPath>..\packages\I8Beef.Ecobee.1.0.0.11\lib\net452\I8Beef.Ecobee.dll</HintPath>
40+
<Reference Include="I8Beef.Ecobee, Version=1.0.0.13, Culture=neutral, processorArchitecture=MSIL">
41+
<HintPath>..\packages\I8Beef.Ecobee.1.0.0.13\lib\net452\I8Beef.Ecobee.dll</HintPath>
4242
</Reference>
4343
<Reference Include="M2Mqtt.Net, Version=4.3.0.0, Culture=neutral, processorArchitecture=MSIL">
4444
<HintPath>..\packages\M2Mqtt.4.3.0.0\lib\net45\M2Mqtt.Net.dll</HintPath>

src/HomeAutio.Mqtt.Ecobee/Program.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ static void Main(string[] args)
2323
var ecobeeName = ConfigurationManager.AppSettings["ecobeeName"];
2424
var ecobeeAppKey = ConfigurationManager.AppSettings["ecobeeAppKey"];
2525

26+
var appPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
27+
2628
// Default to once every 3 minutes as per API guide
27-
int ecobeeRereshInterval = 240000;
29+
int ecobeeRereshInterval = 180000;
2830
if (int.TryParse(ConfigurationManager.AppSettings["ecobeeRefreshInterval"], out ecobeeRereshInterval))
29-
ecobeeRereshInterval = Math.Max(240000, ecobeeRereshInterval * 1000);
31+
ecobeeRereshInterval = Math.Max(180000, ecobeeRereshInterval * 1000);
3032

3133
if (args.Length > 0 && args[0] == "auth")
3234
{
@@ -45,7 +47,7 @@ static void Main(string[] args)
4547
}
4648
else
4749
{
48-
if (!File.Exists(@"token.txt"))
50+
if (!File.Exists(Path.Combine(appPath, "token.txt")))
4951
{
5052
log.Error("Token file token.txt not found");
5153
Console.WriteLine("Token file token.txt not found. Please run 'HomeAutio.Mqtt.Ecobee.exe auth' to retrieve and cache new auth token.");
@@ -55,7 +57,7 @@ static void Main(string[] args)
5557
}
5658

5759
log.Info("Reading cached tokens");
58-
var tokenText = File.ReadAllLines(@"token.txt");
60+
var tokenText = File.ReadAllLines(Path.Combine(appPath, "token.txt"));
5961

6062
var tokenExpiration = DateTime.Parse(tokenText[0]);
6163
var accessToken = tokenText[1];
@@ -97,13 +99,19 @@ static void Main(string[] args)
9799
/// <param name="token">The token to cache.</param>
98100
public static void WriteTokenFile(AuthToken token)
99101
{
102+
var log = LogManager.GetCurrentClassLogger();
103+
104+
log.Info("Writing new token to cache");
105+
100106
var text = new StringBuilder();
101107
text.AppendLine(DateTime.Now.AddSeconds(token.ExpiresIn).ToString());
102108
text.AppendLine(token.AccessToken);
103109
text.AppendLine(token.RefreshToken);
104110

111+
var appPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
112+
105113
// Cache the returned tokens
106-
File.WriteAllText(@"token.txt", text.ToString());
114+
File.WriteAllText(Path.Combine(appPath, "token.txt"), text.ToString());
107115
}
108116
}
109117
}

src/HomeAutio.Mqtt.Ecobee/RevisionStatus.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ public RevisionStatus(string csv)
66
{
77
var parts = csv.Split(':');
88

9-
ThermostatRevision = parts[0];
10-
ThermostatRevision = parts[1];
11-
ThermostatRevision = parts[2];
9+
ThermostatIdentifier = parts[0];
10+
ThermostatName = parts[1];
11+
Connected = parts[2] == "true";
1212

1313
if (parts.Length >= 3)
1414
ThermostatRevision = parts[3];

src/HomeAutio.Mqtt.Ecobee/ThermostatStatus.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ public ThermostatStatus()
1010

1111
Status = new Dictionary<string, string>();
1212

13-
EquipmentStatus = new Dictionary<string, bool>
13+
EquipmentStatus = new Dictionary<string, string>
1414
{
15-
{ "heatPump", false },
16-
{ "heatPump2", false },
17-
{ "heatPump3", false },
18-
{ "compCool1", false },
19-
{ "compCool2", false },
20-
{ "auxHeat1", false },
21-
{ "auxHeat2", false },
22-
{ "auxHeat3", false },
23-
{ "fan", false },
24-
{ "humidifier", false },
25-
{ "dehumidifier", false },
26-
{ "ventilator", false },
27-
{ "economizer", false },
28-
{ "compHotWater", false },
29-
{ "auxHotWater", false }
15+
{ "heatPump", "off" },
16+
{ "heatPump2", "off" },
17+
{ "heatPump3", "off" },
18+
{ "compCool1", "off" },
19+
{ "compCool2", "off" },
20+
{ "auxHeat1", "off" },
21+
{ "auxHeat2", "off" },
22+
{ "auxHeat3", "off" },
23+
{ "fan", "off" },
24+
{ "humidifier", "off" },
25+
{ "dehumidifier", "off" },
26+
{ "ventilator", "off" },
27+
{ "economizer", "off" },
28+
{ "compHotWater", "off" },
29+
{ "auxHotWater", "off" }
3030
};
3131
}
3232

3333
public IDictionary<string, IDictionary<string, string>> Sensors { get; }
3434
public IDictionary<string, string> Status { get; }
35-
public IDictionary<string, bool> EquipmentStatus { get; }
35+
public IDictionary<string, string> EquipmentStatus { get; }
3636
}
3737
}

src/HomeAutio.Mqtt.Ecobee/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="HomeAutio.Mqtt.Core" version="1.0.0.18" targetFramework="net452" />
4-
<package id="I8Beef.Ecobee" version="1.0.0.11" targetFramework="net452" />
4+
<package id="I8Beef.Ecobee" version="1.0.0.13" targetFramework="net452" />
55
<package id="M2Mqtt" version="4.3.0.0" targetFramework="net452" />
66
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
77
<package id="NLog" version="4.3.10" targetFramework="net452" />

0 commit comments

Comments
 (0)