forked from dfrommi/rehaktor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tv.main.kts
executable file
·57 lines (50 loc) · 2.74 KB
/
tv.main.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env kotlin
@file:Repository("https://jitpack.io")
@file:DependsOn("com.github.dfrommi:rehaktor:master-SNAPSHOT")
import io.github.dfrommi.rehaktor.characteristics.*
import io.github.dfrommi.rehaktor.core.HomekitAccessory
import io.github.dfrommi.rehaktor.core.auth.HomekitAuthService
import io.github.dfrommi.rehaktor.services.*
import io.github.hapjava.server.impl.HomekitServer
import reactor.core.publisher.Flux
val tv = HomekitAccessory(
200, "Television", listOf(
TelevisionService(
active = ActiveCharacteristic(Flux.just(ActiveCharacteristic.Enum.ACTIVE)) { println("Active = $it")},
activeIdentifier = ActiveIdentifierCharacteristic(Flux.just(1)) { println("Active input = $it") },
configuredName = ConfiguredNameCharacteristic("My TV"),
sleepDiscoveryMode = SleepDiscoveryModeCharacteristic(SleepDiscoveryModeCharacteristic.Enum.ALWAYS_DISCOVERABLE),
linkedServices = listOf(
InputSourceService(
configuredName = ConfiguredNameCharacteristic("Hdmi 1"),
inputSourceType = InputSourceTypeCharacteristic(InputSourceTypeCharacteristic.Enum.HDMI),
isConfigured = IsConfiguredCharacteristic(IsConfiguredCharacteristic.Enum.CONFIGURED),
currentVisibilityState = CurrentVisibilityStateCharacteristic(CurrentVisibilityStateCharacteristic.Enum.SHOWN),
identifier = IdentifierCharacteristic(1)
),
InputSourceService(
configuredName = ConfiguredNameCharacteristic("Netflix"),
inputSourceType = InputSourceTypeCharacteristic(InputSourceTypeCharacteristic.Enum.APPLICATION),
isConfigured = IsConfiguredCharacteristic(IsConfiguredCharacteristic.Enum.CONFIGURED),
currentVisibilityState = CurrentVisibilityStateCharacteristic(CurrentVisibilityStateCharacteristic.Enum.SHOWN),
identifier = IdentifierCharacteristic(2)
)
)
),
TelevisionSpeakerService(
active = ActiveCharacteristic(Flux.just(ActiveCharacteristic.Enum.ACTIVE)) {},
mute = MuteCharacteristic(Flux.just(false)) { println("Mute = $it") },
volume = VolumeCharacteristic(Flux.just(50)) { println("Volume = $it") },
volumeControlType = VolumeControlTypeCharacteristic(VolumeControlTypeCharacteristic.Enum.ABSOLUTE)
)
)
)
val authInfoService = HomekitAuthService()
val bridge = HomekitServer(9123).createBridge(
authInfoService, "Test Bridge", "Smart Home", "B2", "42", "A", "B"
)
bridge.addAccessory(tv)
println("===============")
println("PIN: ${authInfoService.pin}")
println("===============")
bridge.start()