HyundaiCanada: convert HI/LOW air-temp to resolved unit (fixes 62°C/82°C dropout, issue #30)#40
Open
MrL0 wants to merge 1 commit into
Open
HyundaiCanada: convert HI/LOW air-temp to resolved unit (fixes 62°C/82°C dropout, issue #30)#40MrL0 wants to merge 1 commit into
MrL0 wants to merge 1 commit into
Conversation
Temperature.maximum/minimum are Fahrenheit (62/82) and init(value:units:) does not convert, so a Celsius-resolved vehicle stored 82C/62C for HI/LOW — impossible cabin temps that isPlausibleForDisplay then drops, so the reading vanished (the 62C artifact from issue schmidtwmark#30). Convert the bound to the resolved unit, matching Temperature's string-init path.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
parseCanadaAirTempreturns the HVAC range bounds for"HI"/"LOW":But
Temperature.maximum/minimumare Fahrenheit constants (62/82 — the FahrenheithvacRange), andTemperature.init(value:units:)stores the raw value without conversion. When a Canadian response resolvesunitsto.celsius(top-level"C"),"HI"lands as 82°C and"LOW"as 62°C — impossible cabin temperatures.TemperatureDisplay.isPlausibleForDisplaythen rejects them (Celsius must be ≤ 60), so the reading silently disappears. 62°C is the exact artifact documented for issue #30.Fix: convert the Fahrenheit bound into the resolved unit before storing — matching what
Temperature's string initializer already does (Units.fahrenheit.convert(Temperature.maximum, to: units)). A Celsius vehicle now stores ~27.8 °C / 16.7 °C; Fahrenheit is unchanged.Testing
swift test— 290 tests pass. The conversion itself is covered by the existingTemperature.Units.converttests; this only changes the unit the HI/LOW bound is stored in. (No Canada-specific parse fixture exists in the suite to assert end-to-end.)Drafted with AI assistance; verified locally with
swift test.