Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config Changes Not Being Saved #579

Closed
Wildcat1 opened this issue Jun 29, 2020 · 16 comments
Closed

Config Changes Not Being Saved #579

Wildcat1 opened this issue Jun 29, 2020 · 16 comments
Labels

Comments

@Wildcat1
Copy link

Wildcat1 commented Jun 29, 2020

Describe The Bug:
Starting in 2.0.x seeing that any changes to cameras after initial setup do not get reflected in config. NOTE: Seeing this in the release version of 2.0.x and the beta

To Reproduce:

Using 2.0.x add a camera in with a set criteria (regular -re -i {stream} etc).

  1. After saving and rebooting Homebridge go back into the Config or Plugins, Settings and adjust a parameter, save, reboot again.
  2. After doing this I find that the config is showing the previous (original) version, not updating the changes you made. SO for example if you change the IP address in step 1 and rebooting, the IP address is not updated.
  3. Again this happens whether you are using the Plugins / Settings option to update or directly updating the config.JSON
  4. What is strange is that if I remove the camera from Plugins / Settings, save, reboot then add from scratch, that update is reflected fine but cannot edit it afterwards.

Expected behavior:
Expect this to update the config.JSON and the camera-ffmpeg plugin to read the updated config

Logs:
Not seeing anything in the logs that pinpoints this issue currently but happy to provide.

Screenshots
So here is an example. When I run v2.0.x here is what the logs show when accessing the camera:

[6/29/2020, 4:48:41 PM] [Camera-ffmpeg] ffmpeg -rtsp_transport http -re -i rtsp://xxxxxxx:[email protected]:554/cam/realmonitor?channel=1&subtype=0 -t 1 -vf scale=1280:720 -f image2 -

HOWEVER, here is what the Plugins / Settings section shows (notice the lack of -rtsp_transport in the config):

Screenshot Of Plugins Settings For Camera FFMPEG

Same can be said if you look at the config.JSON therefore its as if after initial setup of v2.0.x that NO changes/updates even in the JSON are being read by the plugin

Screenshot of Config JSON For Camera FFMPEG

Here is what is shown in the Homebridge-UI logs which shows the config.json is being saved and again the config file itself reflects those changes BUT camera-ffmpeg is not reading them:

