Skip to content

Commit

Permalink
Merge pull request #179 from luc-ass/api-url-change
Browse files Browse the repository at this point in the history
[FIX] API URL Change
  • Loading branch information
luc-ass authored Dec 12, 2024
2 parents 716d73a + 958efe9 commit 4445b3f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
49 changes: 14 additions & 35 deletions lib/evohome.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ var Q = require("q");
var request = require("request");
var _ = require("lodash");

const BASE_URL = "https://tccna.resideo.com";
const API_URL = `${BASE_URL}/WebAPI/emea/api/v1`;

function UserInfo(json) {
this.userID = json.userId;
this.username = json.username;
Expand Down Expand Up @@ -112,11 +115,7 @@ function SystemModeStatus(json) {

Session.prototype.getSchedule = function (zoneId, isHotWater) {
var zone_type = isHotWater ? "domesticHotWater" : "temperatureZone";
var url =
"https://tccna.honeywell.com/WebAPI/emea/api/v1/" +
zone_type + "/" +
zoneId +
"/schedule";
var url = `${API_URL}/${zone_type}/${zoneId}/schedule`;
return this._request(url).then(function (json) {
return _.map(json.dailySchedules, function (s) {
return new Schedule(s);
Expand All @@ -125,10 +124,7 @@ Session.prototype.getSchedule = function (zoneId, isHotWater) {
};

Session.prototype.getThermostats = function (locationId) {
var url =
"https://tccna.honeywell.com/WebAPI/emea/api/v1/location/" +
locationId +
"/status?includeTemperatureControlSystems=True";
var url = `${API_URL}/location/${locationId}/status?includeTemperatureControlSystems=True`;
return this._request(url).then(function (json) {
return _.map(
json.gateways[0].temperatureControlSystems[0].zones,
Expand All @@ -140,20 +136,14 @@ Session.prototype.getThermostats = function (locationId) {
};

Session.prototype.getHotWater = function (dhwId) {
var url =
"https://tccna.honeywell.com/WebAPI/emea/api/v1/domesticHotWater/" +
dhwId +
"/status?";
var url = `${API_URL}/domesticHotWater/${dhwId}/status?`;
return this._request(url).then(function (json) {
return new DHW(json)
});
};

Session.prototype.getSystemModeStatus = function (locationId) {
var url =
"https://tccna.honeywell.com/WebAPI/emea/api/v1/location/" +
locationId +
"/status?includeTemperatureControlSystems=True";
var url = `${API_URL}/location/${locationId}/status?includeTemperatureControlSystems=True`;
return this._request(url).then(function (json) {
return new SystemModeStatus(
json.gateways[0].temperatureControlSystems[0].systemModeStatus
Expand All @@ -162,10 +152,7 @@ Session.prototype.getSystemModeStatus = function (locationId) {
};

Session.prototype.getLocations = function () {
var url =
"https://tccna.honeywell.com/WebAPI/emea/api/v1/location/installationInfo?userId=" +
this.userInfo.userID +
"&includeTemperatureControlSystems=True";
var url = `${API_URL}/location/installationInfo?userId=${this.userInfo.userID}&includeTemperatureControlSystems=True`;
return this._request(url).then(function (json) {
return _.map(json, function (location) {
var data = {};
Expand Down Expand Up @@ -196,10 +183,7 @@ Session.prototype.setHeatSetpoint = function (
endtime
) {
var deferred = Q.defer();
var url =
"https://tccna.honeywell.com/WebAPI/emea/api/v1/temperatureZone/" +
zoneId +
"/heatSetpoint";
var url = `${API_URL}/temperatureZone/${zoneId}/heatSetpoint`;
var now = new Date();

if (endtime != null) {
Expand Down Expand Up @@ -253,20 +237,15 @@ Session.prototype.setHeatSetpoint = function (
};

function getDataForHotWater(dhwId, data) {
var url = "https://tccna.honeywell.com/WebAPI/emea/api/v1/domesticHotWater/" +
dhwId +
"/state";
var url = `${API_URL}/domesticHotWater/${dhwId}/state`;

var body = JSON.stringify(data);

return [url, body];
}

function getDataForSwitch(systemId, systemMode) {
var url =
"https://tccna.honeywell.com/WebAPI/emea/api/v1/temperatureControlSystem/" +
systemId +
"/mode";
var url = `${API_URL}/temperatureControlSystem/${systemId}/mode`;

var body = JSON.stringify({
SystemMode: systemMode,
Expand Down Expand Up @@ -313,7 +292,7 @@ Session.prototype._renew = function () {
request(
{
method: "POST",
url: "https://tccna.honeywell.com/Auth/OAuth/Token",
url: `${BASE_URL}/Auth/OAuth/Token`,
headers: {
Authorization:
"Basic NGEyMzEwODktZDJiNi00MWJkLWE1ZWItMTZhMGE0MjJiOTk5OjFhMTVjZGI4LTQyZGUtNDA3Yi1hZGQwLTA1OWY5MmM1MzBjYg==",
Expand Down Expand Up @@ -377,7 +356,7 @@ function login(username, password) {
request(
{
method: "POST",
url: "https://tccna.honeywell.com/Auth/OAuth/Token",
url: `${BASE_URL}/Auth/OAuth/Token`,
headers: {
Authorization:
"Basic NGEyMzEwODktZDJiNi00MWJkLWE1ZWItMTZhMGE0MjJiOTk5OjFhMTVjZGI4LTQyZGUtNDA3Yi1hZGQwLTA1OWY5MmM1MzBjYg==",
Expand Down Expand Up @@ -421,7 +400,7 @@ function getUserInfo(json) {
request(
{
method: "GET",
url: "https://tccna.honeywell.com/WebAPI/emea/api/v1/userAccount",
url: `${API_URL}/userAccount`,
headers: {
Authorization: "bearer " + json.access_token,
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Homebridge Evohome",
"name": "homebridge-evohome",
"version": "0.11.0",
"version": "0.11.2",
"description": "Honeywell Evohome support for Homebridge: https://github.com/nfarina/homebridge",
"license": "ISC",
"keywords": [
Expand Down

0 comments on commit 4445b3f

Please sign in to comment.