Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
flatsiedatsie authored Nov 16, 2023
1 parent 70001a8 commit 882f40f
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 29 deletions.
7 changes: 6 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@
"name": "Homebridge",
"options": {
"default": {
"Rotate camera 180 degrees": false,
"Enable doorbell button": false,
"Doorbell button GPIO pin": 17,
"Separate the camera": false,
"Debugging": false
},
"schema": {
"properties": {
"Rotate camera 180 degrees": {
"type": "boolean",
"description": "If you have a camera module connected, then you can rotate it's output 180 degrees."
},
"Enable doorbell button": {
"type": "boolean",
"description": "If you have connected a button to your Raspberry Pi's GPIO pins, then you can have that button act as a doorbell button. This assumes you have also connected a Raspberry Pi camera, as the doorbell functionality is tied to the camera stream. You can change the default button pin (17) to something else under advanced settings. By default the doorbell button is disabled."
Expand All @@ -56,7 +61,7 @@
}
},
"short_name": "homebridge",
"version": "0.1.7",
"version": "0.1.8",
"web_accessible_resources": [
"css/*.css",
"images/*.svg",
Expand Down
85 changes: 58 additions & 27 deletions pkg/homebridge_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,36 +232,11 @@ def __init__(self, verbose=False):
self.privacy_preview_placed = False

self.unbridge_camera = False # faster if set to True, but more hassle for the end user
self.camera_config = {
"name": "Camera FFmpeg",
"porthttp": self.doorbell_port,
"cameras": [
{
"name": "Candle camera",
"manufacturer": "Candle",
"doorbell": True,
"switches": True,
"unbridge": False,
"videoConfig":
{
"source": "-i rtsp://localhost:" + str(self.rtsp_port) + "/pi",
"stillImageSource": "-i http://localhost:" + str(self.thumbnail_server_port) + "/thumbnail.jpg",
"maxWidth": 640,
"maxHeight": 480,
"maxFPS": 10,
"forceMax": True,
"additionalCommandline": "-x264-params intra-refresh=1:bframes=0",
"audio": False,
"≈": False
}
}
],
"platform": "Camera-ffmpeg"
}
self.flip_video_string = ''



#self.camera_config['cameras'][0]['unbridge'] = self.camera_config

# ring doorbell by requesting:
# http://hostname:8559/doorbell?Candle%20camera
Expand All @@ -286,6 +261,49 @@ def __init__(self, verbose=False):
print("Error loading config: " + str(ex))


self.homekit_camera_name = "Candle camera"
if self.use_doorbell_button:
self.homekit_camera_name = "Candle doorbell"

self.camera_config = {
"name": "Camera FFmpeg",
"porthttp": self.doorbell_port,
"cameras": [
{
"name": self.homekit_camera_name,
"manufacturer": "Candle",
"doorbell": True,
"switches": True,
"unbridge": self.unbridge_camera,
"videoConfig":
{
"source": "-i rtsp://localhost:" + str(self.rtsp_port) + "/pi", # + self.flip_video_string
"stillImageSource": "-i http://localhost:" + str(self.thumbnail_server_port) + "/thumbnail.jpg",
"maxWidth": 640,
"maxHeight": 480,
"maxFPS": 10,
"forceMax": False,
"audio": False,
#"≈": False,
"vcodec": "copy",
#"videoFilter": "scale=640x480",
# "returnAudioTarget": "2way -probesize 32 -analyzeduration 32 -c:a pcm_mulaw -ab 128k -ac 1 -f alsa default -ar 16000 -thread_queue_size 2048", #ffmpeg -i error82.wav -f alsa plughw
"returnAudioTarget": "-f alsa default",
"debug": True,
"debugReturn": True,
"videoFilter": "scale=640x480",
#"mapvideo": "1,0",
#"mapaudio": "0,0",
"packetSize": 752, # multiple of 188. originally was 1378
"additionalCommandline": "-x264-params intra-refresh=1:bframes=0",
}
}
],
"platform": "Camera-ffmpeg"
}



# create list of installed plugins
self.update_installed_plugins_list()

Expand Down Expand Up @@ -425,6 +443,19 @@ def add_from_config(self):
if self.DEBUG:
print("Doorbell button enabled preference was in config: " + str(self.use_doorbell_button))


if 'Rotate camera 180 degrees' in config:
if self.DEBUG:
print("Rotate camera 180 degrees preference was in config: " + str(config['Rotate camera 180 degrees']))
if bool(config['Rotate camera 180 degrees']) == True:
#self.flip_video_string = ' -vf \"transpose=1\"'
self.flip_video_string = ' -vf \"transpose=2,transpose=2\"'






if 'Separate the camera' in config:
self.unbridge_camera = bool(config['Separate the camera'])
if self.DEBUG:
Expand Down
9 changes: 8 additions & 1 deletion pkg/homebridge_api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,16 @@ def install_plugin(self,name,version="@latest"):
if self.DEBUG:
print("in install_plugin. Name: " + str(name) + " -> " + str(plugin_name_full))

p = subprocess.Popen([self.adapter.hb_npm_path,"install","--save",plugin_name_full], cwd=self.adapter.hb_plugins_path)
p = subprocess.Popen([self.adapter.hb_npm_path,"install","--unsafe-perm","--save",plugin_name_full], cwd=self.adapter.hb_plugins_path)
p.wait()

if name == 'homebridge-camera-ffmpeg':
if self.DEBUG:
print("homebridge-camera-ffmpeg -> Also installing ffmpeg-for-homebridge")
p = subprocess.Popen([self.adapter.hb_npm_path,"install","--save",'ffmpeg-for-homebridge'], cwd=self.adapter.hb_plugins_path)
p.wait()


self.adapter.update_installed_plugins_list()


Expand Down

0 comments on commit 882f40f

Please sign in to comment.