FOSCAM motion/sound detection and IR Led status in HA

Was this ever fixed? I’m interested in doing automations in HASS based on motion form the Foscam.

I am also getting an error with the import (below). I followed the steps above that Rob did.
Any ideas how to get the import to work?

Traceback (most recent call last): 
File "./foscam2mqtt.py", line 8, in <module>
from foscam import FoscamCamera
File "/usr/local/lib/python3.4/dist-packages/pyfoscam-1.2-py3.4.egg/foscam/__init__.py", line 1, in <module>
from foscam import FoscamCamera
ImportError: cannot import name 'FoscamCamera'

I had to update the pyfoscam python library (/usr/local/lib/python3.4/dist-packages/pyfoscam-1.2-py3.4.egg/foscam/init.py) and this script to use the correct foscam.foscam namespace change:
OLD:
from foscam import FoscamCamera
NEW:
from foscam.foscam import FoscamCamera

Thank you! Works great now.

1 Like

Thanks for sharing the script.

1 Like

i change in file follow your guide but get erro.

Traceback (most recent call last):
File “./foscam2mqtt.py”, line 7, in
from foscam.foscam import FoscamCamera, FOSCAM_SUCCESS
ImportError: No module named foscam.foscam

just a question… script works properly but how can i use it as i cannot see any values on motion detection :frowning: i see that motion detection is 1 equal activated … but nothing more

ipcamera/Foscam {“infraLedState”: “1”, “soundAlarm”: “0”, “motionDetectAlarm”: “1”}
thats what i get… i never get payload 2. motion detection is well activated :frowning:

FIXED! I just created a mqtt binary sensor… Will see if it works in a few minutes . Til now i use appdaemon for this but motion detection is very slow there and i guess will mqtt it is on the fly

1 Like

Hello there,

I am new to running scripts with HASS. I currently have HASSIO and am looking to get a little more instruction. I have placed the foscam2mqtt.py file inside python_scripts folder inside of the configuration folder. Is this how I install it, or is there another way? Looking for some step by steps if possible. Thanks

I have a question as to the python script. How do you run it? Thanks in advance

So I have gotten the script placed and most working but I keep getting this error: Can anyone help?

    Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/foscam2mqtt.py", line 80, in <module>
    main()
  File "/home/homeassistant/.homeassistant/foscam2mqtt.py", line 61, in main
    client.connect(args.mqtthost, args.mqttport, 60)
  File "/home/pi/.local/lib/python3.5/site-packages/paho/mqtt/client.py", line 760, in connect
    return self.reconnect()
  File "/home/pi/.local/lib/python3.5/site-packages/paho/mqtt/client.py", line 887, in reconnect
    sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
  File "/usr/lib/python3.5/socket.py", line 712, in create_connection
    raise err
  File "/usr/lib/python3.5/socket.py", line 703, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

how to add human detect sensor. Thanks

Good day, how do you continuesly run the script. I pressume it runs once reports the state and stops. How do you keep it active?
Thank you