frenck / spook

Spook 👻 Your homie
https://spook.boo
MIT License
360 stars 34 forks source link

'dict' object has no attribute 'data' #665

Closed Mariusthvdb closed 1 month ago

Mariusthvdb commented 1 month ago

What version of Spook are you using?

2.2.2

What version of Home Assistant are you using?

2024.4.0.dev20240321

The problem

HA dev includes a new PR consisting of a a change in the event filtering: https://github.com/home-assistant/core/pull/113798#issue-2194328239

BDraco suggested this for another CC that was affected:

    @callback
    def zones_filter(event: Event | Mapping[str, Any]) -> bool:
        """Return if the state changed event is for a zone."""
        data = event.data if type(event) is Event else event
        return split_entity_id(data["entity_id"])[0] == ZONE_DOMAIN

Anything in the logs? Paste it here!

2024-03-21 09:37:34.484 ERROR (MainThread) [homeassistant.core] Error in event filter
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1442, in _async_fire
    if event_data is None or not event_filter(event_data):
                                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/spook/repairs.py", line 186, in _filter_event
    service = event.data.get("service")
              ^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'data'
BoGnY commented 1 month ago

I've got a similar problem with dict on stats...

service: recorder.import_statistics
data:
  has_mean: false
  has_sum: false
  statistic_id: sensor.consumo_manuale_gas_mensile
  unit_of_measurement: m³
  source: sensor.consumo_manuale_gas
  stats:
    start: "2023-03-31 23:59:59+00:00"
    max: 23.927

got error Invocazione del servizio recorder.import_statistics non riuscita. expected a list for dictionary value @ data['stats']. Got None

is this related??

frenck commented 1 month ago

@BoGnY That is not related. The error message you pasted contains the answer as well.

frenck commented 1 month ago

@BoGnY It does. But, not related to this issue. So, let's stop polluting this issue. Thanks 👍