Skip to content

Commit

Permalink
Add panasonic
Browse files Browse the repository at this point in the history
  • Loading branch information
Laica-Lunasys committed Apr 11, 2024
1 parent 9371991 commit a5f3f9a
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 2 deletions.
126 changes: 126 additions & 0 deletions light/panasonic/hk9817/entry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package hk9817

import (
"errors"

"github.com/dash-app/remote-go/appliances"
"github.com/dash-app/remote-go/hex"
)

func (r *hk9817) Generate(req *appliances.Request) ([]*hex.HexCode, error) {
e := req.Light()
switch e.Action {
case "OFF":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x09, 0x2F, 0x26},
{0x2C, 0x52, 0x09, 0x2F, 0x26},
{0x2C, 0x52, 0x09, 0x2F, 0x26},
},
},
}, nil
case "ON":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x09, 0x2C, 0x25},
{0x2C, 0x52, 0x09, 0x2C, 0x25},
{0x2C, 0x52, 0x09, 0x2C, 0x25},
},
},
}, nil
case "NIGHT_LIGHT":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x09, 0x2E, 0x27},
{0x2C, 0x52, 0x09, 0x2E, 0x27},
{0x2C, 0x52, 0x09, 0x2E, 0x27},
},
},
}, nil
case "FAV":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x09, 0x2D, 0x24},
{0x2C, 0x52, 0x09, 0x2D, 0x24},
{0x2C, 0x52, 0x09, 0x2D, 0x24},
},
},
}, nil
case "COOL":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x39, 0x8A, 0xB3},
{0x2C, 0x52, 0x39, 0x8A, 0xB3},
{0x2C, 0x52, 0x39, 0x8A, 0xB3},
},
},
}, nil
case "WARM":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x39, 0x8B, 0xB2},
{0x2C, 0x52, 0x39, 0x8B, 0xB2},
{0x2C, 0x52, 0x39, 0x8B, 0xB2},
},
},
}, nil
case "DIM":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x39, 0x92, 0xAB},
{0x2C, 0x52, 0x39, 0x92, 0xAB},
{0x2C, 0x52, 0x39, 0x92, 0xAB},
},
},
}, nil
case "TO_BRIGHT":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x09, 0x2A, 0x23},
{0x2C, 0x52, 0x09, 0x2A, 0x23},
{0x2C, 0x52, 0x09, 0x2A, 0x23},
},
},
}, nil
case "TO_DIM":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x09, 0x2B, 0x22},
{0x2C, 0x52, 0x09, 0x2B, 0x22},
{0x2C, 0x52, 0x09, 0x2B, 0x22},
},
},
}, nil
case "TO_WARM":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x39, 0x91, 0xA8},
{0x2C, 0x52, 0x39, 0x91, 0xA8},
{0x2C, 0x52, 0x39, 0x91, 0xA8},
},
},
}, nil
case "TO_COOL":
return []*hex.HexCode{
{
Code: [][]int{
{0x2C, 0x52, 0x39, 0x90, 0xA9},
{0x2C, 0x52, 0x39, 0x90, 0xA9},
{0x2C, 0x52, 0x39, 0x90, 0xA9},
},
},
}, nil
}

return nil, errors.New("invalid command provided")
}
12 changes: 12 additions & 0 deletions light/panasonic/hk9817/remote.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package hk9817

import (
"github.com/dash-app/remote-go/appliances"
)

type hk9817 struct {
}

func New() appliances.RemoteController {
return &hk9817{}
}
58 changes: 58 additions & 0 deletions light/panasonic/hk9817/template.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package hk9817

import (
"github.com/dash-app/remote-go/appliances"
)

var Template = &appliances.Template{
Vendor: "panasonic",
Model: "hk9817",
Kind: appliances.LIGHT,
Light: &appliances.LightTemplate{
Mode: &appliances.ActionTemplate{
Type: appliances.LIST,
Default: "OFF",
List: &appliances.List{
Values: []interface{}{"OFF", "ON", "NIGHT_LIGHT", "FAV", "COOL", "WARM", "DIM"},
},
},
Brightness: &appliances.ActionTemplate{
Type: appliances.MULTIPLE,
Multiple: []*appliances.ActionTemplate{
{
Type: appliances.SHOT,
Shot: &appliances.Shot{
Value: "TO_DIM",
},
},
{
Type: appliances.SHOT,
Shot: &appliances.Shot{
Value: "TO_BRIGHT",
},
},
},
},
Color: &appliances.ActionTemplate{
Type: appliances.MULTIPLE,
Multiple: []*appliances.ActionTemplate{
{
Type: appliances.SHOT,
Shot: &appliances.Shot{
Value: "TO_COOL",
},
},
{
Type: appliances.SHOT,
Shot: &appliances.Shot{
Value: "TO_WARM",
},
},
},
},
},
}

func (r *hk9817) Template() *appliances.Template {
return Template
}
6 changes: 4 additions & 2 deletions remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/dash-app/remote-go/appliances"
"github.com/dash-app/remote-go/light/hitachi/ira03h"
"github.com/dash-app/remote-go/light/odelic/rc701w"
"github.com/dash-app/remote-go/light/panasonic/hk9817"
)

// VendorSet - Remote Controller Identifier
Expand Down Expand Up @@ -42,8 +43,9 @@ func Init() *Remote {
{Vendor: "panasonic", Model: "panasonic01"}: panasonic01.New(),
},
light: map[VendorSet]appliances.RemoteController{
{Vendor: "hitachi", Model: "ir-a03h"}: ira03h.New(),
{Vendor: "odelic", Model: "rc701w"}: rc701w.New(),
{Vendor: "hitachi", Model: "ir-a03h"}: ira03h.New(),
{Vendor: "odelic", Model: "rc701w"}: rc701w.New(),
{Vendor: "panasonic", Model: "hk9817"}: hk9817.New(),
},
}
}
Expand Down

0 comments on commit a5f3f9a

Please sign in to comment.