Add Climate widget with Compose - #7340
Conversation
… el TODO WIDGET, por ahora solo cree una ui muy básica de prueba y logré registrarlo en el manifest para poder agregarlo, pero falla ya que todavia no modifique el ClimateWidgetConfigureActivity.kt
Creo viewModel para ClimateWidget Agrego la ClimateWidgetConfigureActivity al manifest Puedo añadir el widget al inicio, muestra correctamente la activity de configuración, y se muestra el widget pero con un error de que no esta configurado
La configuracion iniciar funciona ok
…el estado actualizado en la db Agrego action para increase y decrease de temperature
agrego el friendlyName como titulo del widget Fix de actions disabled Agrego placeholder empty para temperatura
Ajusto algunos colores, sigue siendo inconsistente
…en ser Int, Double o Float que van a parsearse igual
# Conflicts: # common/schemas/io.homeassistant.companion.android.database.AppDatabase/53.json # common/src/main/kotlin/io/homeassistant/companion/android/database/AppDatabase.kt # common/src/main/res/values/strings.xml
There was a problem hiding this comment.
Hi @patoGarces
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR introduces a new Climate Glance widget with persistence (Room entity/DAO + DB migration), UI/configuration flow, and WebSocket service calls to control climate temperature and HVAC mode.
Changes:
- Add Climate widget database storage (entity, DAO, type converter) and bump Room DB version to 54 with schema update.
- Add Climate widget UI, configuration activity/view model, state updater flow, and widget actions/tests.
- Add WebSocket repository methods to call Home Assistant climate services (
set_temperature,set_hvac_mode).
Reviewed changes
Copilot reviewed 34 out of 36 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| gradle.properties | Enables tooling parallel sync setting for newer Gradle versions. |
| common/src/main/res/values/strings.xml | Adds new Climate widget strings and labels. |
| common/src/main/kotlin/.../ClimateLastUpdateDataConverter.kt | Adds Room type converter for climate widget cached state. |
| common/src/main/kotlin/.../ClimateWidgetEntity.kt | Adds Room entity for climate widget configuration + cached data. |
| common/src/main/kotlin/.../ClimateWidgetDao.kt | Adds DAO for CRUD and updating cached climate state. |
| common/src/main/kotlin/.../DatabaseModule.kt | Wires the new DAO into DI. |
| common/src/main/kotlin/.../AppDatabase.kt | Registers the new entity, version bump, and auto-migration. |
| common/src/main/kotlin/.../WebSocketRepository.kt | Adds new climate control APIs. |
| common/src/main/kotlin/.../WebSocketRepositoryImpl.kt | Implements the new climate service calls. |
| common/src/main/kotlin/.../Entity.kt | Extends climate controls + adds HVAC mode parsing/model. |
| common/schemas/.../54.json | Adds schema snapshot for DB v54. |
| app/src/main/res/xml/climate_widget_info.xml | Adds AppWidget provider metadata for climate widget. |
| app/src/main/kotlin/.../widgets/climate/* | Adds the widget receiver, UI, state, updater, actions, and configuration. |
| app/src/test/kotlin/.../widgets/climate/* | Adds tests for Climate widget state, updater, actions, and UI. |
| app/src/main/AndroidManifest.xml | Registers the climate widget receiver + configuration activity. |
| app/src/main/kotlin/.../HomeAssistantApplication.kt | Registers the new widget receiver at app startup. |
| app/src/main/kotlin/.../widgets/todo/TodoWidgetActions.kt | Renames Hilt entrypoint DAO getter and adds a debug log. |
| app/src/test/kotlin/.../widgets/todo/TodoWidgetToggleActionsTest.kt | Updates tests for renamed Todo DAO entrypoint method. |
Suppressed comments (1)
common/src/main/kotlin/io/homeassistant/companion/android/database/widget/converters/ClimateLastUpdateDataConverter.kt:1
- Room TypeConverters should be resilient to schema/model evolution. If the stored JSON becomes incompatible,
decodeFromStringwill throw and can break database reads for all users with older cached data. Consider catching decode exceptions and returning null (and optionally logging) to keep the app functional.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
ktlint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
|
@home-assistant recheck |
|
Hey, thanks for suggesting this widget! Based on the screenshot it looks like a good addition. Before diving into review, a quick check: you indicated it is based on the todo widget, did you see recent changes to widgets rebuilding the configuration with more modern Compose? And did you use those components and patterns for configuration of this widget? #7018, #7288 @TimoPtr I'm not sure if there are currently bigger plans with widgets you're aware of from the OHF side - and if we should stick to the frontend tile card design + actions - but I do like the M3 Expressive/You look of the widget |
I didn't have any plan yet for it. It is indeed a nice addition. I need to circle back with @bgoncal just to check if he had something in mind for iOS. I like the usage of M3 to fit in the home screen too. You should add a screenshot of the configuration screen. You could also ask for some UI feedback on discord to the UI team (I'm going to ping them). |
|
iOS does not have this widget yet. in terms of UI, I would start with something more similar to what Home Assistant frontend already has then make adjustments to look and feel more into the Android ecosystem. |

Summary
Hi everyone! This is my first contribution to the Home Assistant Android app, and my first real approach to contributing to the project.
I added a Climate widget for Android based on a personal need. I wanted to be able to quickly see and control my climate entity directly from a widget, including the target temperature and HVAC mode.
This addresses the need described in [#2185].
I've been developing and using it for about a month, and it has been working really well in my day-to-day use.
The implementation is based 100% on the existing Todo List widget. I followed its architecture and patterns for the widget state, DAO, state updater, Glance UI, actions, persistence and tests, adapting them to the requirements of a Climate entity.
The widget currently supports:
This is my first PR to the project, so I'm very open to feedback and suggestions regarding the implementation or anything that could be improved.
Checklist
Select exactly one option that describes AI usage in this contribution:
Screenshots
Link to pull request in documentation repositories
User Documentation: home-assistant/companion.home-assistant#
Developer Documentation: home-assistant/developers.home-assistant#
Any other notes
This widget was developed primarily for my own use, and after using it for about a month I felt it was stable enough to share it with the project.
Since this is my first contribution, any feedback on the approach is very welcome. Thanks for taking the time to review it!