初始化config文件

This commit is contained in:
2026-08-24 21:55:33 +08:00
commit 80a05d172e
2983 changed files with 1221334 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
"""Helpers for node-red."""
from datetime import timedelta
from typing import Any
from homeassistant.helpers.json import JSONEncoder
class NodeRedJSONEncoder(JSONEncoder):
"""JSONEncoder that supports timedelta objects and falls back to the Home Assistant Encoder."""
def default(self, o: Any) -> Any:
"""Convert timedelta objects.
Hand other objects to the Home Assistant JSONEncoder.
"""
if isinstance(o, timedelta):
return o.total_seconds()
return JSONEncoder.default(self, o)