def sensor_fixture(fixed_now: datetime): """Mock UniFi Protect Sensor device.""" # disable pydantic validation so mocking can happen Sensor.__config__.validate_assignment = False data = json.loads(load_fixture("sample_sensor.json", integration=DOMAIN)) sensor: Sensor = Sensor.from_unifi_dict(**data) sensor.motion_detected_at = fixed_now - timedelta(hours=1) sensor.open_status_changed_at = fixed_now - timedelta(hours=1) sensor.alarm_triggered_at = fixed_now - timedelta(hours=1) yield sensor Sensor.__config__.validate_assignment = True
def mock_sensor(): """Mock UniFi Protect Sensor device.""" data = json.loads(load_fixture("sample_sensor.json", integration=DOMAIN)) return Sensor.from_unifi_dict(**data)