『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: louis_lee

[新奇玩法] 【立省100%】小米系可视门铃本地存储

  [复制链接]

2

主题

12

帖子

166

积分

注册会员

Rank: 2

积分
166
金钱
154
HASS币
0
发表于 2023-11-21 09:41:53 | 显示全部楼层
本帖最后由 win741852 于 2023-11-21 09:55 编辑

求教楼主,运行过程中除了有延时以外感觉还都挺正常的,但是通过日志发现一直都有报错,麻烦楼主给分析下有没有影响

报错1:像是个解码问题?
Logger: homeassistant.components.stream.stream.camera.loock_t2pv1_7cd4_video_doorbell
Source: components/stream/__init__.py:431
Integration: Stream (documentation, issues)
First occurred: 09:19:16 (3 occurrences)
Last logged: 09:19:49

Error from stream worker: Error demuxing stream: [Errno 1094995529] Invalid data found when processing input: 'https://business.smartcamera.api.io.mi.com/common/app/m3u8?data=**************'; last error log: [mov,mp4,m4a,3gp,3g2,mj2] stream 0, offset 0x7f6: partial file



报错2:像是超时问题?
Logger: homeassistant.components.automation.door_video_autosave
Source: components/automation/__init__.py:655
Integration: 自动化 (documentation, issues)
First occurred: 2023年11月20日 15:25:11 (23 occurrences)
Last logged: 08:47:13

While executing automation automation.door_video_autosave
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/shell_command/__init__.py", line 92, in async_service_handler
    stdout_data, stderr_data = await process.communicate()
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/subprocess.py", line 200, in communicate
    stdin, stdout, stderr = await tasks.gather(stdin, stdout, stderr)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/subprocess.py", line 180, in _read_stream
    output = await stream.read()
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/streams.py", line 686, in read
    block = await self.read(self._limit)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/streams.py", line 693, in read
    await self._wait_for_data('read')
  File "/usr/local/lib/python3.11/asyncio/streams.py", line 525, in _wait_for_data
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 655, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1578, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/shell_command/__init__.py", line 91, in async_service_handler
    async with asyncio.timeout(COMMAND_TIMEOUT):
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError



报错3:
Logger: homeassistant.components.automation.door_video_autosave
Source: helpers/script.py:468
Integration: 自动化 (documentation, issues)
First occurred: 2023年11月20日 15:25:11 (23 occurrences)
Last logged: 08:47:13

door_video_autosave: Error executing script. Unexpected error for call_service at pos 1:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/shell_command/__init__.py", line 92, in async_service_handler
    stdout_data, stderr_data = await process.communicate()
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/subprocess.py", line 200, in communicate
    stdin, stdout, stderr = await tasks.gather(stdin, stdout, stderr)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/subprocess.py", line 180, in _read_stream
    output = await stream.read()
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/streams.py", line 686, in read
    block = await self.read(self._limit)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/streams.py", line 693, in read
    await self._wait_for_data('read')
  File "/usr/local/lib/python3.11/asyncio/streams.py", line 525, in _wait_for_data
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/shell_command/__init__.py", line 91, in async_service_handler
    async with asyncio.timeout(COMMAND_TIMEOUT):
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError


报错4:也是超时问题?
Logger: homeassistant.components.shell_command
Source: components/shell_command/__init__.py:94
Integration: Shell Command (documentation, issues)
First occurred: 2023年11月20日 15:25:11 (23 occurrences)
Last logged: 08:47:13

Timed out running command: `/bin/bash /config/xiaomi_video_autosave.sh "{{state_attr("camera.loock_t2pv1_7cd4_video_doorbell","stream_address")}}" "{{state_attr("camera.loock_t2pv1_7cd4_video_doorbell","motion_video_time")}}" `, after: 60s


回复

使用道具 举报

2

主题

30

帖子

228

积分

中级会员

Rank: 3Rank: 3

积分
228
金钱
198
HASS币
0
发表于 2023-11-30 11:18:57 | 显示全部楼层
此错误来自自定义集成。

Logger: custom_components.xiaomi_miot.camera
Source: custom_components/xiaomi_miot/camera.py:306
Integration: Xiaomi Miot Auto (documentation, issues)
First occurred: 10:07:48 (67 occurrences)
Last logged: 11:13:48