[6/29/2020, 5:04:21 PM] [Config] Changes to config.json saved.
[1593471861811] INFO (90189 on mycomputer.localdomain): request completed
reqId: 10
res: {
"statusCode": 201


**Homebridge Config:**

**Environment:**

* **Node.js Version**: v12.16.3
* **NPM Version**: 6.14.5
* **Homebridge Version**: 1.1.1
* **Homebridge Camera FFmpeg Version**: v2.0.2=beta13 but appeared on all versions of 2.0.x tested so far
* **Homebridge Config UI X Plugin Version**: v4.23.2
* **Operating System**: macOS

@Wildcat1 Wildcat1 added the bug label Jun 29, 2020
@dankokp
Copy link

dankokp commented Jun 30, 2020

I was able to reproduce it too. Was playing with different params for hours to find the best set and in the end realized I didn't even change anything 😭

@teymur1988
Copy link

I’m having the same issue. Rolled back to 1.3.0

@isramos
Copy link
Contributor

isramos commented Jun 30, 2020

I experienced the same issue. I think I found a temporary workaround which is to change the camera name when you make a change. For example, I renamed "Cam Driveway" to "Cam Driveway2" to force changes to be picked up.

@Supereg
Copy link
Member

Supereg commented Jul 1, 2020

Is this only happening on the latest version of camera-ffmpeg? Meaning is the plugin really the cause of this?
Cause plugins should not be involved with writing or reading the configuration file directly (some do nevertheless, but that's definitely not advised).

@donavanbecker donavanbecker changed the title Seeing Issues With Config Changes Not Being Saved After Initial Camera Addition Config Changes Not Being Saved Jul 1, 2020
@donavanbecker donavanbecker pinned this issue Jul 1, 2020
@longzheng
Copy link
Contributor

longzheng commented Jul 2, 2020

I've also reproduced this issue.

I'm able to temporarily fix this by removing the cameras in the Homebridge Config UI X > Homebridge Settings > Remove Single Cached Accessory. When Homebridge is restarted, then the new config is loaded.

@longzheng
Copy link
Contributor

Is this only happening on the latest version of camera-ffmpeg? Meaning is the plugin really the cause of this?
Cause plugins should not be involved with writing or reading the configuration file directly (some do nevertheless, but that's definitely not advised).

I suspect this was related to how v2.0.0 shows cameras a bridged instead of accessories in v1.3.0. I suspect maybe homebridge caches the config of bridged camera differently to accessories.

@Supereg
Copy link
Member

Supereg commented Jul 2, 2020

const cameraConfig = cameraAccessory.context.cameraConfig;

the plugin stores the configuration made when the camera was first set up and will ignore any further changes to the config made, as it will always just use the stored value

@ciavez
Copy link

ciavez commented Jul 2, 2020

  • I've updated the plugin with the latest BETA 2.0.2
  • empty the cache
  • restarted everything...

but still I get this

[2020-7-2 19:02:08] [Camera-ffmpeg] FFMPEG: [http @ 0x2f5b360] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[tcp @ 0x2f5ce60] Original list of addresses:
[tcp @ 0x2f5ce60] Address 192.168.8.166 port 554
[tcp @ 0x2f5ce60] Interleaved list of addresses:
[tcp @ 0x2f5ce60] Address 192.168.8.166 port 554
[tcp @ 0x2f5ce60] Starting connection attempt to 192.168.8.166 port 554

[2020-7-2 19:02:08] [Camera-ffmpeg] FFMPEG: [tcp @ 0x2f5ce60] Successfully connected to 192.168.8.166 port 554
[http @ 0x2f5b360]
[2020-7-2 19:02:08] [Camera-ffmpeg] FFMPEG: request: GET /videoMain HTTP/1.1
User-Agent: Lavf/58.29.100
Range: bytes=0-
Connection: close
Host: 192.168.8.166:554
Icy-MetaData: 1
x-sessioncookie: 6be697ab8b46455f
Accept: application/x-rtsp-tunnelled
Pragma: no-cache
Cache-Control: no-cache

[2020-7-2 19:02:08] [Camera-ffmpeg] FFMPEG: [http @ 0x2f5b360] HTTP error 400 Bad Request

[2020-7-2 19:02:08] [Camera-ffmpeg] FFMPEG: rtsp://ciava:[email protected]:554/videoMain: Input/output error

[2020-7-2 19:02:08] [Camera-ffmpeg] [FFMPEG] ffmpeg exited with code: 1 and signal: null (error)

@donavanbecker
Copy link
Contributor

donavanbecker commented Jul 2, 2020

@longzheng should be fixed in last merged and latest beta.

@donavanbecker donavanbecker unpinned this issue Jul 2, 2020
@Wildcat1
Copy link
Author

Wildcat1 commented Jul 2, 2020

@donavanbecker Latest beta is definitely an improvement to solving the streaming issues BUT I'm noticing that once I add a cam in the latest v2.0.2 beta 39 that any subsequent changes to that cam through the Plugin's\Settings option results in Homebridge not being able to restart as it kicks out the error below. Only way to resolve is to remove Platform, remove cached device and start over. Thoughts on this ? Thanks again

Cannot add a Service with the same UUID 'xxxxxxxx7xxxxx5xx91' as another Service in this Accessory without also defining a unique 'subtype' property.
at Accessory._this.addService (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:276:17)
at PlatformAccessory.addService (/usr/local/lib/node_modules/homebridge/src/platformAccessory.ts:92:41)
at FfmpegPlatform.configureAccessory (/usr/local/lib/node_modules/homebridge-camera-ffmpeg/src/index.ts:123:12)
at /usr/local/lib/node_modules/homebridge/src/server.ts:307:25
at Array.filter ()
at Server.restoreCachedPlatformAccessories (/usr/local/lib/node_modules/homebridge/src/server.ts:270:69)
at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:158:10)
at cli (/usr/local/lib/node_modules/homebridge/src/cli.ts:80:10)
at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (internal/modules/cjs/loader.js:1133:30)

@donavanbecker
Copy link
Contributor

@donavanbecker Latest beta is definitely an improvement to solving the streaming issues BUT I'm noticing that once I add a cam in the latest v2.0.2 beta 39 that any subsequent changes to that cam through the Plugin's\Settings option results in Homebridge not being able to restart as it kicks out the error below. Only way to resolve is to remove Platform, remove cached device and start over. Thoughts on this ? Thanks again

I wonder if you got this be cause the cache was still there. Has it happen again?

@Wildcat1
Copy link
Author

Wildcat1 commented Jul 2, 2020

@donavanbecker Latest beta is definitely an improvement to solving the streaming issues BUT I'm noticing that once I add a cam in the latest v2.0.2 beta 39 that any subsequent changes to that cam through the Plugin's\Settings option results in Homebridge not being able to restart as it kicks out the error below. Only way to resolve is to remove Platform, remove cached device and start over. Thoughts on this ? Thanks again

I wonder if you got this be cause the cache was still there. Has it happen again?

I can literally replicate this over and over. What is weird is it gets into that loop RE: (another service with same UUID) even if I use cam names I had before installing this beta. Steps to reproduce this and then fix are:

To Cause The Issue:
1 - Start with fresh plugin (beta 39 and all cached cams removed using Homebridge menu)
2 - Add camera
3 - Restart homebridge
4 - Camera appears without issue
5 - Go back into plugin settings OR config.json and adjust a setting OR add a new camera
6 - Restart Homebridge
7 - Homebridge never restarts getting stuck in the 'another service with same UUID.......' error

To Fix The Issue
1 - Go into Plugin\Settings
2 - Remove camera completely
3 - Go to Homebridge menu, remove cached camera(s), this leaves only "platform": "Camera-ffmpeg" in config.json.
4 - Restart Homebridge
5 - Homebridge restarts without issue

The problem of course is 1) somewhere, previous cam names are being stored so seemingly can only be used once and 2) that due to the error being seen, if you need to adjust ANYTHING or add a new camera you will be forced to remove the existing cameras completely, remove cached cams and start from scratch

