Skip to content

Issue printing device in on_discovered: pydantic.error_wrappers.ValidationError: 3 validation errors for SmartBulbPreset #439

Closed
@jimboca

Description

@jimboca

My code is printing a device in the method called by on_discovered:
await Discover.discover(target=broadcast_address,on_discovered=self.discover_new_add_device)

Which fails with:

Traceback (most recent call last):
  File "/var/polyglot/pg3/ns/000db952c414_2/nodes/Controller.py", line 157, in discover_new_add_device
    LOGGER.debug(f'enter: mac={smac} dev={dev}')
  File "/var/polyglot/.local/lib/python3.9/site-packages/kasa/smartdevice.py", line 706, in __repr__
    return f"<{self._device_type} model {self.model} at {self.host} ({self.alias}), is_on: {self.is_on} - dev specific: {self.state_information}>"
  File "/var/polyglot/.local/lib/python3.9/site-packages/kasa/smartdevice.py", line 88, in wrapped
    return f(*args, **kwargs)
  File "/var/polyglot/.local/lib/python3.9/site-packages/kasa/smartlightstrip.py", line 82, in state_information
    info = super().state_information
  File "/var/polyglot/.local/lib/python3.9/site-packages/kasa/smartdevice.py", line 88, in wrapped
    return f(*args, **kwargs)
  File "/var/polyglot/.local/lib/python3.9/site-packages/kasa/smartbulb.py", line 468, in state_information
    info["Presets"] = self.presets
  File "/var/polyglot/.local/lib/python3.9/site-packages/kasa/smartdevice.py", line 88, in wrapped
    return f(*args, **kwargs)
  File "/var/polyglot/.local/lib/python3.9/site-packages/kasa/smartbulb.py", line 512, in presets
    return [SmartBulbPreset(**vals) for vals in self.sys_info["preferred_state"]]
  File "/var/polyglot/.local/lib/python3.9/site-packages/kasa/smartbulb.py", line 512, in <listcomp>
    return [SmartBulbPreset(**vals) for vals in self.sys_info["preferred_state"]]
  File "/var/polyglot/.local/lib/python3.9/site-packages/pydantic/main.py", line 342, in __init__
    raise validation_error
pydantic.error_wrappers.ValidationError: 3 validation errors for SmartBulbPreset
hue
  field required (type=value_error.missing)
saturation
  field required (type=value_error.missing)
color_temp
  field required (type=value_error.missing)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions