Im trying to add a Foscam FI9828W too. Having no luck to get it to work with Home Assistant.
Tried the Foscam and the Mjpeg method and nothing works.I get this error:
17-01-25 20:08:18 requests.packages.urllib3.connectionpool: Failed to parse headers (url=http://192.168.1.7:8151/videostream.cgi?rate=0&user=xxx&pwd=xxx)
Here is an example of my line for my foscam FI9821P (top) and FI8904W & FI8906W (bottom):
camera 2:
platform: foscam
ip: 192.168.2.4
name: Kitchen Cam
port: 18810
username: !secret camera_username
password: !secret camera_password
camera 3:
platform: mjpeg
mjpeg_url: http://192.168.2.115:18811/videostream.cgi?user=Redacted&pwd=Redacted
name: Front Porch Cam
This isn’t HA as much as it is the library they are using for this. As far as I know, the issue at the library is still open.
I have a pair of 8918Ws which are essentially the same and ironically did a bunch of work on them yesterday to get curl commands working to move them to presets.
One of the things that reduced (maybe ended) these errors for me was adding the authentication type.
# Front Inside Camera
- platform: mjpeg
mjpeg_url: !secret cam1_url
authentication: digest
name: interior street facing controllable
The URL I use is identical to @Corey_Johnson; I found it at iSpy’s site which is a great repo for direct URLs for many camera types. https://www.ispyconnect.com/sources.aspx
Also, when working on my presets project, I found this which is going to help a lot of you guys out if you want to access features via curl commands!
As far as some of the other info “errors” that you get from HA on the Foscams, since they don’t affect actual operation, I’ve been filtering them with the following:
logger:
default: error
logs:
homeassistant.components.media_player.firetv: fatal
homeassistant.components.media_player.cast: fatal
homeassistant.components.cameras: fatal
For me, some of these components generate errors that aren’t anything that affects their actual operation; for instance, I have a UHD TV with Cast built in. This is great and when it’s on, the media player shows up fine but when the TV is off I get connection errors. Since I know this is in the process of being fixed (possibly in .37), I’m just suppressing them for now. If something nasty happens, I’ll still get an error. This is a personal choice; I’m not saying you should just ignore errors in your log. But if you know what they are and if you know they are not critical, this is a way to filter them out.
Hope this helps; I didn’t see a lot of Foscam info when I first came here so I wanted to try to add to the knowledge base.
Thanks Robert,
That got me up and running. Now I just have to figure out if I can get the pan/tilt and zoom to work with HA
Give me a little time and I’ll put up what I did with presets; really the only difference would be looking up which command number and CGI to put in the URL. And you should be able to get that from the CGI PDF I posted.
Here’s what I came up with for the preset commands
Go to preset 1 - http://CAM_IP/decoder_control.cgi?command=31&user=USER&pwd=PASSWORD
Go to preset 2 - http://CAM_IP/decoder_control.cgi?command=33&user=USER&pwd=PASSWORD
Go to preset 3 - http://CAM_IP/decoder_control.cgi?command=35&user=USER&pwd=PASSWORD
Go to preset 4 - http://CAM_IP/decoder_control.cgi?command=37&user=USER&pwd=PASSWORD
Go to preset 5 - http://CAM_IP/decoder_control.cgi?command=39&user=USER&pwd=PASSWORD
I also have a cam that faces a window so I turn off the IR otherwise the reflection washes everything out.
Turn off IR lamp - http://CAM_IP/decoder_control.cgi?command=95&user=USER&pwd=PASSWORD
I created scripts for each one to send these commands via cURL here’s an example of one of them:
#!/bin/bash
curl -k "http://CAM_IP/decoder_control.cgi?command=31&user=USER&pwd=PASSWORD"
and changed the owner of the scrip to the HA user. I call them with a shell command.
Thanks Robert, Going to give it a try this week.
Hey maucollu,
i have the same problem with the Foscam FI9851. Can´t get it to work. Did you solve your problem?
No, I never solved it…
I was just doing some research into pan and tilt indoor cameras that work with HA and it looks like Foscam is a good option. However, there is a question as to which model to go for, as some seem problematic (as this thread highlights) and some of the older models are selling out while there are new ones that haven’t been mentioned.
As best I can tell:
Working:
- Foscam C1
- FI8010E - as mjpeg
- FI8904W - as mjpeg
- FI8906W - as mjpeg
- FI8909W - as mjpeg
- FI8918W - as mjpeg
- FI9821P - as foscam
- FI9828W - as mjpeg?
- FI9828P - works with fancy controls
Not working, yet:
- FI8910W
- FI9851?
Unknown:
- Foscam R2
- FI8908W
- FI8910W
- FI9816P
- FI9826P
- FI9831P
But there is also the FI9816P. Has anyone got this working? The reviews aren’t encouraging on Amazon, but then neither are those for the FI9821P. I assume it doesn’t matter too much as Home Assistant will be doing all the work.
i dont know about that specific cam, but i recently bought a C1 lite for 26 euro
it has the same CGI so i can control it on the same way as the F19828P (without PTZ off course)
so the most important is to find out which type of CGI the cam uses.
i will try to find out a list later on.
edit: changed CGG to CGI
I would try MJPEG Generic on this with the following URL:
http://IPADDRESS:PORT/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=[USERNAME]&pwd=[PASSWORD]&
Or FFMPEG with this:
http://IPADDRESS:PORT/videostream.asf?user=[USERNAME]&pwd=[PASSWORD]
You should be able to see something in a browser if you try these URLs and replace the capitalized variables with your actual info. If you do, then it should work in HA as well. At least the first one; you’ll have to set up FFMPEG to use the other one, of course.
Thanks for the advice.
So it seems you can use the pan and tilt through CGI even if it is only using the mjpeg. Good to know.
Do the W and P models make much of a difference when using them through HA?
If you can find a reference of the CGI commands like I did with the 8918w, you can create scripts and use cURL commands to move the cams, at least to the presets if nothing else. I’m doing it myself with an input select.
Not sure, but I wouldn’t think so.
I can confirm that the FI8909W is also working flawless in Hass (stream only). Config used:
camera:
- platform: mjpeg
name: FI8908W Wifi
mjpeg_url: http://192.168.1.11/videostream.cgi?user=admin&pwd=XXX
This may be for older firmware but the cgi command format is different from what is listed above for PTZ presets.
For Horizontal Patrol:
curl -k "IP:PORT/decoder_control.cgi?user=<user>&pwd=<password>&command=28"
For presets:
curl -k "IP:PORT/decoder_control.cgi?user=<user>&pwd=<password>&command=31"
Substitute the command for multiple odd numbers to get different presets (31, 33, 35, 37…)
As this thread helped me a lot getting my webcam to work, here my contribution for the FosCam 8910W:
camera:
- platform: mjpeg
name: Webcam
mjpeg_url: http://IP:PORT/videostream.cgi?user=USER&pwd=PASSWORD
Of course, replace all UPPERCASE with the appropriate numbers/chars for you. the colon and port can be skipped if you did not change the default (as i did). Maybe in case of error, just add it (default is 88).
Maybe this helps another user.
/ Ralf
and mine :
To see if motion is detected a command line sensor can be set up.
Sensor is updated every 5 seconds
- platform: command_line
name: "Front Door Motion"
command: 'curl -k --silent "http://ipaddress:port/get_status.cgi?user=xxx&pwd=xxx" | grep alarm | cut -b 18'
value_template: >-
{%- if value == "0" -%}
Idle
{%- elif value == "1" -%}
Motion
{%- endif -%}
scan_interval: 5
Hallo keizer,
Ben je er inmiddels al achter of de onbekende FI9831P het doet of een of andere manier?
Krijg heb maar niet in mijn home assistant.
m.v.g.
Melvin
Hi, I know this is an old thread, but I used your example to get my camera to show up in the ui. But, it only worked until I restarted home assistant. I’ve restarted several times since then but the camera is still not showing up. Any advice?