Lines
92.30%
12 / 13
Methods
75.00%
3 / 4
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| type | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| describe | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| toMessage | 100.00% | 10 / 10 | 100.00% | 1 / 1 | 1 | ||
| 11 | final readonly class GetHistoryDuringPeriod implements HaCommand | |
| 12 | { | |
| 13 | public function __construct( | |
| 14 | public EntityId $entityId, | |
| 15 | public HistoryWindow $window, | |
| 16 | public HistoryDetail $detail = HistoryDetail::StateChanges, | |
| 17 | ) {} | |
| 18 | ||
| 19 | public function type(): string | |
| 20 | { | |
| 21 | return 'history/history_during_period'; | |
| 22 | } | |
| 23 | ||
| 24 | public function describe(): string | |
| 25 | { | |
| 26 | return \sprintf('%s %s', $this->type(), $this->entityId->value); | |
| 27 | } | |
| 28 | ||
| 29 | public function toMessage(): array | |
| 30 | { | |
| 31 | return [ | |
| 32 | 'type' => $this->type(), | |
| 33 | 'start_time' => $this->window->startsAt->toIso8601(), | |
| 34 | 'end_time' => $this->window->endsAt->toIso8601(), | |
| 35 | 'entity_ids' => [$this->entityId->value], | |
| 36 | 'include_start_time_state' => true, | |
| 37 | 'significant_changes_only' => !$this->detail->includesAttributeOnlyChanges(), | |
| 38 | 'minimal_response' => !$this->detail->includesAttributes(), | |
| 39 | 'no_attributes' => !$this->detail->includesAttributes(), | |
| 40 | ]; | |
| 41 | } | |
| 42 | } |