智能猫眼(chuangmi.cateye.ipc018): camera events is empty. {'result': 'ok', 'retriable': False, 'code': 0, 'data': {'thirdPartPlayUnits': [], 'nextTime': 1700708988000, 'isContinue': True}, 'description': '成功', 'ts': 1701313788247}
智能猫眼(chuangmi.cateye.ipc018): camera events is empty. {'result': 'ok', 'retriable': False, 'code': 0, 'data': {'thirdPartPlayUnits': [], 'nextTime': 1700709048000, 'isContinue': True}, 'description': '成功', 'ts': 1701313848232}
智能猫眼(chuangmi.cateye.ipc018): camera events is empty. {'result': 'ok', 'retriable': False, 'code': 0, 'data': {'thirdPartPlayUnits': [], 'nextTime': 1700709108000, 'isContinue': True}, 'description': '成功', 'ts': 1701313908242}
智能猫眼(chuangmi.cateye.ipc018): camera events is empty. {'result': 'ok', 'retriable': False, 'code': 0, 'data': {'thirdPartPlayUnits': [], 'nextTime': 1700709168000, 'isContinue': True}, 'description': '成功', 'ts': 1701313968244}
智能猫眼(chuangmi.cateye.ipc018): camera events is empty. {'result': 'ok', 'retriable': False, 'code': 0, 'data': {'thirdPartPlayUnits': [], 'nextTime': 1700709228000, 'isContinue': True}, 'description': '成功', 'ts': 1701314028250}

只有刚设置完后,nas上成功保存了一个视频,之后就再没生成过视频,看日志都是这个错误,events empty,why?
回复

使用道具 举报

0

主题

24

帖子

159

积分

注册会员

Rank: 2

积分
159
金钱
135
HASS币
0
发表于 2024-2-2 14:21:14 | 显示全部楼层
louis_lee 发表于 2023-3-15 13:48
如果你按照步骤执行下来,发现视频只有少部分片段,比如米家上看视频15秒,结果用本文方法看只有1-2秒。请 ...

用这个有些视频会丢失帧而且有些帧会变速快放
回复

使用道具 举报

0

主题

31

帖子

237

积分

中级会员

Rank: 3Rank: 3

积分
237
金钱
206
HASS币
0
发表于 2024-2-22 16:34:40 | 显示全部楼层
sleikang 发表于 2024-2-2 14:21
用这个有些视频会丢失帧而且有些帧会变速快放

一样请问你解决了吗
回复

使用道具 举报

27

主题

233

帖子

1797

积分

金牌会员

Rank: 6Rank: 6

积分
1797
金钱
1564
HASS币
0
发表于 2024-3-6 19:27:46 | 显示全部楼层
米家有个门锁X 是不是也能用?
回复

使用道具 举报

9

主题

163

帖子

2826

积分

论坛技术达人

积分
2826
金钱
2653
HASS币
50
发表于 2024-3-7 09:22:47 | 显示全部楼层
感谢大佬分享, 但有一个问题 , 就是 发现用 motion_video_time 当触发条件会有挺大的延迟,不知道这个延迟能否缩小?
回复

使用道具 举报

0

主题

21

帖子

142

积分

注册会员

Rank: 2

积分
142
金钱
121
HASS币
0
发表于 2024-3-7 22:25:26 | 显示全部楼层
只有声音没有图像是怎么个情况呀。。。
回复

使用道具 举报

5

主题

47

帖子

821

积分

论坛技术达人

积分
821
金钱
769
HASS币
20
发表于 2024-3-8 16:13:45 | 显示全部楼层
xxooooxx 发表于 2023-4-5 21:52
还是一样的超时错误,然后也没有视频生成,还是在temp文件夹里遗留一些碎文件,为啥只有我有这种问题出现呀 ...

我是这么解决的,新建了一个脚本,在里面后台执行,因为超时的话,会被杀掉,这就是为什么temp里面还有遗留的原因。
新建 main.sh 脚本,内容如下:
nohup /bin/bash /config/xiaomi_video_autosave.sh "$1" "$2" > out.log 2>&1 &
之前的脚本是所有的都在放在同一目录下,如果第一个没有处理完,又有新的进来,可能会导致文件不完整,修改 xiaomi_video_autosave.sh 把文件名获取提前,临时文件夹中加上文件名。
raw_file_name=`echo $2|sed 's/[^0-9]//g'`
temp_path="/config/xiaomi_video_temp/$raw_file_name/"
shell_command 中替换成 main.sh ,现在执行就会很快

                               
登录/注册后可看大图


                               
登录/注册后可看大图



回复

使用道具 举报

5

主题

58

帖子

737

积分

高级会员

Rank: 4

积分
737
金钱
679
HASS币
10
发表于 2024-3-14 08:51:58 | 显示全部楼层
视频存储目前看OK了,感谢楼主
但是使用gallery-card显示视频,的路径'media-source://media_source/videos/'   这块我是用容器运行的hass,存储路径设置在/config/xiaomi_video   在卡片里该如何设置路径啊,试了好几个都不行,在官网文档里也没看到如何设置?
回复

使用道具 举报

0

主题

21

帖子

200

积分

中级会员

Rank: 3Rank: 3

积分
200
金钱
179
HASS币
0
发表于 2024-3-15 15:33:13 | 显示全部楼层
视频预览卡片尺寸太大了,见附件。
我只添加了一个路径,想把高度改小一点,找了好多地方都没查到。
不知道有大佬解决过吗?
QQ截图20240315153021.jpg
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-5 03:05 , Processed in 0.158526 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表