Skip to content

Commit

Permalink
First implementation for a DeCONZ Driver
Browse files Browse the repository at this point in the history
  • Loading branch information
splattner committed Sep 24, 2023
1 parent a6f8a60 commit c203776
Show file tree
Hide file tree
Showing 26 changed files with 1,478 additions and 26 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This [Unfolded Circle Remote Two](https://www.unfoldedcircle.com/) integration d
Currently this repository implements a driver for the following devices:

* Denon Audio/Video Reveiver
* [DeCONZ](https://dresden-elektronik.github.io/deconz-rest-doc/)

## Device / Clients

Expand All @@ -24,7 +25,9 @@ Run with `ucrt denon`

This client currently implements a [`MediaPlayer` entity](https://github.com/unfoldedcircle/core-api/blob/main/doc/entities/entity_media_player.md) and some [`Button` entities](https://github.com/unfoldedcircle/core-api/blob/main/doc/entities/entity_button.md)

### Deconz

Run with `ucrt deconz`

## How to use

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/mdns v1.0.5 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jurgen-kluft/go-conbee v0.0.0-20211124004556-1d2ff903ea59 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/miekg/dns v1.1.56 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jurgen-kluft/go-conbee v0.0.0-20211124004556-1d2ff903ea59 h1:f9Gn7xzl2wfNdlJ4slukOmX8LhOs9XflRDbaQxA/Onk=
github.com/jurgen-kluft/go-conbee v0.0.0-20211124004556-1d2ff903ea59/go.mod h1:nxv2+SfQy+RF9UzE0rnRpYJGVmBA1MQ45UxUgiOxdqg=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down
18 changes: 11 additions & 7 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ type Client struct {
// Called by RemoteTwo when the integration is added and setup started
setupFunc func()
// Handles connect/disconnect calls from RemoteTwo
clientLoopFunc func()
clientLoopFunc func()
setDriverUserDataFunc func(map[string]string, bool)
}

func NewClient(i *integration.Integration) *Client {
Expand All @@ -41,6 +42,13 @@ func NewClient(i *integration.Integration) *Client {
}

func (c *Client) InitClient() {

// Pass function to the integration driver that is called when the remote want to setup the driver
c.IntegrationDriver.SetHandleSetupFunction(c.HandleSetup)
// Pass function to the integration driver that is called when the remote want to setup the driver
c.IntegrationDriver.SetHandleConnectionFunction(c.HandleConnection)
c.IntegrationDriver.SetHandleSetDriverUserDataFunction(c.HandleSetDriverUserDataFunction)

// Call setup Function if its set
if c.initFunc != nil {
c.initFunc()
Expand Down Expand Up @@ -95,12 +103,8 @@ func (c *Client) HandleSetDriverUserDataFunction(userdata map[string]string, con
"Confim": confirm,
}).Debug(("Handle SetDriverUserData"))

if confirm {
c.IntegrationDriver.SetDriverSetupState(integration.StopEvent, integration.OkState, "", nil)
} else {
c.IntegrationDriver.SetDriverSetupState(integration.StopEvent, integration.OkState, "", nil)
// Confirm is not set.. Bug?
//c.IntegrationDriver.SetDriverSetupState(integration.SetupEvent, integration.WaitUserActionState, "", nil)
if c.setDriverUserDataFunc != nil {
c.setDriverUserDataFunc(userdata, confirm)
}

}
Expand Down
Loading

0 comments on commit c203776

Please sign in to comment.