go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/experiments/huectl/pkg/hue/rule.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package hue
     9  
    10  // Rule represents a bridge rule https://developers.meethue.com/documentation/rules-api
    11  type Rule struct {
    12  	Name           string           `json:"name,omitempty"`
    13  	LastTriggered  string           `json:"lasttriggered,omitempty"`
    14  	CreationTime   string           `json:"creationtime,omitempty"`
    15  	TimesTriggered int              `json:"timestriggered,omitempty"`
    16  	Owner          string           `json:"owner,omitempty"`
    17  	Status         string           `json:"status,omitempty"`
    18  	Conditions     []*RuleCondition `json:"conditions,omitempty"`
    19  	Actions        []*RuleAction    `json:"actions,omitempty"`
    20  	ID             int              `json:",omitempty"`
    21  }
    22  
    23  // RuleCondition defines the condition of a rule
    24  type RuleCondition struct {
    25  	Address  string `json:"address,omitempty"`
    26  	Operator string `json:"operator,omitempty"`
    27  	Value    string `json:"value,omitempty"`
    28  }
    29  
    30  // RuleAction defines the rule to execute when a rule triggers
    31  type RuleAction struct {
    32  	Address string      `json:"address,omitempty"`
    33  	Method  string      `json:"method,omitempty"`
    34  	Body    interface{} `json:"body,omitempty"`
    35  }