Skip to content

Conversation

@UrbanZan
Copy link

@UrbanZan UrbanZan commented Jan 8, 2026

Problem

Some Sonoff TH sensors (SNZB-02D, SNZB-02LD, SNZB-02WD, SNZB-02DR2) with newer firmware (v8960+) send temperature_units as "Celsius" or "Fahrenheit" (capitalized) instead of "celsius" or "fahrenheit" (lowercase).

This causes Home Assistant to reject the value with an error like:

Invalid option for select.office_th_sensor_temperature_units: 'Celsius' (valid options: ['celsius', 'fahrenheit'])

Solution

Added a case-insensitive key matching fallback in getFromLookupByValue(). When the device sends a string value that doesn't match any lookup value exactly, the function now checks if the string matches any lookup key case-insensitively and returns the correctly-cased key.

  • Device sends "Celsius" → returns "celsius"
  • Device sends "Fahrenheit" → returns "fahrenheit"

Affected Devices

  • Sonoff SNZB-02D
  • Sonoff SNZB-02LD
  • Sonoff SNZB-02WD
  • Sonoff SNZB-02DR2

Testing

The fix is backward compatible - existing numeric value handling remains unchanged.

@Koenkk
Copy link
Owner

Koenkk commented Jan 8, 2026

It should always use celsius and never Celsius, this should be fixed after changing it once.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants