Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Go to **Settings → Devices & Services → Add Integration** and search for **S

## Events

The integration fires events on the Home Assistant event bus when players join or leave the server (that is, when the number of connected players changes). You can use these in automations via the **Event** trigger with the event type listed below.
The integration exposes a **Player activity** event entity that fires whenever a player joins or leaves the server (i.e., when the connected player count changes). You can use it in automations via the **State changed** trigger on the event entity.

| Event type | Fired when | Event data |
|---|---|---|
Expand Down
5 changes: 4 additions & 1 deletion custom_components/satisfactory/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def __init__(
) -> None:
"""Initialize the event entity."""
super().__init__(coordinator)
self._attr_unique_id = f"{(entry.unique_id or entry.entry_id)}_player_activity"
self._entry_id = entry.entry_id
self._attr_unique_id = f"{entry.unique_id}_player_activity"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, entry.unique_id or entry.entry_id)},
name=entry.title,
Expand All @@ -69,6 +70,7 @@ def _handle_coordinator_update(self) -> None:
self._trigger_event(
"player_joined",
{
"entry_id": self._entry_id,
"num_connected_players": new_players,
"player_limit": player_limit,
},
Expand All @@ -77,6 +79,7 @@ def _handle_coordinator_update(self) -> None:
self._trigger_event(
"player_left",
{
"entry_id": self._entry_id,
"num_connected_players": new_players,
"player_limit": player_limit,
},
Expand Down