@@ -2,15 +2,15 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
+
5
6
"github.com/brutella/hc"
6
7
"github.com/brutella/hc/accessory"
7
8
"github.com/brutella/hc/characteristic"
8
9
"github.com/brutella/hc/log"
9
10
"github.com/brutella/hc/service"
10
- "github.com/brutella/hc/util"
11
11
)
12
12
13
- func addInputSource (t * accessory.Television , id int , name string , inputSourceType int , storage util. Storage ) {
13
+ func addInputSource (t * accessory.Television , id int , name string , inputSourceType int ) {
14
14
in := service .NewInputSource ()
15
15
16
16
in .Identifier .SetValue (id )
@@ -22,15 +22,8 @@ func addInputSource(t *accessory.Television, id int, name string, inputSourceTyp
22
22
t .AddService (in .Service )
23
23
t .Television .AddLinkedService (in .Service )
24
24
25
- key := fmt .Sprintf ("input-%d" , id )
26
- if b , err := storage .Get (key ); err == nil && len (b ) > 0 {
27
- fmt .Println ("restore configured name" , string (b ))
28
- in .ConfiguredName .SetValue (string (b ))
29
- }
30
-
31
25
in .ConfiguredName .OnValueRemoteUpdate (func (str string ) {
32
26
fmt .Printf (" %s configured name => %s\n " , name , str )
33
- storage .Set (key , []byte (str ))
34
27
})
35
28
in .InputSourceType .OnValueRemoteUpdate (func (v int ) {
36
29
fmt .Printf (" %s source type => %v\n " , name , v )
@@ -143,11 +136,17 @@ func main() {
143
136
config := hc.Config {Pin : "12344321" , StoragePath : "./db" }
144
137
t , err := hc .NewIPTransport (config , acc .Accessory )
145
138
146
- addInputSource (acc , 1 , "HDMI 1" , characteristic .InputSourceTypeHdmi , t .Storage ())
147
- addInputSource (acc , 2 , "HDMI 2" , characteristic .InputSourceTypeHdmi , t .Storage ())
148
- addInputSource (acc , 3 , "Netflix" , characteristic .InputSourceTypeApplication , t .Storage ())
149
- addInputSource (acc , 4 , "YouTube" , characteristic .InputSourceTypeApplication , t .Storage ())
150
- addInputSource (acc , 5 , "Twitter" , characteristic .InputSourceTypeApplication , t .Storage ())
139
+ addInputSource (acc , 1 , "HDMI 1" , characteristic .InputSourceTypeHdmi )
140
+ addInputSource (acc , 2 , "HDMI 2" , characteristic .InputSourceTypeHdmi )
141
+ addInputSource (acc , 3 , "Netflix" , characteristic .InputSourceTypeApplication )
142
+ addInputSource (acc , 4 , "YouTube" , characteristic .InputSourceTypeApplication )
143
+ addInputSource (acc , 5 , "Twitter" , characteristic .InputSourceTypeApplication )
144
+ addInputSource (acc , 6 , "Composite Video" , characteristic .InputSourceTypeCompositeVideo )
145
+ addInputSource (acc , 7 , "S-Video" , characteristic .InputSourceTypeSVideo )
146
+ addInputSource (acc , 8 , "Component Video" , characteristic .InputSourceTypeComponentVideo )
147
+ addInputSource (acc , 9 , "Dvi" , characteristic .InputSourceTypeDvi )
148
+ addInputSource (acc , 10 , "Airplay" , characteristic .InputSourceTypeAirplay )
149
+ addInputSource (acc , 11 , "Usb" , characteristic .InputSourceTypeUsb )
151
150
152
151
if err != nil {
153
152
log .Info .Panic (err )
0 commit comments