Commit graph

405 commits

Author SHA1 Message Date
Zee Aslam f006127b01
add new sensor for ip6 addresses (#4202)
* add new sensor (draft 1)

* run ktlintcheck

* add docs link and update sensor params

* fix loose ends

* fix toString not nested correctly

* fix unit of measurement

* fix not adding to list

* fix typo that allowed ipv4 addresses to slip in
2024-02-22 17:02:13 -05:00
adam5532 ea79b6ae1f
Fixed spelling of compound verbs "set up", "log in", and "log out". Fixed "comma splice". Fixed double space. (#4196) 2024-02-11 08:28:43 -05:00
dependabot[bot] 15b1518a44
Bump org.jlleitschuh.gradle.ktlint from 11.6.1 to 12.1.0 (#4125)
* Bump org.jlleitschuh.gradle.ktlint from 11.6.1 to 12.1.0

Bumps org.jlleitschuh.gradle.ktlint from 11.6.1 to 12.1.0.

---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle.ktlint
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Add .editorconfig

* ktlintFormat

* Fix comment in a 'value_argument_list' is only allowed when placed on a separate line

* Restore AssistShortcutView

* Fix comment in a 'value_argument_list' is only allowed when placed on a separate line

* Fix no comment expected at this location

* Fix property name should start with a lowercase letter and use camel case

* Fix parameter comments

* Fix comment in a 'value_argument_list' is only allowed when placed on a separate line, again

* Fix property name should use the screaming snake case notation when the value can not be changed

* Fix final comment in argument list

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joris Pelgröm <joris.pelgrom@gmail.com>
2024-02-06 21:02:39 -05:00
Joris Pelgröm 98f3d7abd2
Add option to update camera & template tile when 'in view' (#4185)
* Add option to update camera & template tile 'on view'

 - Use the tile enter callback to request an update to the tile once it enters the view. Considering that this callback exists it's probably safe to assume an update that is requested in this callback won't be throttled (at least it appears to work during testing).
 - Minor edit to the refresh interval picker to ensure strings that are more than one line look a bit nicer.

* on view -> in view
2024-02-02 16:44:22 -05:00
Joris Pelgröm 09ca68e061
Fix lint warning for database/db function parameter name (#4178)
- Fixes the following warning x23: /home-assistant-android/common/src/main/java/io/homeassistant/companion/android/database/AppDatabase.kt:838:34 The corresponding parameter in the supertype 'Migration' is named 'db'. This may cause problems when calling this function with named arguments.
2024-02-02 15:28:12 -05:00
Márton Maráz c185b871fd
Make volume sensors update instantly by subscribing to a broadcast (#4162)
* Make volume sensors update instantly by subscribing to a broadcast

* Change skippableActions to a 1-to-many map and the list of all volume sensors to the corresponding Intent action key
2024-02-02 15:25:55 -05:00
Joris Pelgröm c6ddca8fdc
Support image entity in camera widget (now renamed picture widget) (#4159)
- Allow selecting image entities in the camera widget
 - Rename camera widget to picture widget to better reflect camera + image entity support
2024-01-25 17:02:51 -05:00
Sebastian Lövdahl 5d52735e36
Support multiple Template tiles on Wear OS (#3783)
* Support multiple Template tiles on Wear OS

* Add `TemplateTileConfig` data class

* Fix migration

* `Pair` -> `TemplateTileConfig` fixes

* Fix `getAllTemplateTiles` implementation

* Initial work on companion <-> wearable device communication

* More work on phone <-> wear device communication

* Save updated template in phone app

* Get the template to render using the right method

* Fix CI complaints

* Work on Wear UI for multiple template tiles

* Update wear manifest

* Wear migration and navigation fixes

* Fix Template tile IDs in mobile app

* Make adding a new Template tile on Wear device work

* Small cleanups and TODO fixes

* Try to fix template config refresh in settings

* Fix after rebase

* Adopt blocking approach for reacting to tile events, inspired by #3974

* Use `OpenTileSettingsActivity` for template tile

* Adopt Material 3 and other UI-related changes

* Show help text in phone app if no template tiles have been added yet

* Reference the view model variable inside the function

By having the view model variable outside the block, the updated template tile
might not be propagated to the template settings view.

* Reload template tiles when opening the template tiles from settings

* Replace null key with -1 for old template tile

* Lint complaints fixes

* remove TODO

* Store error

* Scrollable list of template tiles

* Move "Configure template tile" to header

* Replace with methods with copy

* Show template as secondary text

* Fix scrolling

* Update app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt

Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>

* Remove unused field

* Move padding to "no tiles" text

* Add deep link

---------

Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
2024-01-24 10:56:39 -05:00
Joris Pelgröm a5efe6a9ab
Support for Thread "import credentials" from frontend (#4128)
* Support for Thread "import credentials" frontend action

 - Add support for the frontend action to import Thread credentials, or better said export Thread credentials from the device. This is essentially a very basic sync.

* Rename/reorder reused Matter code

 - Change names and order of reused Matter code for Thread importing to prevent potential confusion

* Update minimal implementation
2024-01-12 09:20:57 -05:00
Joris Pelgröm f1fcabb0c9
Send IP address of Matter device for on network commissioning (#4069)
* [WIP] Send IP of device during commissioning

* Add version check for IP address in commission_on_network

* Update minimal
2024-01-04 14:29:19 -05:00
Steffen Klee e0731c9c79
Add Wear OS TLS client certificate authentication (TLS CCA) support (#3924)
* Add Wear OS TLS client certificate authentication (TLS CCA) support

Wear OS does not currently allow the user to install certificates to the
system-wide KeyChain for TLS CCA support. This commit adds support for
using certificates from the app-specific Android KeyStore with UI for
setting up a certificate during the Wear OS onboarding process.
The manual step in the onboarding process is required since we cannot
transmit certificates of the Android KeyChain because they are not
extractable.

In particular, this commit adds the following changes:
* KeyStoreImpl as an additional KeyChainRepository interface
  implementation for loading and storing keys to the application's
  KeyStore. TLSHelper uses KeyStoreImpl as a fallback key manager.
* UI for selecting a certificate file with GET_CONTENT intent during
  Wear OS onboarding in OnboardingActivity if it is detected that the
  Home Assistant may require TLS CCA. The UI includes a password check
  for the PKCS12 container.
* During onboarding the app sends the raw PKCS12 data to Wear OS
  together with the container password. The connection is assumed to be
  encrypted and trusted so that no additional encryption is necessary.

* Move PKCS12 password check to lifecycle scope

* Remove redundant try-catch when loading PKCS12

* Simplify MobileAppIntegrationView layout code
2023-12-13 15:19:54 -05:00
Joseph Abbey 6b56bc579a
mobile_app_notification_cleared for wearos (#4035)
* mobile_app_notification_cleared for wearos

* Fix imports

* Remove database id extra

* Fix whitespace

* Reformatted imports and added the receiver to the manifest

* Move `handleDeleteIntent` to common
2023-12-13 14:45:46 -05:00
Kostas Chatzikokolakis 52b0f4a6d7
Set the default BLE transmitter minor value to 40004 (#4027)
This value is whitelisted by the ibeacon integration to ensure the beacon
is processed even without a name.
2023-11-25 12:14:17 -05:00
Yuri Schimke da43981208
Better Wear Check (#4024) 2023-11-25 12:12:21 -05:00
Ruben van Dijk f5886dce1a
Added a sensor to detect if the hotspot is enabled. (#4012)
* Added a sensor to detect if the hotspot is enabled.

* Validate if we aren't running a watch before showing hotspot sensor.

* Fixed code style issues with the linter.

* Fix instant update for hotspot-sensor.

* Update hotspot icon to access-point instead of wifi.
2023-11-22 12:54:06 -05:00
Joris Pelgröm ac7ba33ae7
Show server name in "Unable to connect to Home Assistant" dialog (#3995)
- Shows the server name instead of a generic "Home Assistant" to prevent confusion when the app cannot connect in the WebViewActivity, when using multiserver.
2023-11-04 14:59:15 -04:00
Joris Pelgröm 2da1a36c55
Websocket onMessage: prevent out of order delivery due to launch (#3990)
Websocket onMessage: prevent out of order delivery due to launch
2023-11-01 19:01:20 -04:00
Joris Pelgröm e8815f12e5
Always send sensor registration device class + entity category to prevent errors due to old registration (#3977)
* Always send device class during registration

 - Always send the device class for a sensor during registration to overwrite any existing invalid values

* Only send sensor registrations with null properties to core 2023.2+
2023-10-28 11:18:03 -04:00
Joris Pelgröm 7d76bb4b51
Update tiles logged out state to prevent cut off overflow, shortcuts tile label (#3975)
Update tiles logged out state to prevent cut off overflow

 - Limit length of logged out state string to prevent text cut off and shorten strings to help with translations
 - Fix inconsistent shortcuts tile name
2023-10-28 11:15:22 -04:00
Daniel Shokouhi a596a1183d
Use deprecated wifi method in case WifiInfo is null (#3970)
* Use deprecated wifi method in case WifiInfo is null

* Add comment about why we are reusing the deprecated method
2023-10-25 23:24:27 -04:00
Joris Pelgröm 5314e4b08b
Update Jetpack/Google dependencies (Oct 2023) (#3966) 2023-10-22 12:19:47 -04:00
Joris Pelgröm cda25479d6
Add clear_notification support to Wear OS (#3956)
- Move the clear_notification command to common extensions and add support in the Wear OS app
2023-10-20 17:45:48 -04:00
Daniel Shokouhi 709ca07e8c
Shorten some settings strings (#3921)
* Shorten some settings strings

* Remove unused string
2023-10-06 16:51:32 +00:00
Márton Maráz 2641422e50
Add NFC state sensor (#3905)
* Add first draft for NFC sensor

* Rename NfcSensorManager.nfcSensor to nfcStateSensor

* Move NfcSensorManager to the common module

* Add BroadcastReceiver subscription to NfcAdapter.ACTION_ADAPTER_STATE_CHANGED in both the app and wear modules

* Remove TODO comments

* Change updateType to INTENT

* Convert simple methods to expression body

* Change mdi:nfc to mdi:nfc-variant

* Fix docs URL

* Reword NFC sensor manager according to the PR suggestions
2023-10-05 09:57:33 -04:00
Joris Pelgröm 4a4cc31b97
Update icon (#3888)
* Update icon

 - Replace old icon with the new icon
 - Update app primary color to new blue tint
 - Deduplicate resources

* Update feature graphic

* Decouple app icon color from main color
2023-09-28 17:38:48 -04:00
Joris Pelgröm b0ad11d04f
Add troubleshooting tool: location history (#3886)
* Add location history (location, trigger, result)

 - Initial setup saving data, no UI, cleanup or preferences yet

* On/off setting, limit history size and basic UI

 - Add a on/off setting for location history (default on)
 - Limit the history size to 48 hours, any older entries will be deleted during regular sensor updates
 - Add a basic UI for location history based on paging considering the possible data size with multiserver/high accuracy. The list looks good and shows status at a glance, detail view still needs work.

* Finish expanded UI

 - Make the expanded UI nicer and show relevant data, buttons for opening the location in a maps app and sharing log data
 - Add empty states for location history

* Filter by state, improve list speed

 - Add option to filter by state
 - Simplify Room configuration and sort by indexed ID to improve list loading speed

* Remove duplicate source

* Fix minimal

* Split sent into sent and failed to send
2023-09-28 17:37:37 -04:00
Lev Aronsky a31cd2fdaa
Fix isActive for locks (#3862)
* Fix isActive for locks

Lock entity should be active when locked, inactive otherwise

* Added a comment to explain the change
2023-09-19 15:40:07 -04:00
Joris Pelgröm 3915ec6d8f
Automatically fix broken registrations/webhooks (#3875) 2023-09-19 15:38:50 -04:00
Joris Pelgröm 2c20baf0f5
Add camera tile to Wear OS (#3870)
* [WIP] Prepare camera snapshot tile

* Deduplicate refresh views

* Get/save tile config in the database

* Deduplicate haptic click, add to camera refresh

* [WIP] Camera tile settings UI

 - Create UI to set camera tile settings
 - Reuse shortcut tile settings activity as a general tile settings activity

* Rename camera snapshot tile to camera tile

* Cleanup: camera entities selection, empty state, preview image

 - On initial load also create a list of camera entities to make it possible to select them without showing up elsewhere in the app
 - Add text to empty state instructing the user to set a camera
 - Update tile preview images

* Fix logged out state on missing tile config

* Force tile update on login

* Scale bitmap to fit inside screen size

 - Scale the received image to a bitmap that does not exceed the screen size to ensure timely refreshes and prevent parcels that are too big
2023-09-17 16:57:33 -04:00
Joris Pelgröm 4163e1465e
Add Android 14 device controls panel (#3855)
* Prepare controls panel activity for Android 14

* Allow controls panel to work while locked

* UI to enable/disable controls panel

 - Disable panel by default
 - Add area to controls settings on Android 14 to enable/disable panel

* Panel server/path settings

 - Add setting to choose which server and path to use for the panel

* Remove transition animation for panel

* experience -> mode
2023-09-12 21:47:57 -04:00
Guillermo Orellana 6c54aa84b7
Fix crash on empty URL strings (#3846)
defensive url parsing
2023-09-06 08:32:45 -04:00
Joris Pelgröm b6687dc762
Shortcut path input improvements (#3831) 2023-08-31 19:53:32 -04:00
Daniel Shokouhi 3cc7bdca08
Fix last update sensor intent not retrieving value (#3825)
* Fix last update sensor intent not retrieving value

* Suppress deprecation

* Move suppression
2023-08-28 17:44:10 -04:00
Daniel Shokouhi bb58a578dd
Use unavailable and unknown states consistently when dealing with sensors and entities (#3821)
* Use unavailable and unknown states consistently when dealing with sensors and entities

* Update more sensors

* Remove unused import
2023-08-28 17:43:25 -04:00
Joris Pelgröm 6d4fa06545
Thread updates: add border agent ID, multiserver improvements (#3820)
* Add/update/delete Thread credentials by border agent ID

* Multiserver: only keep one HA credential, handle credentials for deleted servers

 - Make sure the app only stores one HA credential that matches the preferred credential for the server executing the sync.
 - Create an 'orphaned Thread credentials' system to be able to delete credentials for servers that have been previously deleted.

* Fix minimal
2023-08-26 16:54:40 -04:00
Daniel Shokouhi 6c2e555e57
Various changes to entity usage (#3816)
* Various changes to entity usage

* Remove unneeded code

* String fixes

* Remove redundant string
2023-08-26 16:53:31 -04:00
Daniel Shokouhi 1bdbd3f2ce
Android Auto: Set icon color when entity is considered in an active state (#3805)
* Android Auto: Set icon color when entity is considered in an active state

* Add link to frontend code for determing active state

* Add lawn_mower domain and a check on supported colored domains

* Split up isActive and state colored domains

* Update map screen
2023-08-24 14:43:10 -04:00
Joris Pelgröm 7f14582909
Add 'toggle' tap action to entity state widget (#3798)
* [WIP] Widget tap action: toggle entity

* Add feedback on press and failure

* Share code for pressing on entities

* Align cover press action

 - Toggle will stop if possible when opening/closing if supported so prefer toggle instead of open/close

* Toggle by default if supported

 - Set the default tap action for supported entities to toggle instead of refresh

* Update widget description
2023-08-19 19:24:44 +00:00
Joris Pelgröm e3ce9ed5b0
Fix phone state sensor only considering 1 subscription's calls (#3803) 2023-08-19 18:52:24 +00:00
Daniel Shokouhi 256835a380
Add update sensors notification command to Wear OS (#3774) 2023-08-10 13:55:54 -04:00
Joris Pelgröm 73bc7b01fa
Update strings for sentence-style casing (#3768)
* Update strings for sentence-style casing

* Don't remove strings

* Update Companion App
2023-08-07 20:17:09 +00:00
Daniel Shokouhi 28b6d8ec32
Add support for alarm control panels in android auto (#3765)
* Add support for alarm control panels in android auto

* Check for domain when checking if there is a code

* Check that armed_away is a supported state

* Review comments

* Add some missing strings, match state casing with HA core
2023-08-07 15:53:03 -04:00
Daniel Shokouhi 2d439f11ea
Set car sensors state appropriately if sensor registers with unit of measurement (#3764)
* Set car sensor state appropriately if sensor registers with unit of measurement

* Stick to unavailable for better consistency
2023-08-07 15:50:21 -04:00
Joris Pelgröm 49f3080b9e
Update ExoPlayer usage (#3760)
* Switch to StyledPlayerView for migration

* Migrate to media3 for ExoPlayer

* Replace deprecated code

* Restore/customize layout to ExoPlayer v2
2023-08-04 20:07:52 -04:00
Joris Pelgröm add1955901
Assist last used: remember STT and record proactively (before connected) (#3755)
Assist last used: remember STT and record before connected

 - For the last used pipeline for Assist, remember whether or not it supports STT input, and if it does start recording proactively/as soon as possible to avoid missing voice input while doing network checks.
 - Fix potential wrong server while sending voice data.
 - Fix voice input remaining active after getting an error response.
2023-08-04 10:59:27 -04:00
Daniel Shokouhi 94413801ec
Hide some sensors from unsupported devices (#3740)
* Hide some sensors from unsupported devices

* Move UI manager to condition
2023-07-31 15:19:14 -04:00
Joris Pelgröm 670b17e76c
Apply various IDE code quality suggestions (#3734) 2023-07-31 15:17:42 -04:00
Márton Maráz a8a7363317
Implement support for multiple Shortcut Tiles on Wear OS (#3697)
* Extract JSONArray -> List<String> conversion to extension fun

* Refactor navigation around Shortcuts Tile settings

* Add ShortcutsTileId enum class

* Introduce multiple ShortcutTile subclasses and modify settings UI and storage to support multiple Tiles

* Check if correct ShortcutsTileId is passed as parameter to BaseShortcutTile

* Update TileUpdateRequester usages to account for multiple Tiles

* Add entity count to Shortcut Tile list in Settings

* Fix ktlint errors

* Fix more ktlint errors

* Extract string resource

* Add MULTI_INSTANCES_SUPPORTED to ShortcutsTile to be able to use any number of Tiles

* Refresh the list of Shortcut Tiles in the Settings without needing to restart the app

* Remove test logs

* Update androidx.wear.tiles:tiles to the latest version which doesn't yet require API 34 compileSdk version

* Fix crash when the preference's value is "{}"

* Fix crash when key String is "null" and converting to Int

* Rename placeholder variable name

* Add a comment explaining why to save the tiles in a getter

* Return emptyList() directly for clarity

* Remove icons from "Shortcut tile #n" entries in Settings

* Pass emptyList instead of using the non-null assertion operator to prevent NPEs in edge cases

* Refactor getTileShortcuts and getAllTileShortcuts in WearPrefsRepositoryImpl.
Make the code more readable and understandable, and reduce code duplication.

* Make it explicit that intKey is only intended to be null if stringKey == "null"

* Rename getTileShortcuts to getTileShortcutsAndSaveTileId and make it save the tileId not only when there's a null key in the map, but also when the tileId is not yet in the map. This way, actual Tiles and the tileId keys will be more in sync.

* Handle adding Shortcuts Tile immediately after updating the app to a new version which introduces support for multiple Shortcuts Tiles.

* Show message in the Settings when there are no Shortcuts tiles added yet.

* Refine message in the Settings when there are no Shortcuts tiles added yet

* WIP: ConfigShortcutsTile action

* Update comments about Wear OS versions

* Finalize ConfigShortcutsTile feature by applying @jpelgrom's suggestion to OpenShortcutTileSettingsActivity

* Only wrap the code in runCatching which is expected to throw an Exception under normal circumstances, when the pref value needs to be migrated from the old format.

* Call getTileShortcutsAndSaveTileId in OpenShortcutTileSettingsActivity

* Remove unnecessary stuff
2023-07-31 15:14:01 -04:00
Joris Pelgröm 8f7abb4379
Fix old server references in app-level preferences (#3728) 2023-07-28 13:50:16 -04:00
Daniel Shokouhi 4069d29d0a
Android auto: Switch to GridTemplate for home screen and default to favorites if defined (#3694)
* Android auto: default to favorites if defined

* Fix changing servers

* Fix empty favorites list

* Review comments

* Account for extra grid items when showing favorites

* Switch to grid view for home screen, show all domains when there are no favorites for the server

* Review comments

* Clean up and move some methods to util

* Collect favorites with allEntities

* Review comments

* Move native mode logic back

* Check distraction again in domain screen

* Use base class to get distraction optimized variable

* Send blank template if user is not logged in

* Mark variables as private

* Fix icon resolution for grid items
2023-07-27 15:41:22 -04:00