rules

package
v0.0.0-...-db03bfd Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package rules defines the generic rules engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Topic   string
	Payload string
}

Command is an MQTT message to send to take action.

Most commands shall respect the Homie convention. https://github.com/marvinroger/homie

func (*Command) ToMsg

func (c *Command) ToMsg() msgbus.Message

ToMsg converts the command to a MQTT Message.

func (*Command) Validate

func (c *Command) Validate() error

Validate ensures the command is valid.

type Rule

type Rule struct {
	Signal Signal
	Cmd    Command
}

Rule defines a signal that triggers a command.

func Default

func Default() []Rule

Default returns default rules that can be set on a fresh instance.

type Rules

type Rules map[string]Rule

Rules is named rules.

type Signal

type Signal string

Signal defines what signal triggers this rule.

TODO(maruel): Define the language.

func (Signal) Eval

func (s Signal) Eval(input string) bool

Eval evaluates if a signal is a trigger for this rule.

Jump to

Keyboard shortcuts

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