New release: Foscam V3 app (updated for appdaemon 3.0 beta)

I updated the foscam app for use with appdaemon 3.0
and made some minor changes.

i made V1 and V2 now deprecated.

also i created a new github for the app.

because the old topic contains a lot of install postings i now post the readme here new.


This is an app to create controls for a foscam camera
Alt text Alt textAlt text

Cameratypes that work with this
i created 3 groups of cams that work with this app, but only group 1 has full functionality.

F19828P, F19828P V2, F19928P, R2, F19821W V2
cams that are PTZ and with infrared light
C1, C1 V3
no PTZ cams with infrared
C1 lite
no PTZ cams without infrared
not all foscam cameras use the same CGI commands. there are 2 kinds of CGI. the older cams that use the old CGI are not supported by this app.
if your cam isnt here it can still work, but i dont know the type. to check if your cam is working with this app, give this url in your browser:

http://CAM_IP:CAM_POORT/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=YOUR_USER_NAME&pwd=YOUR_PWD

if this gives back info then you can use the app. please contact me to add the camtype.

Installation
this app can only be used with a working version from Appdaemon 3.0 or higher (for installation from appdaemon see: http://appdaemon.readthedocs.io/en/latest/index.html ) it expects at least version 3.0 .
besides appdaemon you need to install the custom widget vertical_input_slider if you want a full working dashboard you can find them here: https://github.com/ReneTode/My-AppDaemon/tree/master/custom_widgets
you need to have the camera added and working in homeassistant https://home-assistant.io/components/camera.foscam/
create in homeassistant the entities you can find in the file add_to_ha_configuration (input_booleans, input_selects, input_numbers and groups)
if all requirements are met you can install the app.

download the file foscam.py and foscam.yaml and move it to your apps directory from appdaemon

foscam:
  class: foscam
  module: foscam                           # the name of the py file you added to your apps
  camsettings:
    camera_type: F19828P V2                # give 1 of the known camera types
    camera_name: yourcam                   # the name you gave it in home assistant
    host: 192.168.1.50                     # the ip address from your cam
    port: '88'                             # the port from your cam (default is 88)
    password: yourpassword                 # password set for the cam (no strange symbols allowed)
    user: username                         # the username you use for the cam
  logsettings:
    loglevel: WARNING                      # setting this to INFO gets more info in the log
    logsensorlevel: WARNING                # the app creates a sensor with the last info. level can be changed
    last_error_sensor: sensor.foscam_last_error # the sensor is created automaticly
  picsettings:                             # these settings need to be created in home assistant (see below)
    brightness_slider: input_number.foscam_brightness 
    contrast_slider: input_number.foscam_contrast
    hue_slider: input_number.foscam_hue
    saturation_slider: input_number.foscam_saturation
    sharpness_slider: input_number.foscam_sharpness
    default_pic_settings_switch: input_boolean.foscam_default_picture_settings
    flip_switch: input_boolean.foscam_flip
    mirror_switch: input_boolean.foscam_mirror
    auto_infrared_switch: input_boolean.foscam_auto_infrared
    infrared_switch: input_boolean.foscam_infrared
  ptzsettings:                             # these settings need to be created in home assistant (see below)
    left_right_slider: input_number.foscam_left_right
    up_down_slider: input_number.foscam_up_down
    start_cruise_select: input_select.foscam_preset_cruise
    stop_cruise_switch: input_boolean.foscam_stop_cruise
    zoom_slider: input_number.foscam_zoom
    preset_points_select: input_select.foscam_preset_points
  alarmsettings:
    motion_sensor: sensor.foscam_motion    # the sensor is created automaticly
    motion_switch: input_boolean.foscam_motion_detect # also needs to be created in home assistant
    soundalarm_sensor: sensor.foscam_sound_alarm  # the sensor is created automaticly
    sensor_update_time: '10'               # the amount of time in seconds between checks from the cam
  recordsettings:
    snap_picture_switch: input_boolean.foscam_snap_picture_now  # also needs to be created in home assistant
    recording_sensor: sensor.foscam_recording  # the sensor is created automaticly
    save_snap_dir: /home/pi/foscam_snap/   # the dir where you want manual snapshots to be saved
  dashboardsettings:
    DashboardDir: /path/to/dashboards/     # in this dir you create your dashboards                          
    use_dashboard: True                    # if this is set to False no dashboards will be created or used
    create_dashboard: True                 # creates a dashboard in your dashboard directory on initialize from the app
    create_alarm_dashboard: True           # creates an alarm dashboard
    dashboard_file_name: dash_terrascam    # the name that your dashboard gets
    alarm_dashboard_file_name: dash_terrascam_fullscreen # the name that the alarm dashboard gets
    screen_width: 1024                     # the screenwidth you want to use for your dashboard
    screen_height: 600                     # the screenheight you want to use for your dashboard
    show_full_screen_dashboard: True       # if you dont want to use the alarm dashboard set it to False
    full_screen_alarm_switch: input_boolean.foscam_toon_alarm_dash # a boolean to silence the alarmdashboard temperary
    time_between_shows: 60                 # minimum time in seconds between showing alarm dashboards
    show_time: 30                          # the amount of seconds the alarm keeps active

you can chose to let the app recreate the dashboard every time you start the app or when you are satisfied with the dashboard, or want to customize it, then set create_dashboard to false after the first time.

if you have done everything right you now can start your dashboard like http://your_dashboard_ip:dashboard_poort/dashboard_file_name

footnotes:

  1. to make sure this app is working like you want to you need to set some settings in the foscam app, before you start this app. motion detection needs to be set to on with all settings set to how you like it. the app can then save those settings during the initialisation and reuse them every time you activate motion detection. also it is wise to set all cruisepresets and preset positions in the foscam app before you add the input_selects to home assistant. during the initialisation the app gets the following settings from your cam: motion detection settings, picture settings like brightness, contrast, etc, flip and mirrorstate, infraredstate. every 10 seconds (or the amount of time you have set in the settings) the app gets the following settings from your cam: motion detection, recording, sound detection, infrared state
  2. zoom and PTZ movement are done by changing the sliders. the more you move the slider away from the center, the higher the speed. movement and zoom automaticly stops after 1 second, unless you start cruises.
  3. the R2 type uses a slightly different configuration. to get it to work allright you need to edit the foscam.py find the lines that say getMotionDetectConfig and setMotionDetectConfig and change that to getMotionDetectConfig1 and setMotionDetectConfig1
4 Likes

Perfect timing.I got my Intel nuc and I’m going to setup my has in a clean way ;9 thanks René

O! I get this error in my logs when trying to zoom:

2018-02-21 14:14:16.768053 WARNING foscam: String format error
2018-02-21 14:14:16.834861 INFO foscam: http://192.168.1.201:88/cgi-bin/CGIProxy.fcgi?&usr=hass&pwd=hass&cmd=setZoomSpeed&speed=3

1 Like

I’m having the following error. Any help? :slight_smile:

2018-10-04 13:49:02.986681 WARNING AppDaemon: ------------------------------------------------------------
2018-10-04 13:49:02.987185 WARNING AppDaemon: Unexpected error loading config file: 
/config/appdaemon/apps/._foscam.yaml
2018-10-04 13:49:02.988043 WARNING AppDaemon: ------------------------------------------------------------
2018-10-04 13:49:03.008172 WARNING AppDaemon: Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1671, in read_config_file
    config_file_contents = yamlfd.read()
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 37: invalid start byte
2018-10-04 13:49:03.008674 WARNING AppDaemon: ------------------------------------------------------------
2018-10-04 13:49:03.009467 WARNING AppDaemon: File '/config/appdaemon/apps/._foscam.yaml' invalid structure - ignoring
2018-10-04 13:49:03.250441 WARNING AppDaemon: File '/config/appdaemon/apps/apps.yaml' duplicate app: foscam - ignoring
2018-10-04 13:49:03.251637 WARNING AppDaemon: ------------------------------------------------------------
2018-10-04 13:49:03.252281 WARNING AppDaemon: Unexpected error loading config file: /config/appdaemon/apps/._apps.yaml
2018-10-04 13:49:03.252910 WARNING AppDaemon: ------------------------------------------------------------
2018-10-04 13:49:03.255299 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1671, in read_config_file
    config_file_contents = yamlfd.read()
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 37: invalid start byte
2018-10-04 13:49:03.255965 WARNING AppDaemon: ------------------------------------------------------------
2018-10-04 13:49:03.256879 WARNING AppDaemon: File '/config/appdaemon/apps/._apps.yaml' invalid structure - ignoring
2018-10-04 13:49:03.257509 INFO AppDaemon: /config/appdaemon/apps/._foscam.yaml added or modified
2018-10-04 13:49:03.258120 INFO AppDaemon: /config/appdaemon/apps/foscam.yaml added or modified
2018-10-04 13:49:03.258705 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2018-10-04 13:49:03.259269 INFO AppDaemon: /config/appdaemon/apps/._apps.yaml added or modified
2018-10-04 13:49:03.259826 INFO AppDaemon: /config/appdaemon/apps/._foscam.yaml added or modified
2018-10-04 13:49:03.260867 INFO AppDaemon: /config/appdaemon/apps/foscam.yaml added or modified
2018-10-04 13:49:03.261627 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2018-10-04 13:49:03.262204 INFO AppDaemon: /config/appdaemon/apps/._apps.yaml added or modified
2018-10-04 13:49:03.262784 INFO AppDaemon: App 'foscam' added
2018-10-04 13:49:03.263743 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2018-10-04 13:49:03.266154 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/hello.py - ignoring
2018-10-04 13:49:03.266686 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/foscam.py
2018-10-04 13:49:03.404482 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/._foscam.py - ignoring
2018-10-04 13:49:03.405409 INFO AppDaemon: Initializing app foscam using class foscam from module foscam
2018-10-04 13:49:03.407557 WARNING AppDaemon: ------------------------------------------------------------
2018-10-04 13:49:03.408280 WARNING AppDaemon: Unexpected error running initialize() for foscam
2018-10-04 13:49:03.409778 WARNING AppDaemon: ------------------------------------------------------------
2018-10-04 13:49:03.414433 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1575, in init_object
    init()
  File "/config/appdaemon/apps/foscam.py", line 126, in initialize
    self.url = "http://"+ self.camhost + ":" + str(self.portnr) + "/cgi-bin/CGIProxy.fcgi?&usr=" + self.user + "&pwd=" + self.password + "&cmd="
TypeError: must be str, not NoneType
2018-10-04 13:49:03.416144 WARNING AppDaemon: ------------------------------------------------------------
2018-10-04 13:49:03.419479 INFO AppDaemon: App initialization complete

you got some hidden files bugging you.

/config/appdaemon/apps/._foscam.yaml
/config/appdaemon/apps/._apps.yaml

first find and delete those

then make sure you got the foscam.yaml configured right.
and dont use special characters like %^& or ëÄ etc.

Tks, @ReneTode, it works!

Almost everything is working fine now, just the most important feature for me isn’t working: The Motion Sensor Alarm.

Sound alarm is working fine but motion isn’t. Any idea? I’ve a C1 camera.

can you tell more about, not working.
do you have any errors in AD?

@ReneTode

I dunno but I get thise errors in the logs… I am not using custom skin but default.

2018-11-14 11:40:00.805505 INFO Compiling dashboard ‘front_cam’
2018-11-14 11:40:01.424251 WARNING Variable definition not found in CSS Skin variables: $vertical_input_slider_title_style
2018-11-14 11:40:01.424616 WARNING Variable definition not found in CSS Skin variables: $vertical_input_slider_title2_style
2018-11-14 11:40:01.424769 WARNING Variable definition not found in CSS Skin variables: $vertical_input_slider_minvalue_style
2018-11-14 11:40:01.424904 WARNING Variable definition not found in CSS Skin variables: $vertical_input_slider_maxvalue_style
2018-11-14 11:40:01.425512 WARNING Variable definition not found in CSS Skin variables: $vertical_input_slider_value_style
2018-11-14 11:40:01.425683 WARNING Variable definition not found in CSS Skin variables: $vertical_input_slider_slider_style
2018-11-14 11:40:01.425823 WARNING Variable definition not found in CSS Skin variables: $vertical_input_slider_widget_style
2018-11-14 11:40:01.626398 INFO Loading custom widget ‘vertical_input_slider.yaml’
2018-11-14 11:40:01.626678 INFO Loading custom widget ‘baseslider_vertical’
2018-11-14 11:40:01.628612 INFO Loading custom widget ‘basevacuum’
2018-11-14 11:40:01.632614 INFO Loading custom widget ‘graph.yaml’
2018-11-14 11:40:01.632891 INFO Loading custom widget ‘basegraph’
2018-11-14 11:40:01.633631 INFO Loading custom widget ‘vacuum.yaml’
2018-11-14 11:40:01.877156 INFO function [get_dashboard] finished in 1077 ms

Where exactly do i have to add those two lines? In which folder.

Sorry for this dumb question again

that means that you didnt add the styles to your variables.yaml in the skin you are using.

Strange but i don’t find variables.yaml in the default…where do I have to watch …anyway I added it somehow somewhere and it now works

Hi @ReneTode,

I have an R2 cam ( ‎FI-R2MB ). Some of the commands still works (for example Flip, brightness, contrast, hue) others don’t (for example switch for activate motion detection, preset loading ecc).

Do you still offer support?

i havent used it for very long, but if you come to the appdaemon discord to the hadashboard channel i can see what i can do for you.

Does this work with Foscam FLC camera? The CGI command getDevState works fine.
I think my model is just ‘FLC’ (stands for floodlight camera I believe)
https://amzn.to/3quHKl9

sorry i cant tell. youll need to try.

No problem, happy to give it a go. What camera_type should I put in the config? FLC or one of the ones you already support?

1 of the supported ones i believe.
or you would also need to change the python.
also you need to know that i dont use the app anymore, for a long time and AD changed a lot since then, so i cant tell if it is 100% working. (i expect it works, but im not sure)