github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/common/events/automation.go (about)

     1  // This file is part of the Smart Home
     2  // Program complex distribution https://github.com/e154/smart-home
     3  // Copyright (C) 2023, Filippov Alex
     4  //
     5  // This library is free software: you can redistribute it and/or
     6  // modify it under the terms of the GNU Lesser General Public
     7  // License as published by the Free Software Foundation; either
     8  // version 3 of the License, or (at your option) any later version.
     9  //
    10  // This library is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13  // Library General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Lesser General Public
    16  // License along with this library.  If not, see
    17  // <https://www.gnu.org/licenses/>.
    18  
    19  package events
    20  
    21  import (
    22  	"context"
    23  
    24  	"github.com/e154/smart-home/common"
    25  	m "github.com/e154/smart-home/models"
    26  )
    27  
    28  // Tasks
    29  // ------------------------------------------------
    30  
    31  type EventTaskCompleted struct {
    32  	Id  int64           `json:"id"`
    33  	Ctx context.Context `json:"ctx"`
    34  }
    35  
    36  // CommandEnableTask ...
    37  type CommandEnableTask struct {
    38  	Id int64 `json:"id"`
    39  }
    40  
    41  // CommandDisableTask ...
    42  type CommandDisableTask struct {
    43  	Id int64 `json:"id"`
    44  }
    45  
    46  // EventCreatedTaskModel ...
    47  type EventCreatedTaskModel struct {
    48  	Id int64 `json:"id"`
    49  }
    50  
    51  // EventRemovedTaskModel ...
    52  type EventRemovedTaskModel struct {
    53  	Id int64 `json:"id"`
    54  }
    55  
    56  // EventUpdatedTaskModel ...
    57  type EventUpdatedTaskModel struct {
    58  	Id int64 `json:"id"`
    59  }
    60  
    61  // EventTaskLoaded ...
    62  type EventTaskLoaded struct {
    63  	Id int64 `json:"id"`
    64  }
    65  
    66  // EventTaskUnloaded ...
    67  type EventTaskUnloaded struct {
    68  	Id int64 `json:"id"`
    69  }
    70  
    71  // Triggers
    72  // ------------------------------------------------
    73  
    74  type TriggerMessage struct {
    75  	Payload     interface{}      `json:"payload"`
    76  	TriggerName string           `json:"trigger_name"`
    77  	EntityId    *common.EntityId `json:"entity_id"`
    78  }
    79  
    80  type EventTriggerCompleted struct {
    81  	Id       int64            `json:"id"`
    82  	Args     *TriggerMessage  `json:"args"`
    83  	EntityId *common.EntityId `json:"entity_id,omitempty"`
    84  	Ctx      context.Context  `json:"ctx"`
    85  }
    86  
    87  // CommandEnableTrigger ...
    88  type CommandEnableTrigger struct {
    89  	Id int64 `json:"id"`
    90  }
    91  
    92  // CommandDisableTrigger ...
    93  type CommandDisableTrigger struct {
    94  	Id int64 `json:"id"`
    95  }
    96  
    97  // EventCallTrigger ...
    98  type EventCallTrigger struct {
    99  	Id  int64           `json:"id"`
   100  	Ctx context.Context `json:"ctx"`
   101  }
   102  
   103  // EventCreatedTriggerModel ...
   104  type EventCreatedTriggerModel struct {
   105  	Id int64 `json:"id"`
   106  }
   107  
   108  // EventRemovedTriggerModel ...
   109  type EventRemovedTriggerModel struct {
   110  	Id int64 `json:"id"`
   111  }
   112  
   113  // EventUpdatedTriggerModel ...
   114  type EventUpdatedTriggerModel struct {
   115  	Id int64 `json:"id"`
   116  }
   117  
   118  // EventTriggerLoaded ...
   119  type EventTriggerLoaded struct {
   120  	Id int64 `json:"id"`
   121  }
   122  
   123  // EventTriggerUnloaded ...
   124  type EventTriggerUnloaded struct {
   125  	Id int64 `json:"id"`
   126  }
   127  
   128  // Actions
   129  // ------------------------------------------------
   130  
   131  type EventActionCompleted struct {
   132  	Id  int64           `json:"id"`
   133  	Ctx context.Context `json:"ctx"`
   134  }
   135  
   136  // EventCallTaskAction ...
   137  type EventCallTaskAction struct {
   138  	Id   int64  `json:"id"`
   139  	Name string `json:"name"`
   140  }
   141  
   142  // EventCallAction ...
   143  type EventCallAction struct {
   144  	Id  int64           `json:"id"`
   145  	Ctx context.Context `json:"ctx"`
   146  }
   147  
   148  // EventAddedActionModel ...
   149  type EventAddedActionModel struct {
   150  	Id int64 `json:"id"`
   151  }
   152  
   153  // EventRemovedActionModel ...
   154  type EventRemovedActionModel struct {
   155  	Id int64 `json:"id"`
   156  }
   157  
   158  // EventUpdatedActionModel ...
   159  type EventUpdatedActionModel struct {
   160  	Id     int64     `json:"id"`
   161  	Action *m.Action `json:"action"`
   162  }
   163  
   164  // EventActionLoaded ...
   165  type EventActionLoaded struct {
   166  	Id int64 `json:"id"`
   167  }
   168  
   169  // EventActionUnloaded ...
   170  type EventActionUnloaded struct {
   171  	Id int64 `json:"id"`
   172  }
   173  
   174  // Conditions
   175  // ------------------------------------------------
   176  
   177  // EventAddedConditionModel ...
   178  type EventAddedConditionModel struct {
   179  	Id int64 `json:"id"`
   180  }
   181  
   182  // EventRemovedConditionModel ...
   183  type EventRemovedConditionModel struct {
   184  	Id int64 `json:"id"`
   185  }
   186  
   187  // EventUpdatedConditionModel ...
   188  type EventUpdatedConditionModel struct {
   189  	Id int64 `json:"id"`
   190  }