start_pause is only supported on entities that don't have STATE sup… (#17147)

* `start_pause` is only support on entities that don't have `STATE` support

* Update hui-vacuum-commands-tile-feature.ts

* Add comment
This commit is contained in:
Bram Kragten 2023-07-11 14:54:38 +02:00 committed by GitHub
parent 04ec380ce0
commit 33b9786ae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -43,9 +43,11 @@ const VACUUM_COMMANDS: VacuumCommand[] = [
icon: mdiPause,
serviceName: "pause",
isVisible: (stateObj) =>
// We need also to check if Start is supported because if not we show play-pause
supportsFeature(stateObj, VacuumEntityFeature.START) &&
supportsFeature(stateObj, VacuumEntityFeature.PAUSE),
// We need also to check if Start is supported because if not we show start-pause
// Start-pause service is only available for old vacuum entities, new entities have the `STATE` feature
supportsFeature(stateObj, VacuumEntityFeature.PAUSE) &&
(supportsFeature(stateObj, VacuumEntityFeature.STATE) ||
supportsFeature(stateObj, VacuumEntityFeature.START)),
},
{
translationKey: "start_pause",
@ -53,6 +55,8 @@ const VACUUM_COMMANDS: VacuumCommand[] = [
serviceName: "start_pause",
isVisible: (stateObj) =>
// If start is supported, we don't show this button
// This service is only available for old vacuum entities, new entities have the `STATE` feature
!supportsFeature(stateObj, VacuumEntityFeature.STATE) &&
!supportsFeature(stateObj, VacuumEntityFeature.START) &&
supportsFeature(stateObj, VacuumEntityFeature.PAUSE),
},

View File

@ -63,6 +63,8 @@ export const VACUUM_COMMANDS_BUTTONS: Record<
> = {
start_pause: (stateObj) => {
const startPauseOnly =
// This service is only available for old vacuum entities, new entities have the `STATE` feature
!supportsFeature(stateObj, VacuumEntityFeature.STATE) &&
!supportsFeature(stateObj, VacuumEntityFeature.START) &&
supportsFeature(stateObj, VacuumEntityFeature.PAUSE);