Skip to content

Commit dad7050

Browse files
authored
Merge pull request #10 from sayurin:feature/debug-epc
デバッグ支援機能
2 parents f270e12 + a6ce91f commit dad7050

4 files changed

Lines changed: 469 additions & 2 deletions

File tree

scripts/custom_definitions.yaml

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242

4343
devices:
4444
# Air cleaner (空気清浄機)
45-
# Sharp Corporation - EPC 0xF1 not in MRA → ADD
4645
0x0135:
4746
- epc: 0xF1
4847
manufacturer_code: 0x000005
@@ -75,10 +74,140 @@ devices:
7574
name_en: "PM2.5"
7675
name_ja: "PM2.5"
7776

77+
# Housing solar power generation (住宅用太陽光発電)
78+
0x0279:
79+
- epc: 0xF2
80+
manufacturer_code: 0x000005
81+
byte_offset: 0
82+
format: uint16
83+
unit: "V"
84+
minimum: 0
85+
maximum: 65533
86+
get: optional
87+
name_en: "Input Voltage 1"
88+
name_ja: "入力電圧1"
89+
- epc: 0xF2
90+
manufacturer_code: 0x000005
91+
byte_offset: 2
92+
format: uint16
93+
unit: "V"
94+
minimum: 0
95+
maximum: 65533
96+
get: optional
97+
name_en: "Input Voltage 2"
98+
name_ja: "入力電圧2"
99+
- epc: 0xF2
100+
manufacturer_code: 0x000005
101+
byte_offset: 4
102+
format: uint16
103+
unit: "V"
104+
minimum: 0
105+
maximum: 65533
106+
get: optional
107+
name_en: "Input Voltage 3"
108+
name_ja: "入力電圧3"
109+
- epc: 0xF2
110+
manufacturer_code: 0x000005
111+
byte_offset: 6
112+
format: uint16
113+
unit: "V"
114+
minimum: 0
115+
maximum: 65533
116+
get: optional
117+
name_en: "Input Voltage 4"
118+
name_ja: "入力電圧4"
119+
- epc: 0xF3
120+
manufacturer_code: 0x000005
121+
byte_offset: 0
122+
format: uint8
123+
unit: "A"
124+
minimum: 0
125+
maximum: 253
126+
multipleOf: 0.1
127+
get: optional
128+
name_en: "Input Current 1"
129+
name_ja: "入力電流1"
130+
- epc: 0xF3
131+
manufacturer_code: 0x000005
132+
byte_offset: 1
133+
format: uint8
134+
unit: "A"
135+
minimum: 0
136+
maximum: 253
137+
multipleOf: 0.1
138+
get: optional
139+
name_en: "Input Current 2"
140+
name_ja: "入力電流2"
141+
- epc: 0xF3
142+
manufacturer_code: 0x000005
143+
byte_offset: 2
144+
format: uint8
145+
unit: "A"
146+
minimum: 0
147+
maximum: 253
148+
multipleOf: 0.1
149+
get: optional
150+
name_en: "Input Current 3"
151+
name_ja: "入力電流3"
152+
- epc: 0xF3
153+
manufacturer_code: 0x000005
154+
byte_offset: 3
155+
format: uint8
156+
unit: "A"
157+
minimum: 0
158+
maximum: 253
159+
multipleOf: 0.1
160+
get: optional
161+
name_en: "Input Current 4"
162+
name_ja: "入力電流4"
163+
- epc: 0xF4
164+
manufacturer_code: 0x000005
165+
byte_offset: 0
166+
format: uint16
167+
unit: "W"
168+
minimum: 0
169+
maximum: 65533
170+
multipleOf: 10
171+
get: optional
172+
name_en: "Input Power 1"
173+
name_ja: "入力電力1"
174+
- epc: 0xF4
175+
manufacturer_code: 0x000005
176+
byte_offset: 2
177+
format: uint16
178+
unit: "W"
179+
minimum: 0
180+
maximum: 65533
181+
multipleOf: 10
182+
get: optional
183+
name_en: "Input Power 2"
184+
name_ja: "入力電力2"
185+
- epc: 0xF4
186+
manufacturer_code: 0x000005
187+
byte_offset: 4
188+
format: uint16
189+
unit: "W"
190+
minimum: 0
191+
maximum: 65533
192+
multipleOf: 10
193+
get: optional
194+
name_en: "Input Power 3"
195+
name_ja: "入力電力3"
196+
- epc: 0xF4
197+
manufacturer_code: 0x000005
198+
byte_offset: 6
199+
format: uint16
200+
unit: "W"
201+
minimum: 0
202+
maximum: 65533
203+
multipleOf: 10
204+
get: optional
205+
name_en: "Input Power 4"
206+
name_ja: "入力電力4"
207+
78208
# Air conditioner ventilation fan (空調換気扇)
79209
# Heat exchanger operation setting (熱交換機動作設定) EPC 0xE0
80210
# MRA bug: "false" (OFF) is incorrectly labeled "Heat exchanger ON"
81-
# EPC 0xE0 exists in MRA → UPDATE
82211
0x0134:
83212
- epc: 0xE0
84213
enum_values:

