Skip to content

orktes/go-alexa-smarthome

Repository files navigation

go-alexa-smarthome

GoDoc

package main

import (
    "github.com/aws/aws-lambda-go/lambda"
    smarthome "github.com/orktes/go-alexa-smarthome"
)

type mockPropertyHandler struct {
	val interface{}
}

func (mockHandler *mockPropertyHandler) GetValue() (interface{}, error) {
    fmt.Printf("Getting value %+v\n", mockHandler.val)
	return mockHandler.val, nil
}

func (mockHandler *mockPropertyHandler) SetValue(val interface{}) error {
	fmt.Printf("Received value %+v\n", val)
	mockHandler.val = val
	return nil
}

func (mockHandler *mockPropertyHandler) UpdateChannel() <-chan interface{} {
	return nil
}

func main() {
	sm := smarthome.New(smarthome.AuthorizationFunc(func (req smarthome.AcceptGrantRequest) error {
	    return nil
	}))

	abstractTestDevice := smarthome.NewAbstractDevice(
		"1",
		"Fake switch",
		"Homeautomation",
		"Just a fake light",
	)
	abstractTestDevice.AddDisplayCategory("SWITCH")
	capability := abstractTestDevice.NewCapability("PowerController")
	capability.AddPropertyHandler("powerState", &mockPropertyHandler{val: "ON"})

	sm.AddDevice(abstractTestDevice)

	lambda.Start(sm.Handle)
}

TODO

Controllers

  • Authorization
  • CameraStreamController
  • ChannelController
  • ColorTemperatureController
  • Discovery
  • InputController
  • PercentageController
  • PowerController
  • SceneController
  • StateReport
  • TemperatureSensor
  • BrightnessController
  • ChangeReport
  • ColorController
  • DeferredResponse
  • ErrorResponse
  • LockController
  • PlaybackController
  • PowerLevelController
  • Speaker
  • StepSpeaker
  • ThermostatController

High level APIs (device abstractions)

  • Light
  • Switch
  • TV
  • Amplifier
  • Speaker
  • Temperature sensor

About

Handler for alexa smarthome v3 directives for golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages