Restore default hours to show on map card to 0 (#15220)

* Restore default hours to show on map card to 0

fixes #15216

* tweak

* always clear this._subscribed right away on unsub

* adjust

* merge from #15217

* merge from #15217
This commit is contained in:
J. Nick Koston 2023-01-30 13:34:35 -06:00 committed by GitHub
parent 9220d65f78
commit 41420c3af3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,7 @@ import {
formatTimeWeekday,
} from "../../../common/datetime/format_time";
const DEFAULT_HOURS_TO_SHOW = 24;
const DEFAULT_HOURS_TO_SHOW = 0;
@customElement("hui-map-card")
class HuiMapCard extends LitElement implements LovelaceCard {
@property({ attribute: false }) public hass!: HomeAssistant;
@ -213,7 +213,7 @@ class HuiMapCard extends LitElement implements LovelaceCard {
}
this._stateHistory = combinedHistory;
},
this._config!.hours_to_show! || DEFAULT_HOURS_TO_SHOW,
this._config!.hours_to_show! ?? DEFAULT_HOURS_TO_SHOW,
this._configEntities!,
false,
false
@ -341,7 +341,7 @@ class HuiMapCard extends LitElement implements LovelaceCard {
const p = {} as HaMapPathPoint;
p.point = [latitude, longitude] as LatLngTuple;
const t = new Date(entityState.lu * 1000);
if (config.hours_to_show! || DEFAULT_HOURS_TO_SHOW > 144) {
if (config.hours_to_show! ?? DEFAULT_HOURS_TO_SHOW > 144) {
// if showing > 6 days in the history trail, show the full
// date and time
p.tooltip = formatDateTime(t, this.hass.locale);