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

Axis Camera Integration needs a refresh #89967

Closed
Viss opened this issue Mar 20, 2023 · 26 comments
Closed

Axis Camera Integration needs a refresh #89967

Viss opened this issue Mar 20, 2023 · 26 comments

Comments

@Viss
Copy link

Viss commented Mar 20, 2023

The problem

Newer axis cameras that get newer firmware have slight changes in the API that the current integration doesn't account for, so certain things (like camera.snapshot) do not work. In this case, it's a camera on new firmware and for some reason the 'default' axis URI path to fetch images and video doesn't work for this camera.

What version of Home Assistant Core has the issue?

2023.3.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

axis

Link to integration documentation on our website

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

Diagnostics information

for some reason this camera is throwing errors when attempting to grab a snapshot, but works just fine when viewing the camera stream. I'm happy to open a ticket with axis to get their input, but I'm betting what's going to happen is that they'll say there's a slightly different URI needed for this model of camera, and those updates will need to go into the integration.

I'm happy to do testing and work with folks to get this sorted out!

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Here's the relevant HA error log. It's trying to read from an Axis M3206-LVE, running firmware 10.12.114.
I have other axis cameras (several M3116-LVE's) on the exact same firmware, and they work no probs. Looks like this camera has, for some reason, a slightly different path to get at things.


2023-03-19 16:30:49.340 DEBUG (MainThread) [axis.rtsp] Received data ['RTSP/1.0 200 OK', 'CSeq: 3', 'RTP-Info: url=rtsp://10.0.0.212/axis-media/media.amp/stream=0?video=0&audio=0&event=on;seq=24268;rtptime=2686444859', 'Range: npt=now-', 'Server: GStreamer RTSP server', 'Session: RIobjjRSgD7-Sb9V;timeout=60', 'Date: Sun, 19 Mar 2023 23:30:49 GMT', ''] from 10.0.0.212
2023-03-19 16:31:03.843 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.driveway_cam] Error from stream worker: Error opening stream (HTTP_SERVER_ERROR, Server returned 5XX Server Error reply) rtsp://****:****@10.0.0.205/axis-media/media.amp?videocodec=h264&streamprofile=highdef&camera=1
2023-03-19 16:31:17.299 DEBUG (MainThread) [axis.rtsp] OPTIONS rtsp://10.0.0.205/axis-media/media.amp?video=0&audio=0&event=on RTSP/1.0
CSeq: 4
User-Agent: HASS Axis
Session: bNEB0VpQy3OI-3iR

I have a BUNCH of axis cameras, so if we wanna go over those to make sure the integration can pick up all the cool sensors and stuff these things can do (theres a lot) I'm game to help! At some point recently the axis integration 'just stopped being able to gather these details' - it used to work and then 'just stopped' - not sure why. I wager going back and looting the older version of this integration for those details would be super helpful

@home-assistant
Copy link

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

Code owner commands

Code owners of axis can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign axis Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


axis documentation
axis source
(message by IssueLinks)

@Kane610
Copy link
Member

Kane610 commented Mar 20, 2023

Thanks for reporting. What button are you using for snapshot? Or is it a service you're calling?

Suggestions of new features are best put here https://github.com/Kane610/axis

@Viss
Copy link
Author

Viss commented Mar 21, 2023

I'm using various angles in home assistant.
One way is to just use the picture glance card. Another is to use vorian's 'send snapshot when motion is detected' blueprint. Here's the code from that blueprint that calls for snapshots: https://community.home-assistant.io/t/send-camera-snapshot-notification-on-motion/254565

I have several m3116-lve's and those work like a champ. A way I can test this outside of the automation is to create a picture glance card, and in the dialog to configure the card, there are 'auto' and 'live' radio buttons. Auto creates a still image. Live creates a video feed. the m3116-lve's will do both, no problems, but the m3206-lve will only do video, no still images.

I've also opened a ticket with axis as well (I have fifteen cameras) asking for clarity, and an updated API reference document, so I'll reply here when I get any interesting data out of them. Amusingly, the newest camera I have, the m3077-plve (synology doesnt even know about this one yet!) seems to work just fine, and its one of those fisheye cameras.

In the meantime - if there's something you'd like me to test I'm happy to go under the hood!

@Viss
Copy link
Author

Viss commented Mar 21, 2023

I see your other repo was updated just days ago - is there a way to import that newest version of the axis integration into my hassos/rpi setup to get the newest version?

@Kane610
Copy link
Member

