Skip to content

Conversation

@elupus
Copy link
Contributor

@elupus elupus commented Jul 7, 2025

Proposed change

Handle the case of binary sensors and switches not using default mapping off "ON", "OFF".

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

'friendly_name': 'F1255 EB101 Installed',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.eb101_installed_49239',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what a strange entity id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many strange one: https://github.com/yozik04/nibe/blob/master/nibe/data/f1155_f1255.json eb101 is a type of asscessory. The number is the ID of the data in nibe databases.

Since we have no way on entities to show what their source unique identifies are in gui (to map to offical documentations) it kinda need to go somewhere.

Comment on lines 66 to 105
async def test_turn_on(
hass: HomeAssistant,
mock_connection: AsyncMock,
model: Model,
entity_id: str,
address: int,
state: Any,
coils: dict[int, Any],
) -> None:
"""Test setting of value."""
coils[address] = state

await async_add_model(hass, model)

await hass.async_block_till_done()
assert hass.states.get(entity_id)

# Write value
await hass.services.async_call(
PLATFORM_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)

await hass.async_block_till_done()

# Verify written
args = mock_connection.write_coil.call_args
assert args
coil = args.args[0]
assert isinstance(coil, CoilData)
assert coil.coil.address == address
assert coil.raw_value == 1


@pytest.mark.parametrize(
("model", "address", "entity_id", "state"),
[
(Model.F1255, 48043, "switch.holiday_activated_48043", "INACTIVE"),
(Model.F1255, 48071, "switch.flm_1_accessory_48071", "ON"),
],
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_turn_off(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you feel fancy, you could also parametrize these

Copy link
Contributor Author

@elupus elupus Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well. i would have to parametrize the service call. Feels ugly.

@home-assistant
Copy link

home-assistant bot commented Jul 7, 2025

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft July 7, 2025 16:54
@elupus elupus marked this pull request as ready for review July 7, 2025 18:30
@home-assistant home-assistant bot requested a review from joostlek July 7, 2025 18:30
@elupus elupus force-pushed the nibe/fix_switch_bool branch from 029d2af to 783d81a Compare July 8, 2025 06:52
@elupus elupus force-pushed the nibe/fix_switch_bool branch from 783d81a to baf691e Compare July 8, 2025 06:55
@joostlek joostlek merged commit a7cba2b into home-assistant:dev Jul 8, 2025
34 checks passed
@joostlek joostlek added this to the 2025.7.2 milestone Jul 8, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jul 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nibe f1255: switch.holiday_activated_48043 error when switching

3 participants