-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(calendar): Implement Calendar Event Trigger Node
* Stub out basic calendar output node * WIP Update UI with draft fields from last attempt * Stuff it, these are the fields I will use * WIP implement event to queue calendar events * WIP implement calendar item timer queue * WIP queue item events * WIP trigger calendar event messages * Add some todos * WIP Refactor EventsCalendarController class * linter fixes * html delint * Allow for mild overdue queuing * Include a check for filter text * Bug-fix: use offset when querying the API * Implement custom outputs * bit of an improvement to status messages * Localise status messages * Bug-fix: prevent queue time drift by basing next queue time on the end of the interval * Include Expose As for the Events Calendar editor * Remove Unnecessary constraint interface definition * Refactor CalendarItem file structure * Remove output count --------- Co-authored-by: Nathan Brittain <[email protected]>
- Loading branch information
Showing
21 changed files
with
706 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Events: calendar | ||
|
||
Outputs calendar item events similar to the calendar automation in Home Assistant | ||
|
||
## Configuration: | ||
|
||
### Entity ID <Badge text="required"/> | ||
|
||
- Type: `string` | ||
|
||
The entity_id for the calendar that contains triggerable calendar items. | ||
|
||
### Relative To <Badge text="required"/> | ||
|
||
- Type: `start | end` | ||
- Default: `start` | ||
|
||
Whether to trigger an event at the start or end of each matching calendar item. | ||
|
||
### Offset <Badge text="required"/> | ||
|
||
- Type: `number` | ||
- Default: 0 seconds | ||
|
||
A negative or positive amount of time to allow the event to be triggered before or after the calendar item's start/end time. | ||
|
||
### Conditions | ||
|
||
This node has two default outputs "allowed" and "blocked". If all the | ||
conditions are true the calendar item will be sent to the output. | ||
|
||
**See Also:** | ||
|
||
- [Conditionals](/guide/conditionals.md) | ||
|
||
### Expose to Home Assistant | ||
|
||
- Type: `boolean` | ||
|
||
Creates a switch within Home Assistant to enable/disable this node. This feature requires [Node-RED custom integration](https://github.com/zachowj/hass-node-red) to be installed in Home Assistant | ||
|
||
## Outputs | ||
|
||
Value types: | ||
|
||
- `calendar item`: the calendar item object as provided by the Home Assistant API |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,41 @@ | ||
import { DateOrDateTime, toDate } from './helpers'; | ||
|
||
export interface ICalendarItem { | ||
start: DateOrDateTime; | ||
end: DateOrDateTime; | ||
summary: string; | ||
description: string; | ||
location?: string | null; | ||
uid: string; | ||
recurrence_id?: string | null; | ||
rrule?: string | null; | ||
queueIndex(): string; | ||
date(eventType: string): Date; | ||
} | ||
|
||
export class CalendarItem implements ICalendarItem { | ||
start!: DateOrDateTime; | ||
end!: DateOrDateTime; | ||
summary!: string; | ||
description!: string; | ||
location?: string | null; | ||
uid!: string; | ||
recurrence_id?: string | null; | ||
rrule?: string | null; | ||
|
||
constructor(data: ICalendarItem) { | ||
Object.assign(this, data); | ||
} | ||
|
||
queueIndex() { | ||
return `${this.uid}${this.recurrence_id || ''}`; | ||
} | ||
|
||
date(eventType: string): Date { | ||
return eventType === 'start' ? toDate(this.start) : toDate(this.end); | ||
} | ||
} | ||
|
||
export function createCalendarItem(data: ICalendarItem): CalendarItem { | ||
return new CalendarItem(data); | ||
} |
Oops, something went wrong.