-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(time-entity): Add "Expose as" option for Listening mode in time-…
…entity node
- Loading branch information
Showing
6 changed files
with
113 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { NodeMessage } from 'node-red'; | ||
|
||
import ExposeAsMixin from '../../common/controllers/ExposeAsMixin'; | ||
import OutputController from '../../common/controllers/OutputController'; | ||
import ValueEntityIntegration from '../../common/integration/ValueEntityIntegration'; | ||
import { TimeEntityNode } from '.'; | ||
|
||
const ExposeAsController = ExposeAsMixin(OutputController<TimeEntityNode>); | ||
export default class TimeEntityController extends ExposeAsController { | ||
protected integration?: ValueEntityIntegration; | ||
// Triggers when a entity value changes in Home Assistant | ||
public async onValueChange(value: string, previousValue?: string) { | ||
if (!this.isEnabled) return; | ||
|
||
const message: NodeMessage = {}; | ||
await this.setCustomOutputs( | ||
this.node.config.outputProperties, | ||
message, | ||
{ | ||
config: this.node.config, | ||
value, | ||
previousValue, | ||
}, | ||
); | ||
|
||
// inject value so colons are not removed | ||
this.status.setSuccess(['__value__', { value }]); | ||
this.node.send(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters