tradfri

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	/** A "normal" remote */
	DeviceTypeRemote = iota
	/**
	 * A remote which has been paired with another remote.
	 * See https://www.reddit.com/r/tradfri/comments/6x1miq for details
	 */
	DeviceTypeSlaveRemote
	/** A lightbulb */
	DeviceTypeLightbulb
	/** A smart plug */
	DeviceTypePlug
	/** A motion sensor (currently unsupported) */
	DeviceTypeMotionSensor
	/** A signal repeater */
	DeviceTypeSignalRepeater
	/** A smart blind */
	DeviceTypeBlind
	/** Symfonisk Remote */
	DeviceTypeSoundRemote
)

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 int) (model.Device, error)

GetDevice gets the JSON representation of the specified device.

func (*Client) GetGroup

func (tc *Client) GetGroup(groupId int) (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) PutDeviceColor

func (tc *Client) PutDeviceColor(deviceId int, x, y int) (model.Result, error)

PutDeviceColor sets the CIE 1931 color space x/y color, x and y must be between 0-65536 but note that many combinations won't work. See CIE 1931 for more details. It is not recommended to use these values to set colors, as it is often not supported by the gateway and is intended for internal use.

func (*Client) PutDeviceColorHSL

func (tc *Client) PutDeviceColorHSL(deviceId int, 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 int, 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) PutDeviceColorRGB

func (tc *Client) PutDeviceColorRGB(deviceId int, rgb string) (model.Result, error)

PutDeviceColorRGB sets the color of the bulb using RGB hex string such as 8f2686 (purple). Note that It does not use the built in rgb hex parameter as that does not work reliably, so the rgb is converted to hsl and that is sent

func (*Client) PutDeviceColorRGBInt

func (tc *Client) PutDeviceColorRGBInt(deviceId int, r, g, b int) (model.Result, error)

PutDeviceColorRGBInt does about the same as PutDeviceColorRGB except you can directly pass the rgb instead of a hex string

func (*Client) PutDeviceColorRGBIntTimed

func (tc *Client) PutDeviceColorRGBIntTimed(deviceId int, r, g, b int, transitionTimeMS int) (model.Result, error)

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

func (*Client) PutDeviceColorRGBTimed

func (tc *Client) PutDeviceColorRGBTimed(deviceId int, rgb string, transitionTimeMS int) (model.Result, error)

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

func (*Client) PutDeviceColorTimed

func (tc *Client) PutDeviceColorTimed(deviceId int, x, y int, transitionTimeMS int) (model.Result, error)

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

func (*Client) PutDeviceDimming

func (tc *Client) PutDeviceDimming(deviceId int, 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 int, positioning float32) (model.Result, error)

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

func (*Client) PutDevicePower

func (tc *Client) PutDevicePower(deviceId int, power int) (model.Result, error)

PutDevicePower switches the power state of the specified device to on (1) or off (0)

func (*Client) PutDeviceState

func (tc *Client) PutDeviceState(deviceId int, power int, dimmer int) (model.Result, error)

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

Jump to

Keyboard shortcuts

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