-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New thermostat tile for Wear OS (#4959)
* Add thermostat tile to Wear OS app. * Add database schema. * Remove debug logging. * Minor changes for ktlint. * More minor changes for ktlint. * Changed import order in AppDatabase. * Changed layout of the tile. Now includes the state (Idle/Heating/Cooling) based on which the font changes color. Also includes the friendly name of the entity at the op. * Add temperature unit to the tile. * Add handling of "Off" state. * Add setting to toggle showing of name on tile. * Aligned name on tile setting of the thermostat tile to the shortcuts tile. * Revert back to SwitchButton for name on tile. * Change preview to realistic image. * Changed retrieving of targetTemperature. * Changed retrieving of friendlyName. * Change location of retrieving information only needed when the tile is configured. * Changed format of temperature when entity is off. * Use friendlyState for the state shown on the tile. * Use constant for temp up and down action, and combine getTempUpButton() and getTempDownButton() into a single function. * Make hvac_action translatable. * Add missing import. * Update layout of the tile. - Text is now always white. - Edge of screen lights up when heating or cooling. * Compressed preview image. * Move hapticClick up in the code to prevent delay. * Disable buttons if entity is off. * Add graceful handling of not being able to fetch entity. * Fixed "select entity" message not being shown. * use state strings for thermostat tile. * Update preview for the select thermostat view. * Change icon to domain default. * Use TAP_ACTION_UP in setting the updated temperature. * Capitalize hvacAction. * Wrap code to show entity name on tile in if statement. * Move logged in check up in the code. * Move logged in check up in the code - Fix. * Remove unnecessary safe calls. * Pass entity to timeline function instead of retrieving it again. * Handle situation where attribute stepSize is not set. * Fix indentation. * Fix empty line. * Changed handling of off/unavailable state * Indentation. * Updated example image. * Change logic to get entity domain. * Direct use of entity.entityId. * Clean up updatedTargetTemp. * Change logic for unavailable entity. * Remove empty line. * Remove suspend from timeline functoin declaration. Co-authored-by: Joris Pelgröm <[email protected]> * Improve imports. * Change order of imports. * Change order of imports, again. * Change order of imports, again. * Another import change. --------- Co-authored-by: Joris Pelgröm <[email protected]>
- Loading branch information
1 parent
c84445b
commit cb99f4c
Showing
14 changed files
with
1,912 additions
and
3 deletions.
There are no files selected for viewing
1,183 changes: 1,183 additions & 0 deletions
1,183
common/schemas/io.homeassistant.companion.android.database.AppDatabase/49.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
29 changes: 29 additions & 0 deletions
29
common/src/main/java/io/homeassistant/companion/android/database/wear/ThermostatTile.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,29 @@ | ||
package io.homeassistant.companion.android.database.wear | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
/** | ||
* Represents the configuration of a thermostat tile. | ||
* If the tile was added but not configured, everything except the tile ID will be `null`. | ||
*/ | ||
@Entity(tableName = "thermostat_tiles") | ||
data class ThermostatTile( | ||
/** The system's tile ID */ | ||
@PrimaryKey | ||
@ColumnInfo(name = "id") | ||
val id: Int, | ||
/** The climate entity ID */ | ||
@ColumnInfo(name = "entity_id") | ||
val entityId: String? = null, | ||
/** The refresh interval of this tile, in seconds */ | ||
@ColumnInfo(name = "refresh_interval") | ||
val refreshInterval: Long? = null, | ||
/** The target temperature to allow quick repeated changes */ | ||
@ColumnInfo(name = "target_temperature") | ||
val targetTemperature: Float? = null, | ||
/** Whether or not to show the entity friendly name on the tile. */ | ||
@ColumnInfo(name = "show_entity_name") | ||
val showEntityName: Boolean? = true | ||
) |
23 changes: 23 additions & 0 deletions
23
common/src/main/java/io/homeassistant/companion/android/database/wear/ThermostatTileDao.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,23 @@ | ||
package io.homeassistant.companion.android.database.wear | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
@Dao | ||
interface ThermostatTileDao { | ||
|
||
@Query("SELECT * FROM thermostat_tiles WHERE id = :id") | ||
suspend fun get(id: Int): ThermostatTile? | ||
|
||
@Query("SELECT * FROM thermostat_tiles ORDER BY id ASC") | ||
fun getAllFlow(): Flow<List<ThermostatTile>> | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun add(tile: ThermostatTile) | ||
|
||
@Query("DELETE FROM thermostat_tiles where id = :id") | ||
fun delete(id: Int) | ||
} |
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
Oops, something went wrong.