src/pyhems/definitions.json

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6281,6 +6281,182 @@
62816281
"name_ja": "定格発電電力値(独立時)",
62826282
"set": "optional",
62836283
"unit": "W"
6284+
},
6285+
{
6286+
"byte_offset": 0,
6287+
"epc": 242,
6288+
"format": "uint16",
6289+
"get": "optional",
6290+
"id": "class_0279_custom_000005_epc_f2_1",
6291+
"manufacturer_code": 5,
6292+
"maximum": 65533,
6293+
"minimum": 0,
6294+
"name_en": "Input Voltage 1",
6295+
"name_ja": "入力電圧1",
6296+
"set": "notApplicable",
6297+
"unit": "V"
6298+
},
6299+
{
6300+
"byte_offset": 2,
6301+
"epc": 242,
6302+
"format": "uint16",
6303+
"get": "optional",
6304+
"id": "class_0279_custom_000005_epc_f2_2",
6305+
"manufacturer_code": 5,
6306+
"maximum": 65533,
6307+
"minimum": 0,
6308+
"name_en": "Input Voltage 2",
6309+
"name_ja": "入力電圧2",
6310+
"set": "notApplicable",
6311+
"unit": "V"
6312+
},
6313+
{
6314+
"byte_offset": 4,
6315+
"epc": 242,
6316+
"format": "uint16",
6317+
"get": "optional",
6318+
"id": "class_0279_custom_000005_epc_f2_3",
6319+
"manufacturer_code": 5,
6320+
"maximum": 65533,
6321+
"minimum": 0,
6322+
"name_en": "Input Voltage 3",
6323+
"name_ja": "入力電圧3",
6324+
"set": "notApplicable",
6325+
"unit": "V"
6326+
},
6327+
{
6328+
"byte_offset": 6,
6329+
"epc": 242,
6330+
"format": "uint16",
6331+
"get": "optional",
6332+
"id": "class_0279_custom_000005_epc_f2_4",
6333+
"manufacturer_code": 5,
6334+
"maximum": 65533,
6335+
"minimum": 0,
6336+
"name_en": "Input Voltage 4",
6337+
"name_ja": "入力電圧4",
6338+
"set": "notApplicable",
6339+
"unit": "V"
6340+
},
6341+
{
6342+
"byte_offset": 0,
6343+
"epc": 243,
6344+
"format": "uint8",
6345+
"get": "optional",
6346+
"id": "class_0279_custom_000005_epc_f3_1",
6347+
"manufacturer_code": 5,
6348+
"maximum": 253,
6349+
"minimum": 0,
6350+
"multipleOf": 0.1,
6351+
"name_en": "Input Current 1",
6352+
"name_ja": "入力電流1",
6353+
"set": "notApplicable",
6354+
"unit": "A"
6355+
},
6356+
{
6357+
"byte_offset": 1,
6358+
"epc": 243,
6359+
"format": "uint8",
6360+
"get": "optional",
6361+
"id": "class_0279_custom_000005_epc_f3_2",
6362+
"manufacturer_code": 5,
6363+
"maximum": 253,
6364+
"minimum": 0,
6365+
"multipleOf": 0.1,
6366+
"name_en": "Input Current 2",
6367+
"name_ja": "入力電流2",
6368+
"set": "notApplicable",
6369+
"unit": "A"
6370+
},
6371+
{
6372+
"byte_offset": 2,
6373+
"epc": 243,
6374+
"format": "uint8",
6375+
"get": "optional",
6376+
"id": "class_0279_custom_000005_epc_f3_3",
6377+
"manufacturer_code": 5,
6378+
"maximum": 253,
6379+
"minimum": 0,
6380+
"multipleOf": 0.1,
6381+
"name_en": "Input Current 3",
6382+
"name_ja": "入力電流3",
6383+
"set": "notApplicable",
6384+
"unit": "A"
6385+
},
6386+
{
6387+
"byte_offset": 3,
6388+
"epc": 243,
6389+
"format": "uint8",
6390+
"get": "optional",
6391+
"id": "class_0279_custom_000005_epc_f3_4",
6392+
"manufacturer_code": 5,
6393+
"maximum": 253,
6394+
"minimum": 0,
6395+
"multipleOf": 0.1,
6396+
"name_en": "Input Current 4",
6397+
"name_ja": "入力電流4",
6398+
"set": "notApplicable",
6399+
"unit": "A"
6400+
},
6401+
{
6402+
"byte_offset": 0,
6403+
"epc": 244,
6404+
"format": "uint16",
6405+
"get": "optional",
6406+
"id": "class_0279_custom_000005_epc_f4_1",
6407+
"manufacturer_code": 5,
6408+
"maximum": 65533,
6409+
"minimum": 0,
6410+
"multipleOf": 10,
6411+
"name_en": "Input Power 1",
6412+
"name_ja": "入力電力1",
6413+
"set": "notApplicable",
6414+
"unit": "W"
6415+
},
6416+
{
6417+
"byte_offset": 2,
6418+
"epc": 244,
6419+
"format": "uint16",
6420+
"get": "optional",
6421+
"id": "class_0279_custom_000005_epc_f4_2",
6422+
"manufacturer_code": 5,
6423+
"maximum": 65533,
6424+
"minimum": 0,
6425+
"multipleOf": 10,
6426+
"name_en": "Input Power 2",
6427+
"name_ja": "入力電力2",
6428+
"set": "notApplicable",
6429+
"unit": "W"
6430+
},
6431+
{
6432+
"byte_offset": 4,
6433+
"epc": 244,
6434+
"format": "uint16",
6435+
"get": "optional",
6436+
"id": "class_0279_custom_000005_epc_f4_3",
6437+
"manufacturer_code": 5,
6438+
"maximum": 65533,
6439+
"minimum": 0,
6440+
"multipleOf": 10,
6441+
"name_en": "Input Power 3",
6442+
"name_ja": "入力電力3",
6443+
"set": "notApplicable",
6444+
"unit": "W"
6445+
},
6446+
{
6447+
"byte_offset": 6,
6448+
"epc": 244,
6449+
"format": "uint16",
6450+
"get": "optional",
6451+
"id": "class_0279_custom_000005_epc_f4_4",
6452+
"manufacturer_code": 5,
6453+
"maximum": 65533,
6454+
"minimum": 0,
6455+
"multipleOf": 10,
6456+
"name_en": "Input Power 4",
6457+
"name_ja": "入力電力4",
6458+
"set": "notApplicable",
6459+
"unit": "W"
62846460
}
62856461
],
62866462
"name_en": "Household solar power generation",

