mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-22 17:22:58 +01:00
🔨 Temporary disable home assistant sensor (suspected to create crash) #102
This commit is contained in:
parent
15ed577682
commit
aa99b360d3
@ -500,72 +500,72 @@ function startAddons() {
|
|||||||
|
|
||||||
function publish_state(state){
|
function publish_state(state){
|
||||||
|
|
||||||
let data_error_sensor = {
|
// let data_error_sensor = {
|
||||||
state: state.status == "error" ? "on" : "off",
|
// state: state.status == "error" ? "on" : "off",
|
||||||
attributes: {
|
// attributes: {
|
||||||
friendly_name: "Nexcloud Backup Error",
|
// friendly_name: "Nexcloud Backup Error",
|
||||||
device_class: "problem",
|
// device_class: "problem",
|
||||||
error_code: state.error_code,
|
// error_code: state.error_code,
|
||||||
message: state.message,
|
// message: state.message,
|
||||||
icon: state.status == "error" ? "mdi:cloud-alert" : "mdi:cloud-check"
|
// icon: state.status == "error" ? "mdi:cloud-alert" : "mdi:cloud-check"
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
let token = process.env.HASSIO_TOKEN;
|
// let token = process.env.HASSIO_TOKEN;
|
||||||
let option = {
|
// let option = {
|
||||||
headers: { "Authorization": `Bearer ${token}` },
|
// headers: { "Authorization": `Bearer ${token}` },
|
||||||
responseType: "json",
|
// responseType: "json",
|
||||||
json: data_error_sensor
|
// json: data_error_sensor
|
||||||
};
|
// };
|
||||||
got.post(`http://hassio/core/api/states/binary_sensor.nextcloud_backup_error`, option)
|
// got.post(`http://hassio/core/api/states/binary_sensor.nextcloud_backup_error`, option)
|
||||||
.then((result) => {
|
// .then((result) => {
|
||||||
logger.debug('Home assistant sensor updated (error status)');
|
// logger.debug('Home assistant sensor updated (error status)');
|
||||||
})
|
// })
|
||||||
.catch((error) => {
|
// .catch((error) => {
|
||||||
logger.error(error);
|
// logger.error(error);
|
||||||
});
|
// });
|
||||||
|
|
||||||
let icon = ""
|
// let icon = ""
|
||||||
switch(state.status){
|
// switch(state.status){
|
||||||
case "error":
|
// case "error":
|
||||||
icon = "mdi:cloud-alert";
|
// icon = "mdi:cloud-alert";
|
||||||
break;
|
// break;
|
||||||
case "download":
|
// case "download":
|
||||||
case "download-b":
|
// case "download-b":
|
||||||
icon = "mdi:cloud-download";
|
// icon = "mdi:cloud-download";
|
||||||
break;
|
// break;
|
||||||
case "upload":
|
// case "upload":
|
||||||
case "upload-b":
|
// case "upload-b":
|
||||||
icon = "mdi:cloud-upload";
|
// icon = "mdi:cloud-upload";
|
||||||
break;
|
// break;
|
||||||
case "idle":
|
// case "idle":
|
||||||
icon = "mdi:cloud-check";
|
// icon = "mdi:cloud-check";
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
icon = "mdi:cloud-sync";
|
// icon = "mdi:cloud-sync";
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
let data_state_sensor = {
|
// let data_state_sensor = {
|
||||||
state: state.status,
|
// state: state.status,
|
||||||
attributes: {
|
// attributes: {
|
||||||
friendly_name: "Nexcloud Backup Status",
|
// friendly_name: "Nexcloud Backup Status",
|
||||||
error_code: state.error_code,
|
// error_code: state.error_code,
|
||||||
message: state.message,
|
// message: state.message,
|
||||||
icon: icon,
|
// icon: icon,
|
||||||
last_backup: state.last_backup == null || state.last_backup == "" ? "" : new Date(state.last_backup).toISOString(),
|
// last_backup: state.last_backup == null || state.last_backup == "" ? "" : new Date(state.last_backup).toISOString(),
|
||||||
next_backup: state.next_backup == null || state.next_backup == "" ? "" : new Date(state.next_backup).toISOString()
|
// next_backup: state.next_backup == null || state.next_backup == "" ? "" : new Date(state.next_backup).toISOString()
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
option.json = data_state_sensor
|
// option.json = data_state_sensor
|
||||||
got.post(`http://hassio/core/api/states/sensor.nextcloud_backup_status`, option)
|
// got.post(`http://hassio/core/api/states/sensor.nextcloud_backup_status`, option)
|
||||||
.then((result) => {
|
// .then((result) => {
|
||||||
logger.debug('Home assistant sensor updated (status)');
|
// logger.debug('Home assistant sensor updated (status)');
|
||||||
})
|
// })
|
||||||
.catch((error) => {
|
// .catch((error) => {
|
||||||
logger.error(error);
|
// logger.error(error);
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getVersion = getVersion;
|
exports.getVersion = getVersion;
|
||||||
|
Loading…
Reference in New Issue
Block a user