model

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MessageTypeAuthRequired      MessageType = "auth_required"
	MessageTypeAuth                          = "auth"
	MessageTypeAuthOK                        = "auth_ok"
	MessageTypeSubscribeEvents               = "subscribe_events"
	MessageTypeSubscribeTrigger              = "subscribe_trigger"
	MessageTypeEvent                         = "event"
	MessageTypePing                          = "ping"
	MessageTypeGetStates                     = "get_states"
	MessageTypeGetServices                   = "get_services"
	MessageTypeGetEntityRegistry             = "config/entity_registry/list"
	MessageTypeGetDeviceRegistry             = "config/device_registry/list"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Id       *string `json:"id"`
	ParentId *string `json:"parent_id"`
	UserId   *string `json:"user_id"`
}

type Data

type Data struct {
	EntityId *string `json:"entity_id"`
	NewState *State  `json:"new_state,omitempty"`
	OldState *State  `json:"old_state,omitempty"`
}

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type Event

type Event struct {
	Data      *Data      `json:"data,omitempty"`
	EventType EventType  `json:"event_type,omitempty"`
	TimeFired *time.Time `json:"time_fired,omitempty"`
	Origin    *string    `json:"origin,omitempty"`
	Context   *Context   `json:"context,omitempty"`
}

type EventType

type EventType string
const (
	EventTypeAll              EventType = "all"
	EventTypeState            EventType = "state"
	EventTypeStateChanged     EventType = "state_changed"
	EventTypeCallService      EventType = "call_service"
	EventTypePysScriptRunning EventType = "pyscript_running"
)

func (EventType) Valid

func (et EventType) Valid() bool

type Histories added in v0.2.3

type Histories []*History

func (*Histories) Get added in v0.2.3

func (hs *Histories) Get(domain, entity string) *History

type History added in v0.2.3

type History struct {
	Entity string
	Domain string
	Start  time.Time
	End    time.Time
	States []*State
}

type Message

type Message struct {
	ID          *int        `json:"id,omitempty"`
	Type        MessageType `json:"type"`
	AccessToken *string     `json:"access_token,omitempty"`
	Success     *bool       `json:"success,omitempty"`

	EventType *EventType `json:"event_type,omitempty"`

	Error         *Error                 `json:"error,omitempty"`
	Event         *Event                 `json:"event,omitempty"`
	Result        []Result               `json:"result,omitempty"`
	ServiceResult map[string]interface{} `json:"service_result,omitempty"`

	Raw []byte `json:"-"`
}

func ParseMessage

func ParseMessage(msgJson []byte) (Message, error)

func (*Message) Attributes

func (m *Message) Attributes() map[string]interface{}

func (*Message) Domain

func (m *Message) Domain() string

func (*Message) DomainEntity

func (m *Message) DomainEntity() string

func (*Message) EntityID

func (m *Message) EntityID() string

func (*Message) FriendlyName

func (m *Message) FriendlyName() string

func (*Message) OldAttributes

func (m *Message) OldAttributes() map[string]interface{}

func (*Message) OldState

func (m *Message) OldState() *string

func (*Message) State

func (m *Message) State() string

func (*Message) StateFloat

func (m *Message) StateFloat() (float64, error)

type MessageType

type MessageType string

func (MessageType) Valid

func (mt MessageType) Valid() bool

type OnAirQualityHandler

type OnAirQualityHandler func(message *Message, newAttrs, oldAttrs *entities.AirQuality)

type OnAlarmControlPanelHandler

type OnAlarmControlPanelHandler func(message *Message, newAttrs, oldAttrs *entities.AlarmControlPanel)

type OnBinarySensorHandler

type OnBinarySensorHandler func(message *Message, newAttrs, oldAttrs *entities.BinarySensor)

type OnButtonHandler

type OnButtonHandler func(message *Message, newAttrs, oldAttrs *entities.Button)

type OnCameraHandler

type OnCameraHandler func(message *Message, newAttrs, oldAttrs *entities.Camera)

type OnClimateHandler

type OnClimateHandler func(message *Message, newAttrs, oldAttrs *entities.Climate)

type OnCoverHandler

type OnCoverHandler func(message *Message, newAttrs, oldAttrs *entities.Cover)

type OnDeviceTrackerHandler

type OnDeviceTrackerHandler func(message *Message, newAttrs, oldAttrs *entities.DeviceTracker)

type OnEntityHandlers

type OnEntityHandlers map[string]func(message *Message)

func (OnEntityHandlers) Run

func (o OnEntityHandlers) Run(message *Message) bool

func (OnEntityHandlers) RunStates

func (o OnEntityHandlers) RunStates(message *Message)

type OnFanHandler

type OnFanHandler func(message *Message, newAttrs, oldAttrs *entities.Fan)

type OnHumidifierHandler

type OnHumidifierHandler func(message *Message, newAttrs, oldAttrs *entities.Humidifier)

type OnIntroductionHandler

type OnIntroductionHandler func(message *Message, newAttrs, oldAttrs *entities.Introduction)

type OnLightHandler

type OnLightHandler func(message *Message, newAttrs, oldAttrs *entities.Light)

type OnLockHandler

type OnLockHandler func(message *Message, newAttrs, oldAttrs *entities.Lock)

type OnMediaPlayerHandler

type OnMediaPlayerHandler func(message *Message, newAttrs, oldAttrs *entities.MediaPlayer)

type OnNumberHandler

