mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-26 04:39:53 +01:00
Compare commits
5 commits
df37860e27
...
8d0a58e391
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d0a58e391 | ||
|
|
4b1a54a41c | ||
|
|
dd367c9e43 | ||
|
|
b4e144afef | ||
|
|
bacbfe9fad |
2 changed files with 10 additions and 15 deletions
|
|
@ -121,13 +121,10 @@ async def handle_hass_get_state(conn: "ConnectionHandler", entity_id):
|
|||
+ str(response.json()["attributes"]["media_title"])
|
||||
+ " "
|
||||
)
|
||||
if "volume_level" in response.json()["attributes"]:
|
||||
responsetext = (
|
||||
responsetext
|
||||
+ "音量是:"
|
||||
+ str(response.json()["attributes"]["volume_level"])
|
||||
+ " "
|
||||
)
|
||||
volume_level = response.json()["attributes"].get("volume_level")
|
||||
if isinstance(volume_level, (int, float)):
|
||||
# volume_level 量程 0~1,换算成百分比(同 volume_set 的 1~100)
|
||||
responsetext = responsetext + "音量是:" + f"{round(volume_level * 100)}%" + " "
|
||||
if "color_temp_kelvin" in response.json()["attributes"]:
|
||||
responsetext = (
|
||||
responsetext
|
||||
|
|
@ -142,13 +139,11 @@ async def handle_hass_get_state(conn: "ConnectionHandler", entity_id):
|
|||
+ str(response.json()["attributes"]["rgb_color"])
|
||||
+ " "
|
||||
)
|
||||
if "brightness" in response.json()["attributes"]:
|
||||
responsetext = (
|
||||
responsetext
|
||||
+ "亮度是:"
|
||||
+ str(response.json()["attributes"]["brightness"])
|
||||
+ " "
|
||||
)
|
||||
brightness = response.json()["attributes"].get("brightness")
|
||||
if isinstance(brightness, (int, float)):
|
||||
# brightness 量程 0~255,换算成百分比(同 brightness_pct 的 1~100),开灯最低报 1%
|
||||
percent = max(1, round(brightness * 100 / 255)) if brightness > 0 else 0
|
||||
responsetext = responsetext + "亮度是:" + f"{percent}%" + " "
|
||||
logger.bind(tag=TAG).info(f"查询返回内容: {responsetext}")
|
||||
return responsetext
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ pyyml==0.0.2
|
|||
silero_vad==6.2.3
|
||||
opuslib_next==1.3.1
|
||||
pydub==0.25.1
|
||||
funasr==1.4.16
|
||||
funasr==1.4.17
|
||||
# transformers>=5 要求 torch>=2.6,与本项目 torch 2.2.2 冲突(会禁用 PyTorch,fun_local 加载不了模型)
|
||||
transformers<5
|
||||
openai==2.8.1
|
||||
|
|
|
|||
Loading…
Reference in a new issue