Coverage for custom_components/camera_autonotify/compat.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-22 21:32 +0000

1"""Schema validation library, for the range of Home Assistant versions supported 

2 

3Home Assistant 2026.10 replaced voluptuous with probatio, aliasing `voluptuous` to it at runtime 

4so that `import voluptuous` carries on working. Earlier versions, supported here until they are 

5more than 6 months old, only have voluptuous. 

6 

7Home Assistant 2026.8 also gave each device a single config entry, with devices of different entries linked by the 

8identifiers and connections they share. Before that, the same identifiers would add the entry to the camera's own 

9device, so a camera's entry device is only made where devices are linked, and earlier versions go without it. 

10 

11So voluptuous is still what is imported at runtime, whichever library that turns out to be, while 

12type checking is against probatio, since that is what the current Home Assistant type hints expect. 

13""" 

14 

15from typing import TYPE_CHECKING 

16 

17from homeassistant.helpers import device_registry as dr 

18 

19if TYPE_CHECKING: 

20 import probatio as vol 

21else: 

22 import voluptuous as vol 

23 

24# only there once a device belongs to a single config entry 

25LINKED_DEVICES: bool = hasattr(dr.DeviceRegistry, "async_get_device_by_identifier") 

26 

27__all__ = ["LINKED_DEVICES", "vol"]