feat(web-app): add temperature request
The POST request was added to ask a new temperature, but didn't get the new one.
This commit is contained in:
@@ -41,6 +41,9 @@ import { URL, USERNAME, PASSWORD, USER, ROOM, DEVICE, APP_NAME } from "./const";
|
|||||||
import { Serie } from "./Measures/Serie";
|
import { Serie } from "./Measures/Serie";
|
||||||
|
|
||||||
let httpClient = new HttpClient(URL, USERNAME, PASSWORD);
|
let httpClient = new HttpClient(URL, USERNAME, PASSWORD);
|
||||||
|
|
||||||
|
// console.log(httpClient.newValue(URL, USERNAME, PASSWORD));
|
||||||
|
|
||||||
let manager = new TimeSeriesManager(httpClient);
|
let manager = new TimeSeriesManager(httpClient);
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export class HttpClient {
|
|||||||
private getAuthHeader() {
|
private getAuthHeader() {
|
||||||
return {
|
return {
|
||||||
Authorization: `Basic ${btoa(`${this._username}:${this._password}`)}`,
|
Authorization: `Basic ${btoa(`${this._username}:${this._password}`)}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,4 +55,26 @@ export class HttpClient {
|
|||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async newValue(
|
||||||
|
user: string,
|
||||||
|
room: string,
|
||||||
|
device: string
|
||||||
|
): Promise<AxiosResponse<any, any>> {
|
||||||
|
const response = await axios.post(
|
||||||
|
`${BASE}${this._url}/${RACLETTE}`,
|
||||||
|
{
|
||||||
|
command: "MEASURE_NEW",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: this.getAuthHeader(),
|
||||||
|
params: {
|
||||||
|
user: user,
|
||||||
|
room: room,
|
||||||
|
device: device,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,4 +77,11 @@ export class TimeSeriesManager {
|
|||||||
throw error; // Re-throw to allow calling code to handle it
|
throw error; // Re-throw to allow calling code to handle it
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getNewValue(user: string, room: string, device: string) {
|
||||||
|
this.client.newValue(user, room, device).catch((error) => {
|
||||||
|
console.error("Error asking new values:", error);
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user