-
-
Notifications
You must be signed in to change notification settings - Fork 144
Changes for Home assistant support #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mretallack
wants to merge
42
commits into
DicioTeam:main
Choose a base branch
from
mretallack:changes-for-ha
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 35 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
0a4bda6
initial changes for HA
mretallack 95c20aa
inital version
mretallack 588c679
fixes
mretallack 7cd06f5
more fixes
mretallack 5fe39f5
changes
mretallack 53c02b3
Fixes for first working version
markretallack 7459802
Added more tests
markretallack 69d38bc
Added persion location
markretallack 07c9e2a
Added docs
markretallack b0338a6
remove unwanted Files
markretallack 0e13e58
Remove unwanted files
markretallack 74c7322
Added import and export support
mretallack 31b8cc0
Add Home Assistant help command with comprehensive usage examples
mretallack 1a139dc
Merge remote-tracking branch 'upstream/master' into changes-for-ha
mretallack 0b2a42a
Add requirements spec for Home Assistant media source control
mretallack 6fa92c8
Add design document for Home Assistant media source control
mretallack a9cb98b
Update design with API research findings and callService extension
mretallack 7e734fd
Add comprehensive unit and integration testing specifications
mretallack cd5a659
Add investigation findings: fuzzy matching, entity mapping, UI design
mretallack 433d206
Add references to investigation documents in design.md
mretallack 55e12a1
Resolve all remaining unknowns: threshold, generated class, ambiguous…
mretallack a0a9a4c
Add fuzzy matching algorithm tests - 20/20 tests pass with real data
mretallack 6985ccd
Add implementation tasks document with 8 phases and 35 tasks
mretallack 9de0af8
Add Home Assistant media player source selection feature
mretallack 8283bd5
Fix UI text for select source success message
mretallack eac7536
Add number variation approach to HA media source spec
mretallack 713d694
Implement number variation handling for HA media source selection
mretallack f39776f
Merge pull request #1 from mretallack/changes-for-ha-dev
mretallack 6214813
Docs: Update Home Assistant skill description
mretallack b674f1d
Merge master into changes-for-ha
mretallack 958b4cf
Fix: Update Home Assistant tests for new API
mretallack a69152c
Fix: Home Assistant tests now pass with TestSkillContext
mretallack 9bd2ab8
Chore: Move .kiro directory to local-only
mretallack 322d009
Docs: Move SETUP.md to docs/skills/home-assistant.md
mretallack ad2eaee
Docs: Remove reference to non-existent .amazonq file
mretallack 13b414f
Merge branch 'master' into changes-for-ha
mretallack a54f98b
Changes after review
mretallack 28705ca
Fix: address easy PR review feedback
mretallack fbc9b63
Refactor: address medium and higher complexity PR review feedback
mretallack c44aeb1
Refactor: remove HA-specific import/export
mretallack 40734e2
Docs: remove HA docs, moved to DicioTeam/docs repo
mretallack 872fff1
Merge pull request #2 from mretallack/changes-for-ha-review-feedback
mretallack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -15,3 +15,6 @@ | |
| fastlane/report.xml | ||
| fastlane/README.md | ||
| fastlane_config.txt | ||
|
|
||
| # Kiro specs (local only) | ||
| .kiro/ | ||
This file contains hidden or 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 hidden or 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 hidden or 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
63 changes: 63 additions & 0 deletions
63
app/src/main/kotlin/org/stypox/dicio/skills/homeassistant/HomeAssistantApi.kt
This file contains hidden or 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,63 @@ | ||
| package org.stypox.dicio.skills.homeassistant | ||
|
|
||
| import org.json.JSONArray | ||
| import org.json.JSONObject | ||
| import org.stypox.dicio.util.ConnectionUtils | ||
| import java.io.IOException | ||
| import java.net.HttpURLConnection | ||
| import java.net.URL | ||
|
|
||
| object HomeAssistantApi { | ||
| @Throws(IOException::class) | ||
| suspend fun getAllStates(baseUrl: String, token: String): JSONArray { | ||
| val connection = URL("$baseUrl/api/states").openConnection() as HttpURLConnection | ||
|
mretallack marked this conversation as resolved.
Outdated
|
||
| connection.setRequestProperty("Authorization", "Bearer $token") | ||
| connection.setRequestProperty("Content-Type", "application/json") | ||
|
|
||
| val scanner = java.util.Scanner(connection.inputStream) | ||
| val response = scanner.useDelimiter("\\A").next() | ||
| scanner.close() | ||
|
|
||
| return JSONArray(response) | ||
| } | ||
|
|
||
| @Throws(IOException::class) | ||
| suspend fun getEntityState(baseUrl: String, token: String, entityId: String): JSONObject { | ||
| val connection = URL("$baseUrl/api/states/$entityId").openConnection() as HttpURLConnection | ||
| connection.setRequestProperty("Authorization", "Bearer $token") | ||
| connection.setRequestProperty("Content-Type", "application/json") | ||
|
|
||
| val scanner = java.util.Scanner(connection.inputStream) | ||
| val response = scanner.useDelimiter("\\A").next() | ||
| scanner.close() | ||
|
|
||
| return JSONObject(response) | ||
| } | ||
|
|
||
| @Throws(IOException::class) | ||
| suspend fun callService( | ||
| baseUrl: String, | ||
| token: String, | ||
| domain: String, | ||
| service: String, | ||
| entityId: String, | ||
| extraParams: Map<String, String> = emptyMap() | ||
| ): JSONArray { | ||
| val connection = URL("$baseUrl/api/services/$domain/$service").openConnection() as HttpURLConnection | ||
| connection.requestMethod = "POST" | ||
| connection.setRequestProperty("Authorization", "Bearer $token") | ||
| connection.setRequestProperty("Content-Type", "application/json") | ||
| connection.doOutput = true | ||
|
|
||
| val body = JSONObject().put("entity_id", entityId) | ||
| extraParams.forEach { (key, value) -> body.put(key, value) } | ||
|
|
||
| connection.outputStream.write(body.toString().toByteArray()) | ||
|
|
||
| val scanner = java.util.Scanner(connection.inputStream) | ||
| val response = scanner.useDelimiter("\\A").next() | ||
| scanner.close() | ||
|
|
||
| return JSONArray(response) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.