aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-02-27 00:01:50 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-02-27 00:01:50 +0300
commit7092c79b5693b239fec739c181d300301c434d22 (patch)
treeed1029051c70767d919a62f62fbac0ab6639e8c4
parentd638bb4f58bf81c60ef218204b1fba75cf16b36a (diff)
some include magic; add tools/ipcam_stream.py
-rwxr-xr-xbin/camera_node.py2
-rwxr-xr-xbin/electricity_calc.py2
-rwxr-xr-xbin/esp32_capture.py2
-rwxr-xr-xbin/esp32cam_capture_diff_node.py2
-rwxr-xr-xbin/gpiorelayd.py2
l---------bin/include_homekit.py1
-rwxr-xr-xbin/inverter_bot.py2
-rwxr-xr-xbin/inverter_mqtt_util.py2
-rwxr-xr-xbin/inverterd_emulator.py2
-rwxr-xr-xbin/ipcam_capture.py2
-rwxr-xr-xbin/ipcam_ntp_util.py2
-rwxr-xr-xbin/ipcam_server.py2
-rwxr-xr-xbin/lugovaya_pump_mqtt_bot.py2
-rwxr-xr-xbin/mqtt_node_util.py2
-rwxr-xr-xbin/openwrt_log_analyzer.py2
-rwxr-xr-xbin/openwrt_logger.py2
-rw-r--r--bin/pio_build.py2
-rwxr-xr-xbin/pio_ini.py2
-rwxr-xr-xbin/polaris_kettle_bot.py2
-rwxr-xr-xbin/polaris_kettle_util.py2
-rwxr-xr-xbin/pump_bot.py2
-rwxr-xr-xbin/pump_mqtt_bot.py2
-rwxr-xr-xbin/relay_mqtt_bot.py2
-rwxr-xr-xbin/relay_mqtt_http_proxy.py2
-rwxr-xr-xbin/sensors_bot.py2
-rwxr-xr-xbin/sound_bot.py2
-rwxr-xr-xbin/sound_node.py2
-rwxr-xr-xbin/sound_sensor_node.py2
-rwxr-xr-xbin/sound_sensor_server.py2
-rwxr-xr-xbin/ssh_tunnels_config_util.py2
-rwxr-xr-xbin/temphum_mqtt_node.py2
-rwxr-xr-xbin/temphum_mqtt_receiver.py2
-rwxr-xr-xbin/temphum_nodes_util.py2
-rwxr-xr-xbin/temphum_smbus_util.py2
-rwxr-xr-xbin/temphumd.py2
-rwxr-xr-xbin/vk_sms_checker.py2
-rwxr-xr-xbin/web_api.py2
-rwxr-xr-xbin/web_kbn.py2
-rw-r--r--include/py/homekit/camera/types.py6
-rw-r--r--include_homekit.py (renamed from bin/__py_include.py)0
-rw-r--r--test/__py_include.py9
l---------test/include_homekit.py1
-rwxr-xr-xtest/mqtt_relay_server_util.py2
-rwxr-xr-xtest/mqtt_relay_util.py2
-rwxr-xr-xtest/test_amixer.py2
-rwxr-xr-xtest/test_api.py2
-rwxr-xr-xtest/test_esp32_cam.py2
-rwxr-xr-xtest/test_inverter_monitor.py2
-rw-r--r--test/test_ipcam_server_cleanup.py2
-rwxr-xr-xtest/test_modems.py2
-rwxr-xr-xtest/test_polaris_stuff.py2
-rwxr-xr-xtest/test_record_upload.py2
-rwxr-xr-xtest/test_send_fake_sound_hit.py2
-rwxr-xr-xtest/test_sound_node_client.py2
-rwxr-xr-xtest/test_sound_server_api.py2
-rwxr-xr-xtest/test_stopwatch.py2
-rw-r--r--test/test_telegram_aio_send_photo.py2
l---------tools/include_homekit.py1
-rwxr-xr-xtools/ipcam_stream.py38
59 files changed, 96 insertions, 64 deletions
diff --git a/bin/camera_node.py b/bin/camera_node.py
index 1485557..039b3c7 100755
--- a/bin/camera_node.py
+++ b/bin/camera_node.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import asyncio
import time
-import __py_include
+import include_homekit
from homekit.config import config
from homekit.media import MediaNodeServer, ESP32CameraRecordStorage, CameraRecorder
diff --git a/bin/electricity_calc.py b/bin/electricity_calc.py
index cff2327..a183095 100755
--- a/bin/electricity_calc.py
+++ b/bin/electricity_calc.py
@@ -3,7 +3,7 @@ import logging
import os
import sys
import inspect
-import __py_include
+import include_homekit
from homekit.config import config # do not remove this import!
from datetime import datetime, timedelta
diff --git a/bin/esp32_capture.py b/bin/esp32_capture.py
index 839114d..c710b23 100755
--- a/bin/esp32_capture.py
+++ b/bin/esp32_capture.py
@@ -2,7 +2,7 @@
import asyncio
import logging
import os.path
-import __py_include
+import include_homekit
from argparse import ArgumentParser
from homekit.camera.esp32 import WebClient
diff --git a/bin/esp32cam_capture_diff_node.py b/bin/esp32cam_capture_diff_node.py
index d664c6d..b383222 100755
--- a/bin/esp32cam_capture_diff_node.py
+++ b/bin/esp32cam_capture_diff_node.py
@@ -3,7 +3,7 @@ import asyncio
import logging
import os.path
import tempfile
-import __py_include
+import include_homekit
import homekit.telegram.aio as telegram
from homekit.config import config
diff --git a/bin/gpiorelayd.py b/bin/gpiorelayd.py
index 89ba78e..022bc81 100755
--- a/bin/gpiorelayd.py
+++ b/bin/gpiorelayd.py
@@ -2,7 +2,7 @@
import logging
import os
import sys
-import __py_include
+import include_homekit
from argparse import ArgumentParser
from homekit.util import Addr
diff --git a/bin/include_homekit.py b/bin/include_homekit.py
new file mode 120000
index 0000000..0cb1486
--- /dev/null
+++ b/bin/include_homekit.py
@@ -0,0 +1 @@
+../include_homekit.py \ No newline at end of file
diff --git a/bin/inverter_bot.py b/bin/inverter_bot.py
index 0be5866..afa9727 100755
--- a/bin/inverter_bot.py
+++ b/bin/inverter_bot.py
@@ -6,7 +6,7 @@ import json
import itertools
import sys
import asyncio
-import __py_include
+import include_homekit
from inverterd import Format, InverterError
from html import escape
diff --git a/bin/inverter_mqtt_util.py b/bin/inverter_mqtt_util.py
index 6003c62..cf64b66 100755
--- a/bin/inverter_mqtt_util.py
+++ b/bin/inverter_mqtt_util.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from argparse import ArgumentParser
from homekit.config import config
diff --git a/bin/inverterd_emulator.py b/bin/inverterd_emulator.py
index 371d955..413f88d 100755
--- a/bin/inverterd_emulator.py
+++ b/bin/inverterd_emulator.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import logging
-import __py_include
+import include_homekit
from homekit.inverter.emulator import InverterEmulator
diff --git a/bin/ipcam_capture.py b/bin/ipcam_capture.py
index 25b101d..8968a0d 100755
--- a/bin/ipcam_capture.py
+++ b/bin/ipcam_capture.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import sys
import os
import subprocess
diff --git a/bin/ipcam_ntp_util.py b/bin/ipcam_ntp_util.py
index 0461cc2..fd9d7f9 100755
--- a/bin/ipcam_ntp_util.py
+++ b/bin/ipcam_ntp_util.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import hikvision, xmeye
from enum import Enum, auto
diff --git a/bin/ipcam_server.py b/bin/ipcam_server.py
index cb2711c..f70afa7 100755
--- a/bin/ipcam_server.py
+++ b/bin/ipcam_server.py
@@ -4,7 +4,7 @@ import os
import asyncio
import time
import shutil
-import __py_include
+import include_homekit
import homekit.telegram.aio as telegram
diff --git a/bin/lugovaya_pump_mqtt_bot.py b/bin/lugovaya_pump_mqtt_bot.py
index 85402d1..fb56a25 100755
--- a/bin/lugovaya_pump_mqtt_bot.py
+++ b/bin/lugovaya_pump_mqtt_bot.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import datetime
-import __py_include
+import include_homekit
from enum import Enum
from typing import Optional
diff --git a/bin/mqtt_node_util.py b/bin/mqtt_node_util.py
index 657fcf9..0c9ea3d 100755
--- a/bin/mqtt_node_util.py
+++ b/bin/mqtt_node_util.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import os.path
-import __py_include
+import include_homekit
from time import sleep
from typing import Optional
diff --git a/bin/openwrt_log_analyzer.py b/bin/openwrt_log_analyzer.py
index 5b14a2f..e414af1 100755
--- a/bin/openwrt_log_analyzer.py
+++ b/bin/openwrt_log_analyzer.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import homekit.telegram as telegram
from homekit.telegram.config import TelegramChatsConfig
diff --git a/bin/openwrt_logger.py b/bin/openwrt_logger.py
index ec67542..4122042 100755
--- a/bin/openwrt_logger.py
+++ b/bin/openwrt_logger.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import os
-import __py_include
+import include_homekit
from datetime import datetime
from typing import Tuple, List, Optional
diff --git a/bin/pio_build.py b/bin/pio_build.py
index 539df44..dd54128 100644
--- a/bin/pio_build.py
+++ b/bin/pio_build.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
if __name__ == '__main__':
print('TODO') \ No newline at end of file
diff --git a/bin/pio_ini.py b/bin/pio_ini.py
index ee85732..3eac3b2 100755
--- a/bin/pio_ini.py
+++ b/bin/pio_ini.py
@@ -2,7 +2,7 @@
import os
import yaml
import re
-import __py_include
+import include_homekit
from argparse import ArgumentParser, ArgumentError
from homekit.pio import get_products, platformio_ini
diff --git a/bin/polaris_kettle_bot.py b/bin/polaris_kettle_bot.py
index 05c2aae..eeedd4c 100755
--- a/bin/polaris_kettle_bot.py
+++ b/bin/polaris_kettle_bot.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
from __future__ import annotations
-import __py_include
+import include_homekit
import logging
import locale
import queue
diff --git a/bin/polaris_kettle_util.py b/bin/polaris_kettle_util.py
index 4db0ed4..fa4f78e 100755
--- a/bin/polaris_kettle_util.py
+++ b/bin/polaris_kettle_util.py
@@ -4,7 +4,7 @@
import logging
import sys
import paho.mqtt.client as mqtt
-import __py_include
+import include_homekit
from typing import Optional
from argparse import ArgumentParser
diff --git a/bin/pump_bot.py b/bin/pump_bot.py
index e00e844..1e9a602 100755
--- a/bin/pump_bot.py
+++ b/bin/pump_bot.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import sys
import asyncio
diff --git a/bin/pump_mqtt_bot.py b/bin/pump_mqtt_bot.py
index aea1451..6ef5dc8 100755
--- a/bin/pump_mqtt_bot.py
+++ b/bin/pump_mqtt_bot.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import datetime
-import __py_include
+import include_homekit
from enum import Enum
from typing import Optional
diff --git a/bin/relay_mqtt_bot.py b/bin/relay_mqtt_bot.py
index 3ad0a9b..226329f 100755
--- a/bin/relay_mqtt_bot.py
+++ b/bin/relay_mqtt_bot.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import sys
-import __py_include
+import include_homekit
from enum import Enum
from typing import Optional, Union
diff --git a/bin/relay_mqtt_http_proxy.py b/bin/relay_mqtt_http_proxy.py
index 866ead3..76ccb37 100755
--- a/bin/relay_mqtt_http_proxy.py
+++ b/bin/relay_mqtt_http_proxy.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import logging
-import __py_include
+import include_homekit
from aiohttp import web
from homekit import http
diff --git a/bin/sensors_bot.py b/bin/sensors_bot.py
index 43932e1..5b84c6a 100755
--- a/bin/sensors_bot.py
+++ b/bin/sensors_bot.py
@@ -4,7 +4,7 @@ import socket
import logging
import re
import gc
-import __py_include
+import include_homekit
from io import BytesIO
from typing import Optional
diff --git a/bin/sound_bot.py b/bin/sound_bot.py
index fa22ba7..ee6e82c 100755
--- a/bin/sound_bot.py
+++ b/bin/sound_bot.py
@@ -2,7 +2,7 @@
import logging
import os
import tempfile
-import __py_include
+import include_homekit
from enum import Enum
from datetime import datetime, timedelta
diff --git a/bin/sound_node.py b/bin/sound_node.py
index 4d0172c..608f131 100755
--- a/bin/sound_node.py
+++ b/bin/sound_node.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import os
-import __py_include
+import include_homekit
from typing import Optional
diff --git a/bin/sound_sensor_node.py b/bin/sound_sensor_node.py
index 39c3905..e178f39 100755
--- a/bin/sound_sensor_node.py
+++ b/bin/sound_sensor_node.py
@@ -2,7 +2,7 @@
import logging
import os
import sys
-import __py_include
+import include_homekit
from homekit.config import config
from homekit.util import Addr
diff --git a/bin/sound_sensor_server.py b/bin/sound_sensor_server.py
index fd7ff5a..3af64e2 100755
--- a/bin/sound_sensor_server.py
+++ b/bin/sound_sensor_server.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import logging
import threading
-import __py_include
+import include_homekit
from time import sleep
from typing import Optional, List, Dict, Tuple
diff --git a/bin/ssh_tunnels_config_util.py b/bin/ssh_tunnels_config_util.py
index d08a4f4..691c2ac 100755
--- a/bin/ssh_tunnels_config_util.py
+++ b/bin/ssh_tunnels_config_util.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from homekit.config import config
if __name__ == '__main__':
diff --git a/bin/temphum_mqtt_node.py b/bin/temphum_mqtt_node.py
index 68ac579..0234211 100755
--- a/bin/temphum_mqtt_node.py
+++ b/bin/temphum_mqtt_node.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import asyncio
import logging
diff --git a/bin/temphum_mqtt_receiver.py b/bin/temphum_mqtt_receiver.py
index e9ee397..355e86b 100755
--- a/bin/temphum_mqtt_receiver.py
+++ b/bin/temphum_mqtt_receiver.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import paho.mqtt.client as mqtt
import re
-import __py_include
+import include_homekit
from homekit.config import config
from homekit.mqtt import MqttWrapper, MqttNode
diff --git a/bin/temphum_nodes_util.py b/bin/temphum_nodes_util.py
index aa46494..4015f19 100755
--- a/bin/temphum_nodes_util.py
+++ b/bin/temphum_nodes_util.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from homekit.mqtt.temphum import MqttTempHumNodes
diff --git a/bin/temphum_smbus_util.py b/bin/temphum_smbus_util.py
index 1cfaa84..48ec4f8 100755
--- a/bin/temphum_smbus_util.py
+++ b/bin/temphum_smbus_util.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from argparse import ArgumentParser
from homekit.temphum import SensorType
diff --git a/bin/temphumd.py b/bin/temphumd.py
index 9ea436d..2585148 100755
--- a/bin/temphumd.py
+++ b/bin/temphumd.py
@@ -2,7 +2,7 @@
import asyncio
import json
import logging
-import __py_include
+import include_homekit
from typing import Optional
diff --git a/bin/vk_sms_checker.py b/bin/vk_sms_checker.py
index 07d9953..ef25278 100755
--- a/bin/vk_sms_checker.py
+++ b/bin/vk_sms_checker.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import re
from html import escape
diff --git a/bin/web_api.py b/bin/web_api.py
index 1804b30..5b6733f 100755
--- a/bin/web_api.py
+++ b/bin/web_api.py
@@ -2,7 +2,7 @@
import asyncio
import json
import os
-import __py_include
+import include_homekit
from datetime import datetime, timedelta
diff --git a/bin/web_kbn.py b/bin/web_kbn.py
index f891675..9629598 100755
--- a/bin/web_kbn.py
+++ b/bin/web_kbn.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import asyncio
import logging
import jinja2
diff --git a/include/py/homekit/camera/types.py b/include/py/homekit/camera/types.py
index aa35ebf..5db4961 100644
--- a/include/py/homekit/camera/types.py
+++ b/include/py/homekit/camera/types.py
@@ -25,16 +25,16 @@ class CameraType(Enum):
elif channel == 2:
if self.is_hikvision():
return '/Streaming/Channels/2'
- elif self.value == CameraType.XMEYE:
+ elif self.is_xmeye():
return '/?stream=1.sdp'
else:
raise ValueError(f'unsupported camera type {self.value}')
def get_codec(self, channel: int) -> VideoCodecType:
if channel == 1:
- return VideoCodecType.H264 if self.value == CameraType.HIKVISION_264 else VideoCodecType.H265
+ return VideoCodecType.H264 if self == CameraType.HIKVISION_264 else VideoCodecType.H265
elif channel == 2:
- return VideoCodecType.H265 if self.value == CameraType.XMEYE else VideoCodecType.H264
+ return VideoCodecType.H265 if self == CameraType.XMEYE else VideoCodecType.H264
else:
raise ValueError(f'unexpected channel {channel}')
diff --git a/bin/__py_include.py b/include_homekit.py
index 8f98830..8f98830 100644
--- a/bin/__py_include.py
+++ b/include_homekit.py
diff --git a/test/__py_include.py b/test/__py_include.py
deleted file mode 100644
index 8f98830..0000000
--- a/test/__py_include.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import sys
-import os.path
-
-for _name in ('include/py',):
- sys.path.extend([
- os.path.realpath(
- os.path.join(os.path.dirname(os.path.join(__file__)), '..', _name)
- )
- ]) \ No newline at end of file
diff --git a/test/include_homekit.py b/test/include_homekit.py
new file mode 120000
index 0000000..0cb1486
--- /dev/null
+++ b/test/include_homekit.py
@@ -0,0 +1 @@
+../include_homekit.py \ No newline at end of file
diff --git a/test/mqtt_relay_server_util.py b/test/mqtt_relay_server_util.py
index 6c02d75..013d876 100755
--- a/test/mqtt_relay_server_util.py
+++ b/test/mqtt_relay_server_util.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from homekit.config import config
diff --git a/test/mqtt_relay_util.py b/test/mqtt_relay_util.py
index efa5588..ec79027 100755
--- a/test/mqtt_relay_util.py
+++ b/test/mqtt_relay_util.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from argparse import ArgumentParser
from homekit.config import config
diff --git a/test/test_amixer.py b/test/test_amixer.py
index e4abc73..1a78592 100755
--- a/test/test_amixer.py
+++ b/test/test_amixer.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from argparse import ArgumentParser
from homekit.config import config
diff --git a/test/test_api.py b/test/test_api.py
index b35a597..ed40526 100755
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from homekit.api import WebApiClient
from homekit.config import config
diff --git a/test/test_esp32_cam.py b/test/test_esp32_cam.py
index 962768f..6296dcd 100755
--- a/test/test_esp32_cam.py
+++ b/test/test_esp32_cam.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from pprint import pprint
from argparse import ArgumentParser
diff --git a/test/test_inverter_monitor.py b/test/test_inverter_monitor.py
index 3231bab..ccb5d8f 100755
--- a/test/test_inverter_monitor.py
+++ b/test/test_inverter_monitor.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from enum import Enum, auto
from typing import Optional
diff --git a/test/test_ipcam_server_cleanup.py b/test/test_ipcam_server_cleanup.py
index ae8d31c..b627fd9 100644
--- a/test/test_ipcam_server_cleanup.py
+++ b/test/test_ipcam_server_cleanup.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import logging
import os
import shutil
diff --git a/test/test_modems.py b/test/test_modems.py
index 39981f7..84cb1a7 100755
--- a/test/test_modems.py
+++ b/test/test_modems.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from homekit.modem import E3372, ModemsConfig
diff --git a/test/test_polaris_stuff.py b/test/test_polaris_stuff.py
index 7778667..88b23b9 100755
--- a/test/test_polaris_stuff.py
+++ b/test/test_polaris_stuff.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import syncleo
diff --git a/test/test_record_upload.py b/test/test_record_upload.py
index f9c83d8..ae9f8cc 100755
--- a/test/test_record_upload.py
+++ b/test/test_record_upload.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import logging
import time
diff --git a/test/test_send_fake_sound_hit.py b/test/test_send_fake_sound_hit.py
index 3cc3e50..1c38113 100755
--- a/test/test_send_fake_sound_hit.py
+++ b/test/test_send_fake_sound_hit.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from argparse import ArgumentParser
from homekit.util import send_datagram, stringify, Addr
diff --git a/test/test_sound_node_client.py b/test/test_sound_node_client.py
index c3748ca..247cc69 100755
--- a/test/test_sound_node_client.py
+++ b/test/test_sound_node_client.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
from homekit.api.errors import ApiResponseError
from homekit.media import SoundNodeClient
diff --git a/test/test_sound_server_api.py b/test/test_sound_server_api.py
index 11cd422..85f6ce2 100755
--- a/test/test_sound_server_api.py
+++ b/test/test_sound_server_api.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import threading
from time import sleep
diff --git a/test/test_stopwatch.py b/test/test_stopwatch.py
index 1da0fe7..efcf936 100755
--- a/test/test_stopwatch.py
+++ b/test/test_stopwatch.py
@@ -1,4 +1,4 @@
-import __py_include
+import include_homekit
from homekit.util import Stopwatch, StopwatchError
from time import sleep
diff --git a/test/test_telegram_aio_send_photo.py b/test/test_telegram_aio_send_photo.py
index 019fa92..9f591c4 100644
--- a/test/test_telegram_aio_send_photo.py
+++ b/test/test_telegram_aio_send_photo.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import __py_include
+import include_homekit
import asyncio
import homekit.telegram.aio as telegram
diff --git a/tools/include_homekit.py b/tools/include_homekit.py
new file mode 120000
index 0000000..0cb1486
--- /dev/null
+++ b/tools/include_homekit.py
@@ -0,0 +1 @@
+../include_homekit.py \ No newline at end of file
diff --git a/tools/ipcam_stream.py b/tools/ipcam_stream.py
new file mode 100755
index 0000000..9cf99d6
--- /dev/null
+++ b/tools/ipcam_stream.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+import include_homekit
+import subprocess
+import sys
+
+from argparse import ArgumentParser, ArgumentError
+from homekit.camera import IpcamConfig
+
+if __name__ == '__main__':
+ players = ('mpv', 'vlc')
+ parser = ArgumentParser()
+ parser.add_argument('--tcp', action='store_true',
+ help='use tcp for rtsp')
+ parser.add_argument('--player', type=str, choices=players, default=players[0],
+ help='player to use')
+ parser.add_argument('--low', action='store_true',
+ help='use second channel')
+ parser.add_argument('camera', metavar='CAMERA', type=int, nargs=1,
+ help='number of camera to stream')
+ args = parser.parse_args()
+
+ ic = IpcamConfig()
+ camera = args.camera[0]
+ if not ic.has_camera(camera):
+ raise ArgumentError(None, f'invalid camera {camera}')
+
+ cmd = [args.player]
+ if args.tcp:
+ cmd.extend(['--rtsp-transport=tcp', '--force-seekable=yes'])
+ ip = ic.get_camera_ip(camera)
+ username, password = ic.get_rtsp_creds()
+ uri = f'rtsp://{username}:{password}@{ip}:554'
+ uri += ic.get_camera_type(camera).get_channel_url(1 if not args.low else 2)
+ cmd.append(uri)
+
+ p = subprocess.run(cmd, capture_output=False)
+ if p.returncode != 0:
+ print(f'error: {args.player} returned {p.returncode}', file=sys.stderr) \ No newline at end of file