Skip to content

Commit

Permalink
add lexus type
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Aug 26, 2023
1 parent f2c5271 commit 6c445a3
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 84 deletions.
149 changes: 74 additions & 75 deletions admin/index_m.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<html>

<head>

<head>
<!-- Load ioBroker scripts and styles-->
<link rel="stylesheet" type="text/css" href="../../css/adapter.css" />
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css">
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css" />

<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
Expand All @@ -18,84 +16,85 @@
<script type="text/javascript" src="words.js"></script>

<script type="text/javascript">
// This will be called by the admin adapter when the settings page loads
function load(settings, onChange) {
// example: select elements with id=key and class=value and insert value
if (!settings) return;
$('.value').each(function () {
var $key = $(this);
var id = $key.attr('id');
if ($key.attr('type') === 'checkbox') {
// do not call onChange direct, because onChange could expect some arguments
$key.prop('checked', settings[id])
.on('change', () => onChange())
;
} else {
// do not call onChange direct, because onChange could expect some arguments
$key.val(settings[id])
.on('change', () => onChange())
.on('keyup', () => onChange())
;
}
});
onChange(false);
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
if (M) M.updateTextFields();
}

// This will be called by the admin adapter when the user presses the save button
function save(callback) {
// example: select elements with class=value and build settings object
var obj = {};
$('.value').each(function () {
var $this = $(this);
if ($this.attr('type') === 'checkbox') {
obj[$this.attr('id')] = $this.prop('checked');
} else if ($this.attr('type') === 'number') {
obj[$this.attr('id')] = parseFloat($this.val());
} else {
obj[$this.attr('id')] = $this.val();
}
});
callback(obj);
}
// This will be called by the admin adapter when the settings page loads
function load(settings, onChange) {
// example: select elements with id=key and class=value and insert value
if (!settings) return;
$(".value").each(function () {
var $key = $(this);
var id = $key.attr("id");
if ($key.attr("type") === "checkbox") {
// do not call onChange direct, because onChange could expect some arguments
$key.prop("checked", settings[id]).on("change", () => onChange());
} else {
// do not call onChange direct, because onChange could expect some arguments
$key
.val(settings[id])
.on("change", () => onChange())
.on("keyup", () => onChange());
}
});
onChange(false);
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
if (M) M.updateTextFields();
}

// This will be called by the admin adapter when the user presses the save button
function save(callback) {
// example: select elements with class=value and build settings object
var obj = {};
$(".value").each(function () {
var $this = $(this);
if ($this.attr("type") === "checkbox") {
obj[$this.attr("id")] = $this.prop("checked");
} else if ($this.attr("type") === "number") {
obj[$this.attr("id")] = parseFloat($this.val());
} else {
obj[$this.attr("id")] = $this.val();
}
});
callback(obj);
}
</script>
</head>

</head>

<body>

<body>
<div class="m adapter-container">

<div class="row">
<div class="col s12 m4 l2">
<img src="toyota.png" class="logo">
</div>
<div class="row">
<div class="col s12 m4 l2">
<img src="toyota.png" class="logo" />
</div>
</div>

<!-- Put your content here -->
<!-- Put your content here -->

<div class="row">
<div class="col s6 input-field">
<input type="text" class="value" id="username" />
<label for="username" class="translate">App Email</label>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="text" class="value" id="username" />
<label for="username" class="translate">App Email</label>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="password" class="value" id="password" />
<label for="password" class="translate">App Password</label>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="password" class="value" id="password" />
<label for="password" class="translate">App Password</label>
</div>

<div class="row">
<div class="col s2 input-field">
<input type="number" class="value" id="interval" />
<label for="interval" class="translate">Update interval in minutes</label>
</div>
</div>
<div class="row">
<div class="col s2 input-field">
<select id="type" class="value">
<option value="toyota">Toyota</option>
<option value="lexus">Lexus</option>
</select>
<label for="type" class="translate">App Toyota or Lexus</label>
</div>
</div>
<div class="row">
<div class="col s2 input-field">
<input type="number" class="value" id="interval" />
<label for="interval" class="translate">Update interval in minutes</label>
</div>
</div>
</div>