Thoughts on how to get around this or can be fixed in the plugin @donavanbecker ?

@Wildcat1
Copy link
Author

Wildcat1 commented Jul 2, 2020

@donavanbecker to follow up to my comment above, even just removing cached cam or renaming cam (for update in config) by themselves does not appear to fix the issue. Only removing the cam then removing the cache and restarting does it resolve the restart issue of 'service with same name'. This means that to update or add any extra cams you literally have to start from scratch each time.

@longzheng
Copy link
Contributor

I can confirm v2.0.2-beta.39 fixes the config issue for me.

I can

  • Edit the video for the existing camera (without renaming the camera)
  • Restart homebridge
  • View the camera with the new config in Home app immediately

@Wildcat1
Copy link
Author

Wildcat1 commented Jul 2, 2020

I can confirm v2.0.2-beta.39 fixes the config issue for me.

I can

  • Edit the video for the existing camera (without renaming the camera)
  • Restart homebridge
  • View the camera with the new config in Home app immediately

@longzheng
As I am literally seeing the opposite of you:

  1. I have to change camera name and remove cache continually every time I update a setting
  2. Run into No Response issues at different times

Could you post you config.json specifically cam settings. Call out the cam's you are using (I'm using Dahua & Hik, Axis etc) and then the platform and version you are running on (I'm running macOS Hombridge UI 4.23.2, Node.js Version | v12.16.3, NPM v6.14.5) ? Maybe that will help pinpoint the issue with caching and response too

Thanks

@longzheng
Copy link
Contributor

I can confirm v2.0.2-beta.39 fixes the config issue for me.
I can

  • Edit the video for the existing camera (without renaming the camera)
  • Restart homebridge
  • View the camera with the new config in Home app immediately

@longzheng
As I am literally seeing the opposite of you:

  1. I have to change camera name and remove cache continually every time I update a setting
  2. Run into No Response issues at different times

Could you post you config.json specifically cam settings. Call out the cam's you are using (I'm using Dahua & Hik, Axis etc) and then the platform and version you are running on (I'm running macOS Hombridge UI 4.23.2, Node.js Version | v12.16.3, NPM v6.14.5) ? Maybe that will help pinpoint the issue with caching and response too

Thanks

Can I suggest you try null out your camera config, save, restart Homebridge, then add it all back in?

        {
            "cameras": [
            ],
            "platform": "Camera-ffmpeg"
        }

My config.json is very simple. I'm connecting to a Dahua NVR.

        {
            "cameras": [
                {
                    "name": "Front door",
                    "videoConfig": {
                        "source": "-rtsp_transport tcp -re -i rtsp://192.168.2.3:554/cam/realmonitor?channel=1&subtype=0",
                        "maxFPS": 20
                    }
                },
                {
                    "name": "Backyard",
                    "videoConfig": {
                        "source": "-rtsp_transport tcp -re -i rtsp://192.168.2.3:554/cam/realmonitor?channel=2&subtype=0",
                        "maxFPS": 20
                    }
                },
                {
                    "name": "Living",
                    "videoConfig": {
                        "source": "-rtsp_transport tcp -re -i rtsp://192.168.2.3:554/cam/realmonitor?channel=3&subtype=0",
                        "maxFPS": 20
                    }
                },
                {
                    "name": "Side",
                    "videoConfig": {
                        "source": "-rtsp_transport tcp -re -i rtsp://192.168.2.3:554/cam/realmonitor?channel=4&subtype=0",
                        "maxFPS": 20
                    }
                },
                {
                    "name": "Laundry",
                    "videoConfig": {
                        "source": "-rtsp_transport tcp -re -i rtsp://192.168.2.3:554/cam/realmonitor?channel=5&subtype=0",
                        "maxFPS": 20
                    }
                }
            ],
            "platform": "Camera-ffmpeg"
        }

In my test, I added "vflip": true to my front door camera, restarted homebridge, and then viewed the video and it was flipped. Then I removed vlip, restarted homebridge, and then viewed the video and it was normal again.

My versions are

Windows 10
homebridge v1.1.1
homebridge-config-ui-x v4.23.2
homebridge-camera-ffmpeg v2.0.2-beta.39
Node.js Version	v14.5.0
Npm Version	v6.4.1

donavanbecker added a commit that referenced this issue Jul 6, 2020
* Update CHANGELOG.md

* Add MQTT to motion Detect  (#572)

* Update package.json

* Update config.schema.json

* Update index.ts

* Add files via upload

* Update index.ts

* Update config.schema.json

* Update config.schema.json

* add prettier back

* Bump ts-jest from 25.5.1 to 26.1.1 (#578)

Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 25.5.1 to 26.1.1.
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md)
- [Commits](kulshekhar/ts-jest@v25.5.1...v26.1.1)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump jest from 26.0.1 to 26.1.0 (#577)

Bumps [jest](https://github.com/facebook/jest) from 26.0.1 to 26.1.0.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md)
- [Commits](jestjs/jest@v26.0.1...v26.1.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump typescript from 3.9.3 to 3.9.5 (#576)

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.9.3 to 3.9.5.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v3.9.3...v3.9.5)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* fix files in package.json

* Update package.json

* Update CHANGELOG.md

* Update index.ts (#585)

Just publish message to topic homebridge/motion
message is the name of camera with no space replace with _

{ "platform": "Camera-ffmpeg", "mqtt": "127.0.0.1", "topics": "homebridge/motion", "cameras": [ { "name": "Camera name", "motion": true, "videoConfig": { "source": "-re -i http://10.0.0.1", "stillImageSource": "-i http://10.0.0.1", "maxStreams": 5, "maxWidth": 1280, "maxHeight": 720, "maxFPS": 15, "maxBitrate": 1000 } } ] }

* Bump typescript from 3.9.3 to 3.9.5 (#582)

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.9.3 to 3.9.5.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v3.9.3...v3.9.5)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Donavan Becker <[email protected]>

* Bump jest from 26.0.1 to 26.1.0 (#581)

Bumps [jest](https://github.com/facebook/jest) from 26.0.1 to 26.1.0.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md)
- [Commits](jestjs/jest@v26.0.1...v26.1.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump ts-jest from 25.5.1 to 26.1.1 (#580)

Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 25.5.1 to 26.1.1.
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md)
- [Commits](kulshekhar/ts-jest@v25.5.1...v26.1.1)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Update streamingDelegate.ts

* Update streamingDelegate.ts

* Update streamingDelegate.ts

* Update streamingDelegate.ts

* Update streamingDelegate.ts

* Update streamingDelegate.ts

* Update streamingDelegate.ts

* Update streamingDelegate.ts

* Update streamingDelegate.ts

* Update streamingDelegate.ts

* Update config.schema.json

* Update index.ts

* Update index.ts

* Update index.ts

* Update index.ts

* reverting

* Update index.ts

* Update index.ts

* switches config option

* Update config.schema.json

* Update config.schema.json

* Update config.schema.json

* add doorbell switch

* move doorbell switch

* Update config.schema.json

* Update config.schema.json

* Update index.ts

* Update CHANGELOG.md

* Update config.schema.json

* Update config.schema.json

* Update config.schema.json

* Update index.ts

* Fix packetsize config and various refactoring (#591)

* Fix duplicate debug

* Set ffmpeg pkt_size to either config packetize or fallback to video.mtu

* Refactor ffmpegOpt to class properties

* Log "Starting video stream" without debug

This was the behaviour in v1.3.0
https://github.com/homebridge-plugins/homebridge-camera-ffmpeg/blob/2d07a3899059ae2c4326bc7d985de5af5d3228ae/ffmpeg.js#L429

* Also log "stopped streaming" without debug

* Tweak start video stream log to contain name of camera

* Ensure that configureAccessory always uses the latest configuration provided by the config file #579 (#593)

* Only create an mqtt client if a mqtt host is configured (#592)

* Update index.ts (#600)

* Update index.ts (#601)

* Tweak image snapshot to use -frames:v instead of -t (#602)

* Fix duplicate debug

* Set ffmpeg pkt_size to either config packetize or fallback to video.mtu

* Refactor ffmpegOpt to class properties

* Log "Starting video stream" without debug

This was the behaviour in v1.3.0
https://github.com/homebridge-plugins/homebridge-camera-ffmpeg/blob/2d07a3899059ae2c4326bc7d985de5af5d3228ae/ffmpeg.js#L429

* Also log "stopped streaming" without debug

* Tweak start video stream log to contain name of camera

* Tweak snapshot capture to use -frames:v instead of -t

The HAP-NodeJS camera example uses `-vframes 1` to capture just one frame https://github.com/homebridge/HAP-NodeJS/blob/master/src/accessories/Camera_accessory.ts#L71

`-frames:v` is the newer version of `-vframes` which is deprecated https://ffmpeg.org/ffmpeg.html#Video-Options

* Update index.ts (#605)

Just post same name that camera in message on topic homebridge/motion

* Support for MQTT Resetting of Motion Sensor (#606)

* Cleaned up formatting.

* Added support for MQTT resetting of motion sensor.

* Logging updates (#607)

* Update streamingDelegate.ts

* fix show of logs

* clean up

* Update streamingDelegate.ts

* Update CHANGELOG.md

Co-authored-by: fennec622 <[email protected]>
Co-authored-by: Brandon McFarlin <[email protected]>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Long Zheng <[email protected]>
Co-authored-by: Andi <[email protected]>
Co-authored-by: california444 <[email protected]>
Co-authored-by: David Maher <[email protected]>
Co-authored-by: Igor Ramos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants