Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/automation-editor/automation-editor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h, render } from 'preact';
import Automation from './automation';
import Automation from './automation.js';

window.AutomationEditor = function (mountEl, props, mergeEl) {
return render(h(Automation, props), mountEl, mergeEl);
Expand Down
6 changes: 3 additions & 3 deletions js/automation-editor/automation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { h, Component } from 'preact';

import Trigger from './trigger';
import Condition from '../common/component/condition';
import Script from '../common/component/script';
import Trigger from './trigger/index.js';
import Condition from '../common/component/condition/index.js';
import Script from '../common/component/script/index.js';

export default class Automation extends Component {
constructor() {
Expand Down
5 changes: 2 additions & 3 deletions js/automation-editor/trigger/event.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { h, Component } from 'preact';

import JSONTextArea from '../../common/component/json_textarea';

import { onChangeEvent } from '../../common/util/event';
import JSONTextArea from '../../common/component/json_textarea.js';
import { onChangeEvent } from '../../common/util/event.js';

export default class EventTrigger extends Component {
constructor() {
Expand Down
4 changes: 2 additions & 2 deletions js/automation-editor/trigger/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h, Component } from 'preact';

import TriggerRow from './trigger_row';
import StateTrigger from './state';
import TriggerRow from './trigger_row.js';
import StateTrigger from './state.js';

export default class Trigger extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/automation-editor/trigger/mqtt.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../common/util/event';
import { onChangeEvent } from '../../common/util/event.js';

export default class MQTTTrigger extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/automation-editor/trigger/numeric_state.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../common/util/event';
import { onChangeEvent } from '../../common/util/event.js';

export default class NumericStateTrigger extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/automation-editor/trigger/state.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../common/util/event';
import { onChangeEvent } from '../../common/util/event.js';

export default class StateTrigger extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/automation-editor/trigger/sun.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../common/util/event';
import { onChangeEvent } from '../../common/util/event.js';

export default class SunTrigger extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/automation-editor/trigger/template.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../common/util/event';
import { onChangeEvent } from '../../common/util/event.js';

export default class TemplateTrigger extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/automation-editor/trigger/time.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../common/util/event';
import { onChangeEvent } from '../../common/util/event.js';

export default class TimeTrigger extends Component {
constructor() {
Expand Down
18 changes: 9 additions & 9 deletions js/automation-editor/trigger/trigger_edit.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { h, Component } from 'preact';

import EventTrigger from './event';
import HassTrigger from './homeassistant';
import MQTTTrigger from './mqtt';
import NumericStateTrigger from './numeric_state';
import StateTrigger from './state';
import SunTrigger from './sun';
import TemplateTrigger from './template';
import TimeTrigger from './time';
import ZoneTrigger from './zone';
import EventTrigger from './event.js';
import HassTrigger from './homeassistant.js';
import MQTTTrigger from './mqtt.js';
import NumericStateTrigger from './numeric_state.js';
import StateTrigger from './state.js';
import SunTrigger from './sun.js';
import TemplateTrigger from './template.js';
import TimeTrigger from './time.js';
import ZoneTrigger from './zone.js';

const TYPES = {
event: EventTrigger,
Expand Down
2 changes: 1 addition & 1 deletion js/automation-editor/trigger/trigger_row.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import TriggerEdit from './trigger_edit';
import TriggerEdit from './trigger_edit.js';

export default class TriggerRow extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/automation-editor/trigger/zone.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../common/util/event';
import { onChangeEvent } from '../../common/util/event.js';

export default class ZoneTrigger extends Component {
constructor() {
Expand Down
12 changes: 6 additions & 6 deletions js/common/component/condition/condition_edit.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { h, Component } from 'preact';

import NumericStateCondition from './numeric_state';
import StateCondition from './state';
import SunCondition from './sun';
import TemplateCondition from './template';
import TimeCondition from './time';
import ZoneCondition from './zone';
import NumericStateCondition from './numeric_state.js';
import StateCondition from './state.js';
import SunCondition from './sun.js';
import TemplateCondition from './template.js';
import TimeCondition from './time.js';
import ZoneCondition from './zone.js';

const TYPES = {
state: StateCondition,
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/condition/condition_row.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import ConditionEdit from './condition_edit';
import ConditionEdit from './condition_edit.js';

export default class ConditionRow extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/condition/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import ConditionRow from './condition_row';
import ConditionRow from './condition_row.js';

export default class Condition extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/condition/numeric_state.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../util/event';
import { onChangeEvent } from '../../util/event.js';

export default class NumericStateCondition extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/condition/state.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../util/event';
import { onChangeEvent } from '../../util/event.js';

export default class StateCondition extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/condition/sun.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../util/event';
import { onChangeEvent } from '../../util/event.js';

export default class SunCondition extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/condition/template.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../util/event';
import { onChangeEvent } from '../../util/event.js';

export default class TemplateCondition extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/condition/time.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../util/event';
import { onChangeEvent } from '../../util/event.js';

export default class TimeCondition extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/condition/zone.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import { onChangeEvent } from '../../util/event';
import { onChangeEvent } from '../../util/event.js';

export default class ZoneCondition extends Component {
constructor() {
Expand Down
10 changes: 5 additions & 5 deletions js/common/component/script/action_edit.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { h, Component } from 'preact';

import CallServiceAction from './call_service';
import ConditionAction from './condition';
import DelayAction from './delay';
import EventAction from './event';
import WaitAction from './wait';
import CallServiceAction from './call_service.js';
import ConditionAction from './condition.js';
import DelayAction from './delay.js';
import EventAction from './event.js';
import WaitAction from './wait.js';

const TYPES = {
'Call Service': CallServiceAction,
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/script/action_row.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import ActionEdit from './action_edit';
import ActionEdit from './action_edit.js';

export default class Action extends Component {
constructor() {
Expand Down
4 changes: 2 additions & 2 deletions js/common/component/script/call_service.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h, Component } from 'preact';

import JSONTextArea from '../json_textarea';
import { onChangeEvent } from '../../util/event';
import JSONTextArea from '../json_textarea.js';
import { onChangeEvent } from '../../util/event.js';

export default class CallServiceAction extends Component {
constructor() {
Expand Down
4 changes: 2 additions & 2 deletions js/common/component/script/condition.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h, Component } from 'preact';

import StateCondition from '../condition/state';
import ConditionEdit from '../condition/condition_edit';
import StateCondition from '../condition/state.js';
import ConditionEdit from '../condition/condition_edit.js';

export default class ConditionAction extends Component {
// eslint-disable-next-line
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/script/delay.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h, Component } from 'preact';
import { onChangeEvent } from '../../util/event';
import { onChangeEvent } from '../../util/event.js';

export default class DelayAction extends Component {
constructor() {
Expand Down
4 changes: 2 additions & 2 deletions js/common/component/script/event.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h, Component } from 'preact';

import JSONTextArea from '../json_textarea';
import { onChangeEvent } from '../../util/event';
import JSONTextArea from '../json_textarea.js';
import { onChangeEvent } from '../../util/event.js';

export default class EventAction extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/script/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import ActionRow from './action_row';
import ActionRow from './action_row.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './action_row.js' import/no-unresolved
Unexpected use of file extension "js" for "./action_row.js" import/extensions


export default class Script extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion js/common/component/script/wait.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h, Component } from 'preact';
import { onChangeEvent } from '../../util/event';
import { onChangeEvent } from '../../util/event.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module '../../util/event.js' import/no-unresolved
Unexpected use of file extension "js" for "../../util/event.js" import/extensions


export default class WaitAction extends Component {
constructor() {
Expand Down
8 changes: 2 additions & 6 deletions js/common/util/compute_domain.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export default function computeDomain(stateObj) {
if (!stateObj._domain) {
stateObj._domain = stateObj.entity_id.substr(0, stateObj.entity_id.indexOf('.'));
}

return stateObj._domain;
export default function computeDomain(entityId) {
return entityId.substr(0, entityId.indexOf('.'));
}
10 changes: 5 additions & 5 deletions js/common/util/compute_state_display.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import computeDomain from './compute_domain';
import formatDateTime from './format_date_time';
import formatDate from './format_date';
import formatTime from './format_time';
import computeStateDomain from './compute_state_domain.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './compute_state_domain.js' import/no-unresolved
Unexpected use of file extension "js" for "./compute_state_domain.js" import/extensions

import formatDateTime from './format_date_time.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './format_date_time.js' import/no-unresolved
Unexpected use of file extension "js" for "./format_date_time.js" import/extensions

import formatDate from './format_date.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './format_date.js' import/no-unresolved
Unexpected use of file extension "js" for "./format_date.js" import/extensions

import formatTime from './format_time.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './format_time.js' import/no-unresolved
Unexpected use of file extension "js" for "./format_time.js" import/extensions


export default function computeStateDisplay(haLocalize, stateObj, language) {
if (!stateObj._stateDisplay) {
const domain = computeDomain(stateObj);
const domain = computeStateDomain(stateObj);
if (domain === 'binary_sensor') {
// Try device class translation, then default binary sensor translation
if (stateObj.attributes.device_class) {
Expand Down
9 changes: 9 additions & 0 deletions js/common/util/compute_state_domain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import computeDomain from './compute_domain.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './compute_domain.js' import/no-unresolved
Unexpected use of file extension "js" for "./compute_domain.js" import/extensions


export default function computeStateDomain(stateObj) {
if (!stateObj._domain) {
stateObj._domain = computeDomain(stateObj.entity_id);
}

return stateObj._domain;
}
2 changes: 1 addition & 1 deletion js/script-editor/script-editor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h, render } from 'preact';
import Script from './script';
import Script from './script.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './script.js' import/no-unresolved
Unexpected use of file extension "js" for "./script.js" import/extensions


window.ScriptEditor = function (mountEl, props, mergeEl) {
return render(h(Script, props), mountEl, mergeEl);
Expand Down
2 changes: 1 addition & 1 deletion js/script-editor/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, Component } from 'preact';

import Script from '../common/component/script';
import Script from '../common/component/script/index.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module '../common/component/script/index.js' import/no-unresolved
Unexpected use of file extension "js" for "../common/component/script/index.js" import/extensions


export default class ScriptEditor extends Component {
constructor() {
Expand Down
14 changes: 7 additions & 7 deletions js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* import these functions where we need them.
*/

import attributeClassNames from './common/util/attribute_class_names';
import computeDomain from './common/util/compute_domain';
import computeStateDisplay from './common/util/compute_state_display';
import formatDate from './common/util/format_date';
import formatDateTime from './common/util/format_date_time';
import formatTime from './common/util/format_time';
import attributeClassNames from './common/util/attribute_class_names.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './common/util/attribute_class_names.js' import/no-unresolved
Unexpected use of file extension "js" for "./common/util/attribute_class_names.js" import/extensions

import computeStateDomain from './common/util/compute_state_domain.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './common/util/compute_state_domain.js' import/no-unresolved
Unexpected use of file extension "js" for "./common/util/compute_state_domain.js" import/extensions

import computeStateDisplay from './common/util/compute_state_display.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './common/util/compute_state_display.js' import/no-unresolved
Unexpected use of file extension "js" for "./common/util/compute_state_display.js" import/extensions

import formatDate from './common/util/format_date.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './common/util/format_date.js' import/no-unresolved
Unexpected use of file extension "js" for "./common/util/format_date.js" import/extensions

import formatDateTime from './common/util/format_date_time.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './common/util/format_date_time.js' import/no-unresolved
Unexpected use of file extension "js" for "./common/util/format_date_time.js" import/extensions

import formatTime from './common/util/format_time.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './common/util/format_time.js' import/no-unresolved
Unexpected use of file extension "js" for "./common/util/format_time.js" import/extensions


window.hassUtil = window.hassUtil || {};

Expand All @@ -21,7 +21,7 @@ const language = navigator.languages ?
window.fecha.masks.haDateTime = window.fecha.masks.shortTime + ' ' + window.fecha.masks.mediumDate;

window.hassUtil.attributeClassNames = attributeClassNames;
window.hassUtil.computeDomain = computeDomain;
window.hassUtil.computeDomain = computeStateDomain;
window.hassUtil.computeStateDisplay = computeStateDisplay;
window.hassUtil.formatDate = dateObj => formatDate(dateObj, language);
window.hassUtil.formatDateTime = dateObj => formatDateTime(dateObj, language);
Expand Down
10 changes: 5 additions & 5 deletions test-mocha/common/util/compute_domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import computeDomain from '../../../js/common/util/compute_domain';
const assert = require('assert');

describe('computeDomain', () => {
it('Detects sensor domain', () => {
const stateObj = {
entity_id: 'sensor.test',
};
assert.strictEqual(computeDomain(stateObj), 'sensor');
it('Returns domains', () => {
assert.equal(computeDomain('sensor.bla'), 'sensor');
assert.equal(computeDomain('switch.bla'), 'switch');
assert.equal(computeDomain('light.bla'), 'light');
assert.equal(computeDomain('persistent_notification.bla'), 'persistent_notification');
});
});
12 changes: 12 additions & 0 deletions test-mocha/common/util/compute_state_domain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import computeStateDomain from '../../../js/common/util/compute_state_domain.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module '../../../js/common/util/compute_state_domain.js' import/no-unresolved
Unexpected use of file extension "js" for "../../../js/common/util/compute_state_domain.js" import/extensions


const assert = require('assert');

describe('computeStateDomain', () => {
it('Detects sensor domain', () => {
const stateObj = {
entity_id: 'sensor.test',
};
assert.strictEqual(computeStateDomain(stateObj), 'sensor');
});
});