Skip to content

Commit

Permalink
Support odelic light (+ RAW Signal Support)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laica-Lunasys committed Mar 29, 2021
1 parent 5e276b3 commit ce3347a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 34 deletions.
57 changes: 30 additions & 27 deletions frontend/dash-home/src/light/Light.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,37 @@ export const LightPanel: React.FC<ControllerProps> = props => {
<HR />
<Row>
{/* Bightness */}
<Contents>
<SummonByTpl
title={
<Icon icon={["fas", "sun"]} />
}
description={t("controller.light.brightness.name")}
i18nKey="controller.light.brightness"
value={""}
setter={(e: any) => light!.action = e}
sender={(after: any) => update({ ...light! }, after)}
action={props.template?.light?.brightness!}
/>
</Contents>

{props.template?.light?.brightness &&
<Contents>
<SummonByTpl
title={
<Icon icon={["fas", "sun"]} />
}
description={t("controller.light.brightness.name")}
i18nKey="controller.light.brightness"
value={""}
setter={(e: any) => light!.action = e}
sender={(after: any) => update({ ...light! }, after)}
action={props.template?.light?.brightness!}
/>
</Contents>
}
{/* Color */}
<Contents>
<SummonByTpl
title={
<Icon icon={["fas", "adjust"]} />
}
description={t("controller.light.color.name")}
i18nKey="controller.light.color"
value={""}
setter={(e: any) => light!.action = e}
sender={(after: any) => update({ ...light! }, after)}
action={props.template?.light?.color!}
/>
</Contents>
{props.template?.light?.color &&
<Contents>
<SummonByTpl
title={
<Icon icon={["fas", "adjust"]} />
}
description={t("controller.light.color.name")}
i18nKey="controller.light.color"
value={""}
setter={(e: any) => light!.action = e}
sender={(after: any) => update({ ...light! }, after)}
action={props.template?.light?.color!}
/>
</Contents>
}
</Row>
</LightCard>
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/dash-app/remote-go v0.0.0-20210222083255-1b0a70213e08
github.com/dash-app/remote-go v0.0.3
github.com/gin-contrib/cors v1.3.1
github.com/gin-contrib/static v0.0.0-20200916080430-d45d9a37d28e
github.com/gin-gonic/gin v1.6.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ github.com/dash-app/remote-go v0.0.0-20210218130152-0194225df821 h1:K/Lb87ByH1t2
github.com/dash-app/remote-go v0.0.0-20210218130152-0194225df821/go.mod h1:NDeDX5ytimaP0cjt4kj7m/3stnbWokHKSgN7cZY5ZdA=
github.com/dash-app/remote-go v0.0.0-20210222083255-1b0a70213e08 h1:0LSnyAqOGcew48dTdpMpehDSopdh37i2Uit90Pc3B6c=
github.com/dash-app/remote-go v0.0.0-20210222083255-1b0a70213e08/go.mod h1:NDeDX5ytimaP0cjt4kj7m/3stnbWokHKSgN7cZY5ZdA=
github.com/dash-app/remote-go v0.0.3 h1:0qQSpzkqn1Y+4oAJLey0ZbF373iJ8uEsOIU1eELXZtM=
github.com/dash-app/remote-go v0.0.3/go.mod h1:NDeDX5ytimaP0cjt4kj7m/3stnbWokHKSgN7cZY5ZdA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
22 changes: 16 additions & 6 deletions pkg/agent/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Payload struct {
Interval int `json:"interval,omitempty"`
}

func (as *AgentService) SendIR(ctx context.Context, hex []*hex.HexCode) error {
func (as *AgentService) SendIR(ctx context.Context, h []*hex.HexCode) error {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()

Expand All @@ -42,11 +42,21 @@ func (as *AgentService) SendIR(ctx context.Context, hex []*hex.HexCode) error {
// return errors.New("agent is not online")
//}
var payload []Payload
for _, code := range hex {
payload = append(payload, Payload{
Signal: aeha.SignalToCode(430, code.Code, 13300),
Interval: code.Interval,
})
for _, code := range h {
switch code.Format {
default:
fallthrough
case hex.AEHA:
payload = append(payload, Payload{
Signal: aeha.SignalToCode(430, code.Code, 13300),
Interval: code.Interval,
})
case hex.RAW:
payload = append(payload, Payload{
Signal: code.Raw,
Interval: code.Interval,
})
}
}

// Marshal codes
Expand Down

0 comments on commit ce3347a

Please sign in to comment.