Remove models/index.ts

This commit is contained in:
2020-05-05 18:51:36 +03:00
parent e5b92b0396
commit 80d551db6e
3 changed files with 10 additions and 8 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ import {
property,
TemplateResult,
} from 'lit-element';
import { TimeUnit } from '../models';
import { TimeUnit } from '../models/time-unit';
import { Direction } from '../types';
@customElement('time-unit')
-3
View File
@@ -1,3 +0,0 @@
export { TimeUnit } from './time-unit';
export { Hour } from './hour';
export { Minute } from './minute';
+9 -4
View File
@@ -11,7 +11,8 @@ import {
} from 'lit-element';
import './components/time-unit.component';
import { CARD_SIZE, CARD_VERSION, STYLE_VARIABLES } from './const';
import { Hour, Minute } from './models';
import { Hour } from './models/hour';
import { Minute } from './models/minute';
import { Partial } from './partials';
import { TimePickerCardConfig } from './types';
@@ -36,11 +37,15 @@ export class TimePickerCard extends LitElement {
);
}
private get entity(): HassEntity {
private get entity(): HassEntity | undefined {
return this.hass.states[this.config.entity];
}
render(): TemplateResult | null {
if (!this.entity) {
return Partial.error('Entity not found', this.config);
}
if (!this.entity.entity_id.startsWith('input_datetime')) {
return Partial.error('You must set an input_datetime entity', this.config);
}
@@ -52,7 +57,7 @@ export class TimePickerCard extends LitElement {
);
}
const { hour, minute } = this.entity.attributes;
const { hour, minute } = this.entity!.attributes;
this.hour = new Hour(hour, this.config.hour_step);
this.minute = new Minute(minute, this.config.minute_step);
@@ -89,7 +94,7 @@ export class TimePickerCard extends LitElement {
const time = `${this.hour.value}:${this.minute.value}:00`;
return this.hass.callService('input_datetime', 'set_datetime', {
entity_id: this.entity.entity_id,
entity_id: this.entity!.entity_id,
time,
});
}