-
Notifications
You must be signed in to change notification settings - Fork 1
/
switch.main.kts
executable file
·38 lines (30 loc) · 1.13 KB
/
switch.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
#!/usr/bin/env kotlin
@file:Repository("https://jitpack.io")
@file:DependsOn("com.github.dfrommi:rehaktor:master-SNAPSHOT")
import io.github.dfrommi.rehaktor.characteristics.OnCharacteristic
import io.github.dfrommi.rehaktor.core.HomekitAccessory
import io.github.dfrommi.rehaktor.core.auth.HomekitAuthService
import io.github.dfrommi.rehaktor.services.SwitchService
import io.github.hapjava.server.impl.HomekitServer
import reactor.core.publisher.DirectProcessor
import reactor.core.publisher.Flux
val loopbackProcessor = DirectProcessor.create<Boolean>()
val loopbackSink = loopbackProcessor.sink()
val fakeSwitch = HomekitAccessory(
100, "Fake Switch", listOf(
SwitchService(
OnCharacteristic(Flux.from(loopbackProcessor)) {
println("Setting fake switch to $it")
loopbackSink.next(it)
}
)
))
val authInfoService = HomekitAuthService()
val bridge = HomekitServer(9123).createBridge(
authInfoService, "Test Bridge", "Smart Home", "B2", "42", "A", "B"
)
bridge.addAccessory(fakeSwitch)
println("===============")
println("PIN: ${authInfoService.pin}")
println("===============")
bridge.start()