Kane610 commented Mar 21, 2023

I see your other repo was updated just days ago - is there a way to import that newest version of the axis integration into my hassos/rpi setup to get the newest version?

There are no relevant changes, I'm preparing some refactoring of the library together with some dependency bumps. The integration is in need of some improved structuring so I'm investigating that currently.

@Viss
Copy link
Author

Viss commented Mar 22, 2023

I found part of the issue, check it out.
Looks like the m3206-lve seems to barf if you give it slightly different params.

Would you consider either testing a few different URI strings to make sure they're valid, or letting the user input their own URI for the camera, if its being persnicketty like this one?

Screen Shot 2023-03-22 at 12 35 46 PM

@Kane610
Copy link
Member

Kane610 commented Mar 24, 2023

Are you running the latest firmware on all those devices?

There should be some logics behind how to compile the URI where I've probably missed something small difference with the m3206

@Viss
Copy link
Author

Viss commented Mar 24, 2023

It looks like leaving off ?camera=1 from the URI makes it behave.
image

Yeah, all of these cameras are on the latest possible firmware I can get from axis. I have a windows vm and I run their device manager, so once a month or so I fire that thing up and let it update all the cameras.

@Brutuss
Copy link

Brutuss commented Mar 27, 2023

Dont know if its related.. But I have a M3106LVE with latest firmware 9.80.2.2
When trying to add the camera and provide the credentials there is an error authentication failed.
Credentials are correct. Made also a new user.

@Kane610
Copy link
Member

Kane610 commented Apr 24, 2023

Hello

I was looking at the integration code, have you perhaps configured the options of the integration?

Can you check in your home-assistant/.storage/core.config_entries what the contents of the options of the integration is?

Since it's adding camera it should not be empty. So it might be possible to resolve without patching the integration :)

@Kane610
Copy link
Member

Kane610 commented Apr 24, 2023

Dont know if its related.. But I have a M3106LVE with latest firmware 9.80.2.2
When trying to add the camera and provide the credentials there is an error authentication failed.
Credentials are correct. Made also a new user.

Different issue

@Viss
Copy link
Author

Viss commented Apr 25, 2023 via email

@Viss
Copy link
Author

Viss commented Jun 8, 2023

I have some more information about this issue.

It seems that something home assistant is doing to the camera is causing it to 'become broken'.
After a fresh reboot of the camera, I can get curl to work with the syntax expected, however right after I aim home assistant at it, it "becomes broken again".

can you give me an idea of how the axis integration tries to communicate with the camera before it tries to fetch an image?

i've also concurrently opened a support request with axis to see if they can help

@Kane610
Copy link
Member

Kane610 commented Jun 8, 2023

I checked that file and it definitely looks like there's content in it.

Can you share the content of the config_entry for the axis camera?

It should look something like

      {
        "entry_id": "aade4617cda4bb79a3482f301bcdd8aa",
        "version": 3,
        "domain": "axis",
        "title": "M3106-LVE - ACCC8E000000",
        "data": {
          "host": "192.168.0.13",
          "port": 80,
          "username": "root",
          "password": "pass",
          "model": "M3106-LVE",
          "name": "M3106-LVE 0"
        },
        "options": {
          "stream_profile": "No stream profile",
          "video_source": 1
        },
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "ssdp",
        "unique_id": "ac:cc:8e:00:00:00",
      }

what you want to try in your case is to change the options to not contain the "video_source" part, make sure to remove the , at the end of the line before else parsing will fail.

        "options": {
          "stream_profile": "No stream profile"
        },

Hopefully this works.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@Viss
Copy link
Author

Viss commented Sep 6, 2023

this issue has not been resolved by any of the subsequent home assitant updates. It has to do with the specific URI used to query axis cameras, and since that remains unchanged, the issue remains. Some of the newer firmwares for axis cameras can be a little persnicketty, and in the case of the issue I'm trying to resolve, it seems that one or two additional requests need to be made in order to get the camera to behave properly.

@github-actions github-actions bot removed the stale label Sep 6, 2023
@Kane610
Copy link
Member

Kane610 commented Sep 6, 2023

Start by following #89967 (comment) and see if that helps

@Viss
Copy link
Author

