Skip to content

Commit d900f4b

Browse files
authored
Fix TuyaQuirkBuilder quirk_file location (#3757)
1 parent c00eb01 commit d900f4b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

zhaquirks/tuya/builder/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
from collections.abc import Callable
44
from enum import Enum
5+
import inspect
56
import math
7+
import pathlib
8+
from types import FrameType
69
from typing import Any, Optional
710

811
from zigpy.quirks import _DEVICE_REGISTRY
@@ -185,6 +188,12 @@ def __init__(
185188
self.tuya_dp_to_attribute: dict[int, DPToAttributeMapping] = {}
186189
self.new_attributes: set[foundation.ZCLAttributeDef] = set()
187190
super().__init__(manufacturer, model, registry)
191+
# quirk_file will point to the init call above if called from this QuirkBuilder,
192+
# so we need to re-set it correctly
193+
current_frame: FrameType = inspect.currentframe()
194+
caller: FrameType = current_frame.f_back
195+
self.quirk_file = pathlib.Path(caller.f_code.co_filename)
196+
self.quirk_file_line = caller.f_lineno
188197

189198
def _tuya_battery(
190199
self,

0 commit comments

Comments
 (0)