Add tamper device class for binary sensor (#10268)

This commit is contained in:
Franck Nijhof 2021-10-14 12:22:07 +02:00 committed by GitHub
parent 4ad005f0bf
commit a91d25b27d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 1 deletions

View File

@ -22,6 +22,7 @@ export const binarySensorIcon = (state?: string, stateObj?: HassEntity) => {
case "gas":
case "problem":
case "safety":
case "tamper":
return is_off ? "hass:check-circle" : "hass:alert-circle";
case "smoke":
return is_off ? "hass:check-circle" : "hass:smoke";

View File

@ -26,6 +26,7 @@ const BINARY_SENSOR_DEVICE_CLASS_COLOR_INVERTED = new Set([
"problem",
"safety",
"smoke",
"tamper",
"window",
]);

View File

@ -279,6 +279,15 @@ export const getLogbookMessage = (
);
}
break;
case "tamper":
if (isOn) {
return hass.localize(`${LOGBOOK_LOCALIZE_PATH}.detected_tampering`);
}
if (isOff) {
return hass.localize(`${LOGBOOK_LOCALIZE_PATH}.cleared_tampering`);
}
break;
}
break;

View File

@ -333,7 +333,9 @@
"turned_off": "turned off",
"turned_on": "turned on",
"changed_to_state": "changed to {state}",
"became_unavailable": "became unavailable"
"became_unavailable": "became unavailable",
"detected_tampering": "detected tampering",
"cleared_tampering": "cleared tampering"
}
},
"entity": {

View File

@ -34,6 +34,7 @@ const hassAttributeUtil = {
"safety",
"smoke",
"sound",
"tamper",
"vibration",
"window",
],