Leggin / dirigera

This repository provides an unofficial Python client for controlling the IKEA Dirigera Smart Home Hub.
MIT License
116 stars 21 forks source link

Error calling hub.get_motion_sensors() #45

Closed sanjoyg closed 8 months ago

sanjoyg commented 8 months ago

Get the following error

1 validation error for MotionSensor attributes.lightLevel Field required [type=missing, input_value={'customName': 'Motion Se... 'circadianPresets': []}, input_type=dict] For further information visit https://errors.pydantic.dev/2.5/v/missing

======== The /devices JSON for motion_sensor is the following 'id': 'b9e5f463-5fc7-4731-aa36-9ee8e2e62a42_1', 'type': 'sensor', 'deviceType': 'motionSensor', 'createdAt': '2024-01-14T20:10:26.000Z', 'isReachable': False, 'lastSeen': '2024-01-30T13:51:14.000Z', 'attributes': {'customName': 'Motion Sensor 1', 'model': 'TRADFRI motion sensor', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '24.4.5', 'hardwareVersion': '1', 'serialNumber': '90FD9FFFFED87667', 'productCode': 'E1525', 'batteryPercentage': 1, 'isOn': False, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00', 'sensorConfig': {'scheduleOn': True, 'onDuration': 120, 'schedule': {'onCondition': {'time': '22:00'}, 'offCondition': {'time': '06:00'}}}, 'circadianPresets': []}, 'capabilities': {'canSend': ['isOn'], 'canReceive': ['customName']}, 'room': {'id': '7a88939b-4d5d-4369-9272-a5a1e16f07d8', 'name': 'Office', 'color': 'ikea_yellow_no_28', 'icon': 'rooms_office_chair'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}

The issue is in devices/motion_sensor.py

class MotionSensorAttributes(Attributes): battery_percentage: int is_on: bool light_level: float

The light_level isnt there in the attribute returned by the hub

Leggin commented 8 months ago

Ah interesting find, thank you! I will make light_level optional in the next release.