-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Apple Watch battery sensor #2897
Conversation
📸 Snapshot TestNo snapshots generated
🛸 Powered by Emerge Tools |
This seems to be rounding to nearest 5 %. Is that expected? |
It looks like the API returns changes every 5% change indeed. |
@TomBrien I just noticed that iPhone battery behaves the same |
Oh so it does. Never noticed that... |
<!-- 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 #1764 (reply in thread) , 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, f961d68#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 <[email protected]>
Summary
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes