tradfri

package
v0.0.0-...-e2aaeb7 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceTypeRemote = iota
	DeviceTypeSlaveRemote
	DeviceTypeLightbulb
	DeviceTypePlug
	DeviceTypeMotionSensor
	DeviceTypeSignalRepeater
	DeviceTypeBlind
	DeviceTypeSoundRemote
)

most of this is stolen shamelessly from eriklupander/tradfri-go/tradfri and adjusted for my needs

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides a declarative API for sending CoAP messages to the gateway over DTLS.

func NewTradfriClient

func NewTradfriClient(gatewayAddress, clientID, psk string) *Client

NewTradfriClient creates a new instance of Client, including initiating the DTLS client.

func (*Client) AuthExchange

func (tc *Client) AuthExchange(clientID string) (model.TokenExchange, error)

AuthExchange performs the initial PSK exchange. see ref: https://community.openhab.org/t/ikea-tradfri-gateway/26135/148?u=kai

func (*Client) Call

func (tc *Client) Call(msg coap.Message) (coap.Message, error)

Call is just a proxy to the underlying DtlsClient Call

func (*Client) Get

func (tc *Client) Get(id string) (coap.Message, error)

Get gets whatever is identified by the passed ID string.

func (*Client) GetDevice

func (tc *Client) GetDevice(deviceID string) (model.Device, error)

GetDevice gets the JSON representation of the specified device.

func (*Client) GetGroup

func (tc *Client) GetGroup(groupID string) (model.Group, error)

GetGroup gets the JSON representation of the specified group.

func (*Client) ListDeviceIds

func (tc *Client) ListDeviceIds() ([]int, error)

ListDeviceIds gives you a list of all connected device id's

func (*Client) ListDevices

func (tc *Client) ListDevices() ([]model.Device, error)

ListDevices gives you a list of all devices

func (*Client) ListGroups

func (tc *Client) ListGroups() ([]model.Group, error)

ListGroups lists all groups

func (*Client) Put

func (tc *Client) Put(id string, payload string) (coap.Message, error)

Put puts the payload for whatever is identified by the passed ID string.

func (*Client) PutDeviceColorHSL

func (tc *Client) PutDeviceColorHSL(deviceID string, hue float64, saturation float64, lightness float64) (model.Result, error)

PutDeviceColorHSL sets the color of the bulb using the HSL color notation This is more effictive than RGB because RGB is always at full brightness, ("000000" is the same as "ffffff")

func (*Client) PutDeviceColorHSLTimed

func (tc *Client) PutDeviceColorHSLTimed(deviceID string, hue float64, saturation float64, lightness float64, transitionTimeMS int) (model.Result, error)

PutDeviceColorHSLTimed does the same as PutDeviceColorHSL but it gives you the ability to change the speed at which the color changes

func (*Client) PutDeviceDimming

func (tc *Client) PutDeviceDimming(deviceID string, dimming int) (model.Result, error)

PutDeviceDimming sets the dimming property (0-255) of the specified device. The device must be a bulb supporting dimming, otherwise the call if ineffectual.

func (*Client) PutDevicePositioning

func (tc *Client) PutDevicePositioning(deviceID string, positioning float32) (model.Result, error)

PutDevicePositioning sets the positioning property (0-100) of the specified device.

func (*Client) PutDevicePower

func (tc *Client) PutDevicePower(deviceID string, power bool) (model.Result, error)

PutDevicePower switches the power state of the specified device

func (*Client) PutDeviceState

func (tc *Client) PutDeviceState(deviceID string, power bool, dimmer int) (model.Result, error)

PutDeviceState allows changing both power and dimmer (0-255) for a given device with one command.

type DevicePlatform

type DevicePlatform struct {
	Running bool
}

DevicePlatform is the handle to the devices on the bridge

func (DevicePlatform) AddAccessory

func (tdp DevicePlatform) AddAccessory(a *tfaccessory.TFAccessory)

AddAccessory is called to add individual accessories -- do not use directly

func (DevicePlatform) Background

func (tdp DevicePlatform) Background()

Background runs the TradfriDevice status pollers

func (DevicePlatform) GetAccessory

func (tdp DevicePlatform) GetAccessory(name string) (*tfaccessory.TFAccessory, bool)

GetAccessory returns a Tradfri Device accessory by name

func (DevicePlatform) Shutdown

func (tdp DevicePlatform) Shutdown() platform.Control

Shutdown the TradfriDevicePlatform -- never actually called

func (DevicePlatform) Startup

func (tdp DevicePlatform) Startup(c *config.Config) platform.Control

Startup the TradfriDevicePlatform -- never actually called

type Platform

type Platform struct {
	Running bool
}

Platform is the handle to the bridge

func (Platform) AddAccessory

func (tp Platform) AddAccessory(a *tfaccessory.TFAccessory)

AddAccessory is called to add a Tradfri bridge/gateway -- devices are enumerated automatically from it

func (Platform) Background

func (tp Platform) Background()

Background runs the background tasks for the bridges (none)

func (Platform) GetAccessory

func (tp Platform) GetAccessory(ip string) (*tfaccessory.TFAccessory, bool)

GetAccessory gets the bridge by IP address

func (Platform) Shutdown

func (tp Platform) Shutdown() platform.Control

Shutdown is called by the platform management to shut things down

func (Platform) Startup

func (tp Platform) Startup(c *config.Config) platform.Control

Startup is called by the platform management to start things up

Jump to

Keyboard shortcuts

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