</body>

</html>
</body>
</html>
1 change: 1 addition & 0 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"native": {
"username": "",
"password": "",
"type": "toyota",
"interval": 10
},
"objects": [],
Expand Down
21 changes: 12 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Toyota extends utils.Adapter {
this.updateInterval = null;
this.reLoginTimeout = null;
this.refreshTokenTimeout = null;
this.hostName = "" + this.hostName + "";
}

/**
Expand All @@ -43,7 +44,9 @@ class Toyota extends utils.Adapter {
this.config.interval = 0.5;
}
this.subscribeStates("*");

if (this.config.type === "lexus") {
this.hostName = "lexuslink-agg.toyota-europe.com";
}
await this.login();

if (this.token && this.uuid) {
Expand All @@ -60,7 +63,7 @@ class Toyota extends utils.Adapter {
async login() {
this.session_data = await this.requestClient({
method: "post",
url: "https://myt-agg.toyota-europe.com/cma/api/user/login",
url: "https://" + this.hostName + "/cma/api/user/login",
headers: {
accept: "*/*",
"content-type": "application/json",
Expand Down Expand Up @@ -95,7 +98,7 @@ class Toyota extends utils.Adapter {
async getDeviceList() {
await this.requestClient({
method: "get",
url: "https://myt-agg.toyota-europe.com/cma/api/user/" + this.uuid + "/vehicle/details?allServices=true",
url: "https://" + this.hostName + "/cma/api/user/" + this.uuid + "/vehicle/details?allServices=true",
headers: {
cookie: "iPlanetDirectoryPro=" + this.token,
accept: "*/*",
Expand Down Expand Up @@ -168,27 +171,27 @@ class Toyota extends utils.Adapter {
const statusArray = [
{
path: "status",
url: "https://myt-agg.toyota-europe.com/cma/api/users/" + this.uuid + "/vehicles/$vin/vehicleStatus",
url: "https://" + this.hostName + "/cma/api/users/" + this.uuid + "/vehicles/$vin/vehicleStatus",
desc: "Status of the car",
},
{
path: "addtionalInfo",
url: "https://myt-agg.toyota-europe.com/cma/api/vehicle/$vin/addtionalInfo",
url: "https://" + this.hostName + "/cma/api/vehicle/$vin/addtionalInfo",
desc: "AddtionalInfo of the car",
},
{
path: "location",
url: "https://myt-agg.toyota-europe.com/cma/api/users/" + this.uuid + "/vehicle/location",
url: "https://" + this.hostName + "/cma/api/users/" + this.uuid + "/vehicle/location",
desc: "Location of the car",
},
{
path: "parking",
url: "https://myt-agg.toyota-europe.com/cma/api/users/" + this.uuid + "/vehicles/$vin/parking",
url: "https://" + this.hostName + "/cma/api/users/" + this.uuid + "/vehicles/$vin/parking",
desc: "Parking of the car",
},
{
path: "statusV2",
url: "https://myt-agg.toyota-europe.com/cma/api/vehicles/$vin/remoteControl/status",
url: "https://" + this.hostName + "/cma/api/vehicles/$vin/remoteControl/status",
desc: "Additional Status Information",
},
];
Expand Down Expand Up @@ -304,7 +307,7 @@ class Toyota extends utils.Adapter {
},
},
};
const url = "https://myt-agg.toyota-europe.com/cma/api/user/" + this.uuid + "/vehicle/" + deviceId + "/remoteControl";
const url = "https://" + this.hostName + "/cma/api/user/" + this.uuid + "/vehicle/" + deviceId + "/remoteControl";
this.log.debug(JSON.stringify(data));
this.log.debug(url);
await this.requestClient({
Expand Down

0 comments on commit 6c445a3

Please sign in to comment.