Documentation ¶
Overview ¶
Package wemo ... Copyright 2014 Matt Ho
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package wemo ... Copyright 2014 Matt Ho
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package wemo ...
Copyright 2014 Matt Ho
// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
Package wemo ... Copyright 2014 Matt Ho
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package wemo ... Copyright 2014 Matt Ho
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package wemo ...
Copyright 2014 Matt Ho
// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
Index ¶
- Constants
- func Listener(listenerAddress string, cs chan SubscriptionEvent)
- type BulbStatusList
- type Device
- func (d *Device) Bulb(id, cmd, value string, group bool) error
- func (d *Device) FetchDeviceInfo(ctx context.Context) (*DeviceInfo, error)
- func (d *Device) GetBinaryState() int
- func (d *Device) GetBridgeEndDevices(uuid string) *EndDevices
- func (d *Device) GetBulbStatus(ids string) (map[string]string, error)
- func (d *Device) GetInsightParams() *InsightParams
- func (d *Device) ManageSubscription(listenerAddress string, timeout int, ...) (string, int)
- func (d *Device) Off()
- func (d *Device) On()
- func (d *Device) ReSubscribe(sid, address string, timeout int) (string, int)
- func (d *Device) SetState(newState bool) error
- func (d *Device) Subscribe(listenerAddress, address, path string, timeout int) (string, int)
- func (d *Device) Toggle()
- func (d *Device) UnSubscribe(sid, address string) int
- type DeviceInfo
- type DeviceInfos
- type DeviceStatus
- type Deviceevent
- type EndDeviceInfo
- type EndDevices
- type InsightParams
- type StateEvent
- type SubscriptionEvent
- type SubscriptionInfo
- type Wemo
- func (w *Wemo) Discover(urn string, timeout time.Duration) ([]*Device, error)
- func (w *Wemo) DiscoverAll(timeout time.Duration) ([]*Device, error)
- func (w *Wemo) Off(friendlyName string, timeout time.Duration)
- func (w *Wemo) On(friendlyName string, timeout time.Duration)
- func (w *Wemo) SetSourcePort(sourcePort uint16)
- func (w *Wemo) Toggle(friendlyName string, timeout time.Duration)
Constants ¶
const ( Basic = "urn:Belkin:service:basicevent:1" Bridge = "urn:Belkin:device:bridge:1" Controllee = "urn:Belkin:device:controllee:1" Light = "urn:Belkin:device:light:1" Sensor = "urn:Belkin:device:sensor:1" NetCam = "urn:Belkin:device:netcam:1" Insight = "urn:Belkin:device:insight:1" )
Constants for URNS
const ( SSDPBROADCAST = "239.255.255.250:1900" MSEARCH = "" /* 146-byte string literal not displayed */ LOCATION = "LOCATION: " )
Constants associated with Scanning
Variables ¶
This section is empty.
Functions ¶
func Listener ¶
func Listener(listenerAddress string, cs chan SubscriptionEvent)
Listener Listen for incomming subscribed state changes.
Types ¶
type BulbStatusList ¶
type BulbStatusList struct {
DeviceStatus []DeviceStatus `xml:"Body>GetDeviceStatusResponse>DeviceStatusList>DeviceStatusList>DeviceStatus"`
}
BulbStatusList ...
type Device ¶
Device struct
func (*Device) FetchDeviceInfo ¶
func (d *Device) FetchDeviceInfo(ctx context.Context) (*DeviceInfo, error)
FetchDeviceInfo from device
func (*Device) GetBridgeEndDevices ¶
func (d *Device) GetBridgeEndDevices(uuid string) *EndDevices
GetBridgeEndDevices ...
func (*Device) GetBulbStatus ¶
GetBulbStatus return map of [DeviceID]status values, function returns a map of deviceid to status as it is possible to have several DeviceID results returned.
func (*Device) GetInsightParams ¶
func (d *Device) GetInsightParams() *InsightParams
GetInsightParams ...
func (*Device) ManageSubscription ¶
func (d *Device) ManageSubscription(listenerAddress string, timeout int, subscriptions map[string]*SubscriptionInfo) (string, int)
ManageSubscription Manage firstly the subscription and then the resubscription of this device.
func (*Device) ReSubscribe ¶
ReSubscribe The subscription to the device must be renewed before the timeout. Return the Subscription ID (sid) and StatusCode
func (*Device) SetState ¶
SetState is a wrapper for changeState, which allows errors to be exposed to caller.
func (*Device) Subscribe ¶
Subscribe to the device event emitter, return the Subscription ID (sid) and StatusCode
func (*Device) UnSubscribe ¶
UnSubscribe According to the spec all subscribers must unsubscribe when the publisher is no longer required to provide state updates. Return the StatusCode
type DeviceInfo ¶
type DeviceInfo struct { Device *Device `json:"-"` DeviceType string `xml:"deviceType" json:"device-type"` FriendlyName string `xml:"friendlyName" json:"friendly-name"` MacAddress string `xml:"macAddress" json:"mac-address"` FirmwareVersion string `xml:"firmwareVersion" json:"firmware-version"` SerialNumber string `xml:"serialNumber" json:"serial-number"` UDN string `xml:"UDN" json:"UDN"` EndDevices EndDevices }
DeviceInfo struct
type DeviceInfos ¶
type DeviceInfos []*DeviceInfo
DeviceInfos slice
func (DeviceInfos) Len ¶
func (d DeviceInfos) Len() int
func (DeviceInfos) Less ¶
func (d DeviceInfos) Less(i, j int) bool
func (DeviceInfos) Swap ¶
func (d DeviceInfos) Swap(i, j int)
type DeviceStatus ¶
type DeviceStatus struct { DeviceID string `xml:"DeviceID"` CapabilityValue string `xml:"CapabilityValue"` }
DeviceStatus ...
type Deviceevent ¶
type Deviceevent struct { XMLName xml.Name `xml:"propertyset"` BinaryState string `xml:"property>BinaryState"` StateEvent StateEvent `xml:"property>StatusChange>StateEvent"` }
Deviceevent Structure for XML to Parse to
type EndDeviceInfo ¶
type EndDeviceInfo struct { DeviceIndex string `xml:"DeviceIndex"` DeviceID string `xml:"DeviceID"` FriendlyName string `xml:"FriendlyName"` FirmwareVersion string `xml:"FirmwareVersion"` CapabilityIDs string `xml:"CapabilityIDs"` CurrentState string `xml:"CurrentState"` Manufacturer string `xml:"Manufacturer"` ModelCode string `xml:"ModelCode"` ProductName string `xml:"productName"` WeMoCertified string `xml:"WeMoCertified"` }
EndDeviceInfo ...
type EndDevices ¶
type EndDevices struct { DeviceListType string `xml:"Body>GetEndDevicesResponse>DeviceLists>DeviceLists>DeviceList>DeviceListType"` EndDeviceInfo []EndDeviceInfo `xml:"Body>GetEndDevicesResponse>DeviceLists>DeviceLists>DeviceList>DeviceInfos>DeviceInfo"` }
EndDevices ...
type StateEvent ¶
type StateEvent struct { DeviceID string `xml:"DeviceID"` CapabilityID string `xml:"CapabilityId"` Value string `xml:"Value"` }
StateEvent ...
type SubscriptionEvent ¶
type SubscriptionEvent struct { Sid string Deviceevent Deviceevent }
SubscriptionEvent Structure for sending subscribed event data with
type SubscriptionInfo ¶
type SubscriptionInfo struct { DeviceInfo Timeout int Sid string Host string Deviceevent Deviceevent }
SubscriptionInfo struct
type Wemo ¶
type Wemo struct { Debug bool // contains filtered or unexported fields }
Wemo ...
func NewByInterface ¶
NewByInterface find the ip address associated with the specified interface
func (*Wemo) DiscoverAll ¶
DiscoverAll ...