Skip to content

fix(bravia_pro): power boolean param, numeric volume parse, error-body handling - #2

Draft
kvu-ucla wants to merge 1 commit into
masterfrom
worktree-bravia-pro-fixes
Draft

fix(bravia_pro): power boolean param, numeric volume parse, error-body handling#2
kvu-ucla wants to merge 1 commit into
masterfrom
worktree-bravia-pro-fixes

Conversation

@kvu-ucla

Copy link
Copy Markdown
Owner

Summary

Fixes three bugs in the Sony Bravia Pro REST driver, all found and verified against a live FW-43BZ30L (Pro mode, interface 5.7.0) in nonprod:

  • Power control never worked: setPowerStatus takes a boolean {"status": true}; the driver sent "active"/"standby" strings, which the display rejects with [3, "Illegal Argument"]. Those strings are only the response vocabulary of getPowerStatus.
  • Volume/mute state parsing crashed: hardware returns "volume": 17 as a JSON number, but the driver parsed with .as_s.to_i?, raising TypeCastError. Now parses numbers with a string fallback for older firmware. (Note: the sent volume must stay a string — integers are rejected.)
  • Device errors were treated as success: all failures arrive as HTTP 200 with {"error": [code, msg]} in the body (e.g. 40005 "Display Is Turned off" in standby). The driver only checked response.success?, so rejected commands still updated state. A shared parse_result helper now checks the body; expected standby/no-content errors (7, 40005) log at debug instead of warn.

Also dedupes volume?/mute? through a shared speaker_info lookup and fixes the when .hdmi1?, hdmi? matcher typo (missing dot).

Testing

  • All API forms verified live against 172.17.193.209 (power on/off round-trip, volume/mute, input switch, standby error bodies); display restored to original state afterwards.
  • Spec updated to mirror real hardware payloads (boolean power param, numeric volume, maxVolume/minVolume fields) and adds error-path coverage: rejected commands must not update state.
  • crystal spec drivers/sony/displays/bravia_pro_spec.cr passes against a -Dplaceos_all_transports build.

🤖 Generated with Claude Code

…y handling

Verified against a live FW-43BZ30L (Pro mode, interface 5.7.0):

- setPowerStatus takes a boolean; the "active"/"standby" strings were
  rejected with [3, "Illegal Argument"] so power control never worked
- getVolumeInformation returns volume as a JSON number, the as_s parse
  raised TypeCastError; now accepts number with string fallback
- the display reports failures as HTTP 200 with an {"error": [code, msg]}
  body; commands no longer set state optimistically when rejected
  (e.g. 40005 "Display Is Turned off" while in standby)
- expected standby/no-content errors (7, 40005) log at debug, not warn
- dedupe volume?/mute? via shared speaker_info; fix `.hdmi?` matcher typo

Spec updated to mirror real hardware payloads and cover the error paths.
@kvu-ucla
kvu-ucla force-pushed the worktree-bravia-pro-fixes branch from 1b32f3b to 395459f Compare August 21, 2026 21:37
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.

1 participant