Skip to content

Action fails on station-less devices #15

@CFenner

Description

@CFenner

Running the test function via HA fails for my XS01-WX:

  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 132, in _async_press_action
    await self.async_press()
  File "/config/custom_components/xsense/button.py", line 111, in async_press
    await self.entity_description.press_fn(device, xsense)
  File "/config/custom_components/xsense/button.py", line 25, in run_action
    return await xsense.action(entity, action)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/xsense/async_xsense.py", line 270, in action
    await self.set_state(entity, action_def['shadow'], topic, action_def)
  File "/usr/local/lib/python3.13/site-packages/xsense/async_xsense.py", line 241, in set_state
    station = entity.station
              ^^^^^^^^^^^^^^
AttributeError: 'Station' object has no attribute 'station'

async def set_state(self, entity: Entity, shadow: str, topic: str, definition: Dict):
station = entity.station

The Entity that is passed to the function is a Station, so we cannot use entity.station.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions