Fix problems in map card when hours_to_show is 0 (#15900)

This commit is contained in:
karwosts 2023-03-22 09:55:30 -07:00 committed by GitHub
parent 7c62b08fdd
commit da2de3c7d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,7 @@ import {
HistoryStates,
subscribeHistoryStatesTimeWindow,
} from "../../../data/history";
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
import { HomeAssistant } from "../../../types";
import { findEntities } from "../common/find-entities";
import { processConfigEntities } from "../common/process-config-entities";
@ -187,7 +188,7 @@ class HuiMapCard extends LitElement implements LovelaceCard {
return true;
}
return false;
return hasConfigOrEntitiesChanged(this, changedProps);
}
public connectedCallback() {
@ -203,7 +204,11 @@ class HuiMapCard extends LitElement implements LovelaceCard {
}
private _subscribeHistory() {
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
if (
!isComponentLoaded(this.hass!, "history") ||
this._subscribed ||
!(this._config?.hours_to_show ?? DEFAULT_HOURS_TO_SHOW)
) {
return;
}
this._subscribed = subscribeHistoryStatesTimeWindow(
@ -324,7 +329,7 @@ class HuiMapCard extends LitElement implements LovelaceCard {
config: MapCardConfig,
history?: HistoryStates
): HaMapPaths[] | undefined => {
if (!history) {
if (!history || !(config.hours_to_show ?? DEFAULT_HOURS_TO_SHOW)) {
return undefined;
}