Skip to content

Add Climate widget with Compose - #7340

Open
patoGarces wants to merge 24 commits into
home-assistant:mainfrom
patoGarces:ft/climate_widget_compose
Open

Add Climate widget with Compose#7340
patoGarces wants to merge 24 commits into
home-assistant:mainfrom
patoGarces:ft/climate_widget_compose

Conversation

@patoGarces

@patoGarces patoGarces commented Aug 17, 2026

Copy link
Copy Markdown

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:

  • Displaying the target temperature.
  • Increasing and decreasing the target temperature.
  • Selecting the HVAC mode.
  • Manually refreshing the widget.
  • Keeping the widget state synchronized with Home Assistant.
  • Persisting the latest state locally while waiting for updates.

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

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.
  • I have read the Open Home Foundation AI Policy.

Select exactly one option that describes AI usage in this contribution:

  • I have not used AI for this contribution.
  • AI assistance was used for this contribution.
  • AI fully generated the code for this contribution, but I've reviewed and understood it before submitting and will respond without AI during review.

Screenshots

image

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!

… 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
Copilot AI lite review requested due to automatic review settings August 17, 2026 02:18

@home-assistant home-assistant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@home-assistant

Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
home-assistant Bot marked this pull request as draft August 17, 2026 02:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, decodeFromString will 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.

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ktlint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@patoGarces
patoGarces marked this pull request as ready for review August 20, 2026 18:37
@patoGarces

Copy link
Copy Markdown
Author

@home-assistant recheck

@jpelgrom

jpelgrom commented Aug 21, 2026

Copy link
Copy Markdown
Member

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

@TimoPtr

TimoPtr commented Aug 24, 2026

Copy link
Copy Markdown
Member

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).

@bgoncal

bgoncal commented Aug 25, 2026

Copy link
Copy Markdown
Member

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.

@bgoncal

bgoncal commented Aug 25, 2026

Copy link
Copy Markdown
Member

Quick reference (no need to be identical of course)
CleanShot 2026-08-25 at 11 26 00@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants