olijouve / onvif2

Apache License 2.0
5 stars 3 forks source link

Zoom of FOSCAM FI9928P ONVIF Camera #1

Open ReaLogics opened 4 years ago

ReaLogics commented 4 years ago

Hi @olijouve

On the original ONVIF version you recently modified, zoom did not work on my Foscam FI9928P. Do you think this is an issue with FOSCAM firmware, or with ONVIF & libpyfoscam library? I am still waiting for FOSCAM R&D to respond to my inquiry that ODM zoom does not work with their camera... it could be a problem with ODM itself (sent them another ping today).

olijouve commented 4 years ago

Foscam firmware doesn’t support zoom for onvif. About libpyfoscam i’ve made a PR to add zoom support in the lib but the main developer doesn’t give any life sign and did not merged it yet/still. Without that merge we cannot move to the official HA foscam integration upgrade, or we do can but only as a custom component.

I’m working on a NodeRed smart & simple thermostat for my central heater, with dynamic input temperature sensors by time range. Should have finished it by the end of the week if my wife and daughter leave my few free time. I’ll look for a zoom enabled foscam custom component after that.

Otherwise, did you tested the new goto preset feature/service i’ve add in this onvif2 version ? It’s also a bit more reactive for me, do you experience it the same?

ReaLogics commented 4 years ago

I have done a little testing... here is some feedback.

Yes the preset GotoHome works... which is awesome! I have not tried setting custom presets yet.

The ContinuousMove distance attribute changes my camera pan/tilt motor speed.

The speed attribute does not seem to have any affect on pan/tilt operations.

When camera pan/tilt motor is moving and then execute move_mode: Stop, the camera does not stop and no error is logged.

I will give more time to this tomorrow.

olijouve commented 4 years ago

About setting Presets, Foscam has a limitation on it as you can only have 6 presets max. Also Foscam onvif support doesn't implement RemovePreset, that's a pitty ! That is why it is not implemented in my component yet. So to remove existing presets you have to use Foscam app/web interface.

About speed/distance, i didn't really modifyied original python moving function apart to add new moving mode based on the original parameters. ContinuousMove only takes velocity x and y for pan and tilt, and with the old service it is distance param that is used. Speed attribute is only used by Relative and Absolute move modes.

But you should better try new advanced moving service (onvif_ptz_advanced_move) instead. This one let you fine tune your move without any value transformation, so it is just like to pass native onvif coordinates to your camera(ODM style)

About Stop command it's an oversight, it's fixed in my last commit.

olijouve commented 4 years ago

But you should tried new advanced moving service (onvif_ptz_advanced_move) instead. This one let you fine tune your move without any value transformation, so it is just like to pass native onvif coordinates to your camera(ODM style)

About Stop command it's an oversight, it's fixed in my last commit.

@REALogics your feedback on previous 2 points would be appreciated, before you'll totally abandon onvif in favour of : https://github.com/olijouve/foscam2 Enjoy !

ReaLogics commented 4 years ago

move_mode: Stop has no affect on camera with new changes. Maybe it is not implemented in camera?

2020-02-01 07:29:41 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1835971472] Received {'type': 'call_service', 'domain': 'onvif', 'service': 'onvif_ptz_move', 'service_data': {'entity_id': 'camera.sentinel', 'move_mode': 'Stop'}, 'id': 37}
2020-02-01 07:29:41 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=onvif, service=onvif_ptz_move, service_data=entity_id=camera.sentinel, move_mode=Stop>
2020-02-01 07:29:41 DEBUG (MainThread) [custom_components.onvif2.camera] Calling Stop PTZ Move on camera 'Sentinel'| Pan = 0.00 | Tilt = 0.00 | Zoom = 0.00 | Speed = (0.5, 0.5, 0.5) | Timeout = 0.0
2020-02-01 07:29:41 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1835971472] Sending {'id': 37, 'type': 'result', 'success': True, 'result': {'context': Context(user_id='5e689420cf0144bab7af80bf56a45d00', parent_id=None, id='8b7ee6bc125546728cce2dfac321fd6a')}}

The ContinuousMove, RelativeMove, AbsoluteMove all produce ptz_vector dictionary error:

entity_id: camera.living_room_camera
move_mode: AbsoluteMove
ptz_vector: '-1,1,0'

Odd how FOSCAM's ONVIF cameras work better using CGI commands... AND they don't even mention CGI protocol in the camera specs!

The last release of libpyfoscam was March 2019. I am wondering if you will have same merging issues with libpyfoscam as in libpyonvif?

I have not tried FOSCAM/CGI component yet. If zoom is implemented in CGI and not ONVIF, then maybe that is the place to spend coding/testing efforts... and I would be happy to support you in testing with my camera.

olijouve commented 4 years ago

I’ll look what i did wrong for Stop command. It is supported as it’s the same command i use to simulate move timeout. Vectors has to be set like that: ptz _vector: [-1,1,0]

ReaLogics commented 4 years ago

PTZ Advance Moves - Continuous/Relative/Absolute do not accept negative settings in ptz_vector: [-1,1,0]. If I use [1,1,0] or any other positive numbers 0 to 1, then I get:

Failed to call service onvif/onvif_ptz_advanced_move. No namespace defined for 'Ter' ('Ter:PTZNotSupported')

Short of just using debug logging, I've spent many many hours trying to setup VS Code for HA break-point debugging on Windows. I'd like to help debug this stuff. However, it does not look like VS Code can provide the same HASS.IO frontend tab, as is true on RPi. What do you recommend for HA break-point debugging, or do you just do logging?

olijouve commented 4 years ago

Thanks for the feedback, it was a bug with voluptuous validator that don't allow negative values in array parameters. I've fixed it by passing strings in the values array :

ptz_vector: ["-1.0","1.0","0"]
speed_vector: ["1.0","1.0","1.0"]

Stop operation works for me, best to to it on long moves. I've tested it after a ContinuousMove with a continuous_timeout set to 0 or after a GotoHome operation.

Break point doesn't work on my VSCode with devcontainer HA but i haven't looked if it can be enable. Indeed i just use logger to watch some objects, i'm discovering HA dev and VSCode through the onvif component update.

olijouve commented 4 years ago

Odd how FOSCAM's ONVIF cameras work better using CGI commands... AND they don't even mention CGI protocol in the camera specs!

The last release of libpyfoscam was March 2019. I am wondering if you will have same merging issues with libpyfoscam as in libpyonvif?

I have not tried FOSCAM/CGI component yet. If zoom is implemented in CGI and not ONVIF, then maybe that is the place to spend coding/testing efforts... and I would be happy to support you in testing with my camera.

CGI interface is the legacy interface of the old cameras. From what i've seen in their Web UI, they have started to move on a websocket closed protocol so I think there is a risk that Foscam might disable CGI it in some futur new firmware releases and I would recommend you to DL and save/archive the actual firmware just in case...

libpyfoscam and libpyonvif are 2 different librairies and the foscam integration is based on libpyfoscam. I really don't feal to rewrite it over a new library. My PR is just ~15 days old so no need to worry yet, i'm confident it will be merge soon enough.

About spending effort on foscam integration, i'll have no time in near futur as i've got lots of renovation works to do in my house that consume my spare time and energy. libpyfoscam is very complete so it is "just" about HA services interfacing, some simple features could/should be add to HA, at least presets and IR lights control...