Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scene support to WMS WebControl pro #126081

Merged
merged 3 commits into from
Oct 10, 2024
Merged

Conversation

mback2k
Copy link
Contributor

@mback2k mback2k commented Sep 16, 2024

Proposed change

Add scene support to WMS WebControl pro

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:

homeassistant/components/wmspro/scene.py Outdated Show resolved Hide resolved
Comment on lines 47 to 60
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, scene_id_str)},
manufacturer=MANUFACTURER,
model="Scene",
name=scene.name,
serial_number=scene_id_str,
suggested_area=scene.room.name,
via_device=(DOMAIN, config_entry_id),
configuration_url=f"http://{scene.host}/control",
)
Copy link
Member

Choose a reason for hiding this comment

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

Why is every scene its own device?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't need to be. Scenes are not a device in the real world, so we could skip this part.

Copy link
Member

Choose a reason for hiding this comment

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

But I am interested in how they work since they are linked to a room

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the automatically created dashboard it puts them into the corresponding room:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works the same as with other entities which have device information:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Scenes in WMS are basically the same thing as in HA: "A scene entity is an entity that can reproduce a wanted state for a group of entities. A scene entity can activate the scene towards a group of devices but remains stateless ..."

Copy link
Member

Choose a reason for hiding this comment

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

Check. Yea I remember that Hue also has scenes, but they are coupled to the group they affect

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, so should I remove or keep the device info?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just checked: The following integrations also provide DeviceInfo for Scene implementations:

  • fibaro
  • hue
  • litejet
  • lutron_caseta
  • tuya

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some more research and found out the following:

Fibaro links the scenes to the hub device:

# All scenes are shown on hub device
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, controller.hub_serial)}
)

Hue actually links the scenes to the room/zone device:

# we create a virtual service/device for Hue zones/rooms
# so we have a parent for grouped lights and scenes
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.group.id)},
)

Litejet links the scenes to the hub (mcp?) device:

self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, f"{entry_id}_mcp")},
name="LiteJet",
manufacturer="Centralite",
model=system.model_name,
)

Lutron Caseta links the scenes to the hub (bridge) device:

self._attr_device_info = DeviceInfo(
identifiers={(CASETA_DOMAIN, data.bridge_device["serial"])},
)

Only Tuya links the scene to its own (scene_id) device:

self._attr_unique_id = f"tys{scene.scene_id}"

return DeviceInfo(
identifiers={(DOMAIN, f"{self.unique_id}")},
manufacturer="tuya",
name=self.scene.name,
model="Tuya Scene",
entry_type=DeviceEntryType.SERVICE,
)

So, we have Hue linking to rooms, 3 others linking to their hub and just Tuya creating per scene devices.

Based on these findings, any suggestion on how to move forward?

@mback2k mback2k marked this pull request as ready for review September 22, 2024 19:50
@mback2k mback2k marked this pull request as draft September 23, 2024 10:26
@mback2k mback2k marked this pull request as ready for review September 23, 2024 20:34
@mback2k mback2k requested a review from joostlek September 23, 2024 20:34
@home-assistant home-assistant bot marked this pull request as draft October 10, 2024 11:27
@home-assistant
Copy link

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.

@mback2k mback2k marked this pull request as ready for review October 10, 2024 12:54
@home-assistant home-assistant bot requested a review from joostlek October 10, 2024 12:54
@joostlek joostlek merged commit 5e38bb7 into home-assistant:dev Oct 10, 2024
31 checks passed
@mback2k
Copy link
Contributor Author

mback2k commented Oct 10, 2024

Thanks a lot! 👍

@github-actions github-actions bot locked and limited conversation to collaborators Oct 11, 2024
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.

2 participants