core icon indicating copy to clipboard operation
core copied to clipboard

generic camera does not keep stream orientation

Open Tom-Heitbrink opened this issue 1 year ago • 9 comments

The problem

When setting a orientation on the camera, it briefly changes position, but then reverts to the standard, and the value is not saved.

What version of Home Assistant Core has the issue?

2022.10.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

generic camera

Link to integration documentation on our website

https://www.home-assistant.io/integrations/generic

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Tom-Heitbrink avatar Oct 27 '22 13:10 Tom-Heitbrink

Hey there @davet2001, mind taking a look at this issue as it has been labeled with an integration (generic) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of generic can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant unassign generic Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


generic documentation generic source (message by IssueLinks)

home-assistant[bot] avatar Oct 27 '22 13:10 home-assistant[bot]

@Tom-Heitbrink Please could you provide some more detail on how to reproduce this issue?

I am not aware of any orientation controls, it could be that these are specific to your camera.

Any more information such as what make/model of camera you have, how are you are setting the orientation etc would be very helpful.

davet2001 avatar Oct 27 '22 16:10 davet2001

image

It's a Eminent camera, setup as a generic camera. The integration is generic camera, where I input the URL of the camera feed.

for some reason the feed is now (after a few reboots due to other changes) correct, my house has the roof on the topside again. The camera is attached on a 90 degree angle, therefore I need the feed to rotate 90 degrees.

Tom-Heitbrink avatar Oct 28 '22 07:10 Tom-Heitbrink

@uvjustin I was not aware of the new orientation feature added in #77439. Do you know why this might not be saving correctly? Not sure if this problem is specific to generic or whether it applies to all 'stream' entities.

davet2001 avatar Oct 28 '22 14:10 davet2001

@davet2001 I'm not sure. I haven't noticed this and can't reproduce it. Are you able to reproduce it?

uvjustin avatar Oct 31 '22 07:10 uvjustin

I did notice that the camera orientation seems to only be updated in Camera._async_stream_endpoint_url, so this may be the source of the issue. @Tom-Heitbrink It seems that currently the stream orientation change is only applied after the first time the HLS stream is accessed. If you have still images of the stream shown in the frontend, they may not be transformed until the first time you open the actual video feed. Is this consistent with what you experienced?

uvjustin avatar Oct 31 '22 08:10 uvjustin

I can reproduce this for generic, or at least something similar. In my case I change the orientation in the settings tab and click update, but when I go back to the info tab nothing has changed.

@uvjustin I am not sure how this is intended to work. Where is the setting saved within the hass storage?

davet2001 avatar Nov 05 '22 08:11 davet2001

@davet2001 The current code only updates the orientation the next time the stream URL is accessed. This means that the orientation won't show up until the more info window is closed and opened again. Is this what you are seeing? If so, the cause is what I mentioned above - it's not from the update/storage of the setting but rather syncing that setting between camera and stream. It's easy to patch camera to sync the parameters properly to stream, but it might be cleaner to refactoring it a bit so that the setting is actually just shared between camera and stream. I discussed this briefly with @allenporter the other day, and I already mocked up a refactoring/will open a PR for it. As for your question, the storage is actually a bit messy/complicated. The preload_stream setting is stored in a single Store held by the camera, so the setting has to be looked up by entity. When I added orientation, I put it in the entity registry as suggested by a few reviewers of that PR. The reason preload_stream was not moved to the entity registry is that not all cameras use config flows, so they do not all have entity registry entries.

uvjustin avatar Nov 06 '22 15:11 uvjustin

@uvjustin Thanks, yes it works as you describe when I close and reopen the window.

davet2001 avatar Nov 06 '22 17:11 davet2001