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

Error calling hub.get_motion_sensors() #45

Closed
sanjoyg opened this issue Jan 31, 2024 · 1 comment · Fixed by #46
Closed

Error calling hub.get_motion_sensors() #45

sanjoyg opened this issue Jan 31, 2024 · 1 comment · Fixed by #46

Comments

@sanjoyg
Copy link
Contributor

sanjoyg commented Jan 31, 2024

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
Copy link
Owner

Leggin commented Jan 31, 2024

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

@Leggin Leggin linked a pull request Feb 7, 2024 that will close this issue
@Leggin Leggin closed this as completed in #46 Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants