mirror of
https://github.com/home-assistant/iOS.git
synced 2026-02-20 20:06:04 -06:00
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->
## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->
Following the thread at
https://github.com/home-assistant/iOS/discussions/1764#discussioncomment-10434403
, this is my novice attempt at adding
https://developer.apple.com/documentation/watchkit/wkinterfacedevicebatterystate
or the Watch Battery State, using #2897 as a reference.
## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->
I don't know how to take a screenshot of the sensor reporting through
the simulator, I can add them if pointed in the right direction.
## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#
> _I will look into this. I will look for the corresponding watch
battery change docs if they exist and extend them._
## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
This is a rough pass. I used #2897 as a launching point - I read it
carefully as this is my first ever code contribution for Swift / iOS,
WatchOS project but I think I had enough heuristics to manage to
_possibly_ get it in the vicinity of it being correct.
I also used `Sources/Shared/API/Webhook/Sensors/BatterySensor.swift` for
including an additional `Battery State` sensor, while exposing both
sensors similarly in name like it's another device.
I think it could still be improved by using
`Sources/Shared/API/Webhook/Sensors/BatterySensor.swift` as a reference.
I tried to change as little as possible.
I wasn't sure if I needed to add anything to
`Sources/App/WatchCommunicatorService.swift`, considering the commit in
#2897,
f961d689e5 (diff-daa127042af3bc5719e4eb4e02e3c50bfcef50084f554e53475f4a4238fdd096)
- I will lean heavily on comments and will iterate where requested, if
the changes aren't edited directly by the maintainers. @bgoncal
- I **do** think I ran the Unit Tests correctly and added to the one
that was also changed in #2897
---------
Co-authored-by: Bruno Pantaleão Gonçalves <5808343+bgoncal@users.noreply.github.com>