Skip to content

fix: filter garbage data from Daikin API responses#94

Open
gcamp wants to merge 5 commits intozlangbert:mainfrom
gcamp:fix/filter-garbage-api-data
Open

fix: filter garbage data from Daikin API responses#94
gcamp wants to merge 5 commits intozlangbert:mainfrom
gcamp:fix/filter-garbage-api-data

Conversation

@gcamp
Copy link
Copy Markdown

@gcamp gcamp commented Dec 21, 2025

The Daikin API occasionally returns sentinel values (255, 65535) when the thermostat restarts or loses connectivity. These garbage values result in unrealistic sensor readings like 127.5% demand or 655.35kW power usage.

This change adds validation to detect these sentinel values and skip updates with corrupted data, preserving the last known good state instead. A warning is logged when garbage data is detected for debugging purposes.

Fixes #79

The Daikin API occasionally returns sentinel values (255, 65535) when the
thermostat restarts or loses connectivity. These garbage values result in
unrealistic sensor readings like 127.5% demand or 655.35kW power usage.

This change adds validation to detect these sentinel values and skip updates
with corrupted data, preserving the last known good state instead. A warning
is logged when garbage data is detected for debugging purposes.

Fixes zlangbert#79

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@gcamp
Copy link
Copy Markdown
Author

gcamp commented Dec 21, 2025

@zlangbert any chance for a review and merge? This project seems unmaintained at this point

- Add pytest and pytest-asyncio to dev dependencies
- Create comprehensive test suite for garbage data detection
- Tests verify sentinel value detection (255, 65535)
- Tests verify state preservation when garbage data received
- Update CI workflow to run tests on PRs and main branch
- Configure pytest with async support in pyproject.toml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@zlangbert
Copy link
Copy Markdown
Owner

Hi @gcamp, thanks for the PR and ping, I've been meaning to come back to this at some point.

When I was initially looking at this (#22), I remember thinking I wanted to filter out specific sensor updates with sentinel values rather than not update anything. The reasoning being I couldn't be sure that we wouldn't get sentinel values for one thing and not another, potentially blocking updates to new values we do want.

Now that you have looked into this more, any additional insight on that? How confident are you in this approach?

gcamp and others added 3 commits December 21, 2025 14:46
- Add proper type hints to all test fixtures and methods
- Import LogCaptureFixture from pytest for caplog typing
- Use type: ignore comments for private method access
- Add file-level pyright configuration for necessary suppressions
- All tests pass and pyright reports 0 errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add return type annotation (-> None)
- Add type annotation for valid_devices list
- Resolves pyright strict mode type checking errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Remove ctIFCFanRequestedDemandPercent from the list of fields checked
for garbage sentinel values. Update corresponding test.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@gcamp
Copy link
Copy Markdown
Author

gcamp commented Dec 21, 2025

Hard to be confident at 100% when you're working on an private API but I can say that :

  • When this issue happens, all the values are set to the sentinel value (see response in Daikin API sometimes sends garbage data, should filter #79)
  • I don't see how a functioning unit could return sentinel values for any of the fields listed (it does still return sentinel for some values, but not any of the required fields).
    • Does Daikin still has some AC that aren't heatpump? In that case we can probably check heat or cold instead of heat and cold.
    • I was initially wrong about ctIFCFanRequestedDemandPercent being required, which I don't understand because I don't see my fan_demand_requested at 127%. I didn't investigate more at this point.

I also added tests, but feel free to remove them if you don't think they add value (since there was no test before).

Currently testing my branch on my home assistant, I can report back in a week or two to make sure everything is good.

@zlangbert
Copy link
Copy Markdown
Owner

zlangbert commented Dec 21, 2025

Does Daikin still has some AC that aren't heatpump? In that case we can probably check heat or cold instead of heat and cold.

This is essentially the issue I am most concerned about. I have seen a lot of different combinations of reported / non-reported values for people with differing equipment, some of which I can't make any sense of. The more I think about this the more I feel we should take a more granular approach.

My philosophy at this point is the less we assume about the relationships between fields the better

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.

Daikin API sometimes sends garbage data, should filter

2 participants