forked from home-assistant/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into HA_Entity_Loading
- Loading branch information
Showing
14 changed files
with
210 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...omeassistant/companion/android/common/data/websocket/impl/entities/AssistPipelineEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.homeassistant.companion.android.common.data.websocket.impl.entities | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties | ||
|
||
data class AssistPipelineEvent( | ||
val type: String, | ||
val data: AssistPipelineEventData? | ||
) | ||
|
||
object AssistPipelineEventType { | ||
const val RUN_START = "run-start" | ||
const val RUN_END = "run-end" | ||
const val STT_START = "stt-start" | ||
const val STT_END = "stt-end" | ||
const val INTENT_START = "intent-start" | ||
const val INTENT_END = "intent-end" | ||
const val TTS_START = "tts-start" | ||
const val TTS_END = "tts-end" | ||
const val ERROR = "error" | ||
} | ||
|
||
interface AssistPipelineEventData | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
data class AssistPipelineRunStart( | ||
val pipeline: String, | ||
val language: String, | ||
val runnerData: Map<String, Any?> | ||
) : AssistPipelineEventData | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
data class AssistPipelineIntentStart( | ||
val engine: String, | ||
val language: String, | ||
val intentInput: String | ||
) : AssistPipelineEventData | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
data class AssistPipelineIntentEnd( | ||
val intentOutput: ConversationResponse | ||
) : AssistPipelineEventData |
20 changes: 20 additions & 0 deletions
20
common/src/main/java/io/homeassistant/companion/android/util/FlowUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.homeassistant.companion.android.util | ||
|
||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.conflate | ||
import kotlinx.coroutines.flow.transform | ||
|
||
/** | ||
* Emit the first value from a Flow, and then after the period has passed the last item emitted | ||
* by the Flow during that period (if different). This ensures throttling/debouncing but also | ||
* always receiving the first and last item of the Flow. | ||
* | ||
* From https://github.com/Kotlin/kotlinx.coroutines/issues/1446#issuecomment-1198103541 | ||
*/ | ||
fun <T> Flow<T>.throttleLatest(delayMillis: Long): Flow<T> = this | ||
.conflate() | ||
.transform { | ||
emit(it) | ||
delay(delayMillis) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.