Viss commented Sep 7, 2023

      {                       
        "entry_id": "5f2cd192d8c0cf9ae03cce4536290122",
        "version": 3,
        "domain": "axis",
        "title": "M3206-LVE - B8A44F1DA7EA",           
        "data": {    
          "host": "10.0.0.205",
          "port": 80,   
          "username": "root",
          "password": "camerafap1",
          "model": "M3206-LVE",
          "name": "M3206-LVE 0"
        },                                 
        "options": {                  
          "stream_profile": "highdef",
          "video_source": 1
        },                 
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",                              
        "unique_id": "b8:a4:4f:1d:a7:ea",
        "disabled_by": null   
      },                                   

There's the entry in full!

i removed the 'video_source' line per your instructions, and rebooted home assistant, but this has not resolved the issue.

@Kane610
Copy link
Member

Kane610 commented Sep 11, 2023

Just to clarify; you tried streams with and without ?camera=1 using a different client and it worked when leaving it out?

@Viss
Copy link
Author

Viss commented Sep 12, 2023

It works in synology surveillance station, but I can't get it to work in tinycam at all, and with curl I get the same results as above, even with new firmware. I've opened a ticket with axis for help as well

@Viss
Copy link
Author

Viss commented Sep 12, 2023

I think i figured it out. I flashed the camera with fresh firmware and when i hit the 'rotate 180 degrees' option because the picture is upside down, suddenly home assistant breaks. It has something to do with the api. when i curl before i flip the image, it works fine. but after i flip the image it breaks. so this seems like its entirely an axis bug.

@Viss Viss closed this as completed Sep 12, 2023
@Kane610
Copy link
Member

Kane610 commented Sep 12, 2023

For my own reference should I want to try it myself, you mean after the integration is up and running with video and events you change the video to be rotated 180 degree and the integration then fails and requires a restart? Or it also affects just retrieving a snapshot?

@Viss
Copy link
Author

Viss commented Sep 12, 2023

This camera is hung with a commercial setup over my driveway, and the home asstant integration, for a very long time, worked just fine, no worries. Then one day the camera 'just stopped showing up in home assistant', so I started to investigate.

what i discovered was that it 'worked sometimes'. From first boot, its fine if you try to curl the api - but the second you aim home assistant at it "it breaks". I'm not 100% what the actual request is that HA makes that causes a change in the camera, but in theory, curling the api shouldnt 'write anything' or make any modifications. I started a conversation with axis support and twice (over several months) I basically stumped the support person trying to help.

Today, I did a full factory reset and firmware flash, and noticed that HA seemed to like the camera until I flipped the image. Having noticed that I decided 'maybe if I just go unscrew the camera and rotate the camera element itself, I wont have to use software to flip the picture, and that may get around the issue' - when I took the camera apart some dead bugs fell out of it (which is bad. bugs arent supposed to be able to get inside it) - and now I'm beginning to think there is some kind of physical problem and the bizarro api behavior is just a symptom. I took the camera down from its mount and I'm going to begin the RMA process - but sadly this leaves questions unanswered.

A good troubleshooting step if you would like to try this yourself, is to login to an axis camera yourself, and flip the picture in the image settings, and see if HA has a seizure. It seems to ONLY affect this camera - and it "just started happening one day", and i had attributed that to an HA upgrade, since I upgraded HA and this problem happened at the same time.

hopefully you get somewhere with your troubleshooting. hopefully axis will let me RMA this thing.
If they do, and I get a fresh new camera, I'll definitely test and reply with the results.

@Viss Viss reopened this Oct 4, 2023
@Viss
Copy link
Author

Viss commented Oct 4, 2023

I have an update from axis!
I was able to discover that with this specififc camera (m3206-lve) there is some kind of bug triggered under the hood when making a request for the full resolution of the image.

if i make the request /axis-cgi/jpg/image.cgi?resolution=1280x960 it works every time without a problem. Axis has agreed to file this as an actual bug and is running it up the line.

If there's a way to manually specify a resolution for this camera, this will temporarily solve the issue and it'll work in home assistant again until axis hq in sweden fixes the underlying bug.

@Viss
Copy link
Author

Viss commented Oct 4, 2023

I've tried adding a 'resolution' section in the config_entry file, and ive even created a stream profile that forces the resolution down to 1280x960 - but it seems home assistant refuses to allow for me to specify the resolution for 'any image requests' - now i can get the camera to stream video, and that works, but HA still can't get still images out of it, so the thumbnail for the camera is empty, and none of the image/snapshot autonations can get an image out.

at least in the short term, if theres a way to specify "a global resolution to use for any requests made to the camera, for anything" tnat would solve the problem.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@issue-triage-workflows issue-triage-workflows bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants