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

Fix calling get cluster on wrong variable #72

Merged
merged 2 commits into from
Sep 15, 2022
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 custom_components/matter_experimental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def on_hass_stop(event: Event) -> None:
return True


async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Config entry is being removed."""
# Remove storage file.
storage_path = get_matter_store(hass, entry).path
Expand Down
8 changes: 6 additions & 2 deletions custom_components/matter_experimental/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class MatterBinarySensor(MatterEntity, BinarySensorEntity):
@callback
def _update_from_device(self) -> None:
"""Update from device."""
self._attr_is_on = self._device.get_cluster(clusters.BooleanState).stateValue
self._attr_is_on = self._device_type_instance.get_cluster(
clusters.BooleanState
).stateValue


class MatterOccupancySensor(MatterBinarySensor):
Expand All @@ -55,7 +57,9 @@ class MatterOccupancySensor(MatterBinarySensor):
@callback
def _update_from_device(self) -> None:
"""Update from device."""
occupancy = self._device.get_cluster(clusters.OccupancySensing).occupancy
occupancy = self._device_type_instance.get_cluster(
clusters.OccupancySensing
).occupancy
# The first bit = if occupied
self._attr_is_on = occupancy & 1 == 1

Expand Down
6 changes: 3 additions & 3 deletions custom_components/matter_experimental/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ class MatterSwitch(MatterEntity, SwitchEntity):

async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn switch on."""
await self._device.send_command(
await self._device_type_instance.send_command(
payload=clusters.OnOff.Commands.On(),
)

async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn switch off."""
await self._device.send_command(
await self._device_type_instance.send_command(
payload=clusters.OnOff.Commands.Off(),
)

@callback
def _update_from_device(self) -> None:
"""Update from device."""
self._attr_is_on = self._device.get_cluster(clusters.OnOff).onOff
self._attr_is_on = self._device_type_instance.get_cluster(clusters.OnOff).onOff


@dataclass
Expand Down