src/pyhems/device_manager.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,28 @@ async def setup_device(self, node_id: str, eoj: EOJ) -> bool:
397397
bytes(sorted(inf_epcs)).hex(),
398398
)
399399

400+
if _LOGGER.isEnabledFor(logging.DEBUG):
401+
try:
402+
dump_results = await self._client.get(
403+
node_id, eoj, sorted(node.get_epcs)
404+
)
405+
responded = sum(1 for p in dump_results if p.edt)
406+
inf_only = sorted(node.inf_epcs - node.get_epcs)
407+
lines = [
408+
f" EPC 0x{p.epc:02X}: {p.edt.hex() if p.edt else '(no response)'}"
409+
for p in dump_results
410+
] + [f" EPC 0x{epc:02X}: (inf-only)" for epc in inf_only]
411+
_LOGGER.debug(
412+
"Debug dump for %s: %d get_epcs, %d responded, %d inf-only\n%s",
413+
device_key,
414+
len(node.get_epcs),
415+
responded,
416+
len(inf_only),
417+
"\n".join(lines),
418+
)
419+
except Exception:
420+
_LOGGER.debug("Debug dump failed for %s", device_key)
421+
400422
for cb in self._on_device_added:
401423
cb(device_key)
402424

0 commit comments

Comments
 (0)