type OnNumberHandler func(message *Message, newAttrs, oldAttrs *entities.Number)

type OnRemoteHandler

type OnRemoteHandler func(message *Message, newAttrs, oldAttrs *entities.Remote)

type OnSelectHandler

type OnSelectHandler func(message *Message, newAttrs, oldAttrs *entities.Select)

type OnSensorHandler

type OnSensorHandler func(message *Message, newAttrs, oldAttrs *entities.Sensor)

type OnSirenHandler

type OnSirenHandler func(message *Message, newAttrs, oldAttrs *entities.Siren)

type OnSwitchHandler

type OnSwitchHandler func(message *Message, newAttrs, oldAttrs *entities.Switch)

type OnTextHandler

type OnTextHandler func(message *Message, newAttrs, oldAttrs *entities.Text)

type OnTypeHandlers

type OnTypeHandlers struct {
	OnAirQuality        OnAirQualityHandler
	OnAlarmControlPanel OnAlarmControlPanelHandler
	OnBinarySensor      OnBinarySensorHandler
	OnButton            OnButtonHandler
	OnCamera            OnCameraHandler
	OnClimate           OnClimateHandler
	OnCover             OnCoverHandler
	OnDeviceTracker     OnDeviceTrackerHandler
	OnFan               OnFanHandler
	OnHumidifier        OnHumidifierHandler
	OnIntroduction      OnIntroductionHandler
	OnLight             OnLightHandler
	OnLock              OnLockHandler
	OnMediaPlayer       OnMediaPlayerHandler
	OnNumber            OnNumberHandler
	OnRemote            OnRemoteHandler
	OnSelect            OnSelectHandler
	OnSensor            OnSensorHandler
	OnSiren             OnSirenHandler
	OnSwitch            OnSwitchHandler
	OnText              OnTextHandler
	OnUpdate            OnUpdateHandler
	OnVacuum            OnVacuumHandler
	OnWaterHeater       OnWaterHeaterHandler
	OnWeather           OnWeatherHandler
}

func (*OnTypeHandlers) Run

func (o *OnTypeHandlers) Run(message *Message) bool

func (*OnTypeHandlers) RunStates

func (o *OnTypeHandlers) RunStates(message *Message)

type OnUpdateHandler

type OnUpdateHandler func(message *Message, newAttrs, oldAttrs *entities.Update)

type OnVacuumHandler

type OnVacuumHandler func(message *Message, newAttrs, oldAttrs *entities.Vacuum)

type OnWaterHeaterHandler

type OnWaterHeaterHandler func(message *Message, newAttrs, oldAttrs *entities.WaterHeater)

type OnWeatherHandler

type OnWeatherHandler func(message *Message, newAttrs, oldAttrs *entities.Weather)

type Result

type Result struct {
	EntityId    *string                `json:"entity_id,omitempty"`
	EntityState *string                `json:"state,omitempty"`
	Attributes  map[string]interface{} `json:"attributes,omitempty"`
	LastChanged *time.Time             `json:"last_changed,omitempty"`
	LastUpdated *time.Time             `json:"last_updated,omitempty"`
	Context     *Context               `json:"context,omitempty"`

	AreaId         *string     `json:"area_id"`
	ConfigEntryId  *string     `json:"config_entry_id"`
	DeviceId       *string     `json:"device_id"`
	DisabledBy     *string     `json:"disabled_by"`
	EntityCategory *string     `json:"entity_category"`
	HasEntityName  bool        `json:"has_entity_name"`
	HiddenBy       interface{} `json:"hidden_by"`
	Icon           *string     `json:"icon"`
	Id             string      `json:"id"`
	Name           *string     `json:"name"`
	Options        struct {
		SensorPrivate struct {
			SuggestedUnitOfMeasurement string `json:"suggested_unit_of_measurement"`
		} `json:"sensor.private,omitempty"`
	} `json:"options"`
	OriginalName   *string `json:"original_name"`
	Platform       string  `json:"platform"`
	TranslationKey *string `json:"translation_key"`
	UniqueId       string  `json:"unique_id"`

	ConfigurationUrl *string         `json:"configuration_url"`
	ConfigEntries    []string        `json:"config_entries"`
	Connections      [][]string      `json:"connections"`
	EntryType        *string         `json:"entry_type"`
	HwVersion        *string         `json:"hw_version"`
	Identifiers      [][]interface{} `json:"identifiers"`
	Manufacturer     *string         `json:"manufacturer"`
	Model            *string         `json:"model"`
	NameByUser       *string         `json:"name_by_user"`
	SwVersion        *string         `json:"sw_version"`
	ViaDeviceId      *string         `json:"via_device_id"`
}

func (*Result) Domain

func (r *Result) Domain() string

func (*Result) DomainEntity

func (r *Result) DomainEntity() string

func (*Result) EntityID

func (r *Result) EntityID() string

func (*Result) State

func (r *Result) State() string

type State

type State struct {
	EntityId    *string                `json:"entity_id,omitempty"`
	LastChanged *time.Time             `json:"last_changed,omitempty"`
	State       *string                `json:"state,omitempty"`
	Attributes  map[string]interface{} `json:"attributes,omitempty"`
	LastUpdated *time.Time             `json:"last_updated,omitempty"`
	Context     *Context               `json:"context,omitempty"`
}

func (*State) Domain added in v0.2.3

func (s *State) Domain() string

func (*State) Entity added in v0.2.3

func (s *State) Entity() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址