Amcrest Camera Problem [Solved]

Hi,

So I have following code working fine when placed in configuration.yaml file.

amcrest:
  - host: !secret amcrest_2_ip
    username: !secret amcrest_username
    password: !secret amcrest_password
    name: Amcrest-2
    binary_sensors:
      - motion_detected
      - online
    sensors:
      - sdcard

camera:
  - platform: amcrest

But I want to keep configuration file short and clean and move this code to another file under “cameras/amcrest.yaml”.

So I changed the configuration.yaml file to include:

camera: !include cameras/amcrest.yaml (–> line 14 in the code)

And placed following code under “cameras/amcrest.yaml”

camera amcrest-2:
  - host: !secret amcrest_2_ip
    username: !secret amcrest_username
    password: !secret amcrest_password
    name: Amcrest-2
    binary_sensors:
      - motion_detected
      - online
    sensors:
      - sdcard
camera:
  - platform: amcrest

But the configuration is coming as invalid with following error:
Invalid config for [camera]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 14).

Any pointers how to fix the code for “cameras/amcrest.yaml”?

Thanks,

Pankaj

The only thing that should be in that file, since you are including it from
camera:
is
- platform: amcrest

You can do this 2 different ways

#1) split these up by having 2 lines in your configuration.yaml

amcrest: !include amcrest.yaml
camera: !include camera.yaml

amcrest.yaml would include

  - host: !secret amcrest_2_ip
    username: !secret amcrest_username
    password: !secret amcrest_password
    name: Amcrest-2
    binary_sensors:
      - motion_detected
      - online
    sensors:
      - sdcard

and camera.yaml would merely have
- platform: amcrest

#2) If you are already using Packages, just add a new file called amcrest.yaml in your packages folder. If you are not using packages, read up at that link and it will guide you through setting it up. Packages is the way to go if you want to reduce the size of configuration.yaml.

if you go the packages route, the amcrest.yaml file would consist of

amcrest:
  - host: !secret amcrest_2_ip
    username: !secret amcrest_username
    password: !secret amcrest_password
    name: Amcrest-2
    binary_sensors:
      - motion_detected
      - online
    sensors:
      - sdcard

camera:
  - platform: amcrest

Hi Glenn,

You are spot on, I added amcrest.yaml and camera.yaml and the camera started working :clap:
But now I have another problem, I also have a Bedser camera and added “bedser.yaml” file to cameras folder, the Bedser camera is working on standalone basis.
To make HA read all the camera files, I modified “configuration.yaml” as follows:

#camera: !include cameras/bedser.yaml
amcrest: !include cameras/amcrest.yaml
#camera: !include cameras/camera.yaml
camera: !include_dir_merge_named cameras/

Here is the code under “Bedser.yaml”:

  - platform: generic
    name: Bedser-2
    username: !secret bedeser_2_username
    password: !secret bedser_2_password
    still_image_url: !secret bedser_2_still_url
    stream_source: !secret bedser_2_stream_source

So the file is not giving any “invalid” syntax error but the Bedser camera is not showing up in entities.
Any pointers why it is not loading?

Thanks and appreciate your help!
Pankaj

I would have just added the bedser info to the camera.yaml file you already had and not made a directory for each camera. Mine looks like this…

  - platform: nwsradar
    station: ewx
    style: Enhanced
    frames: 8  # Optional
    name: "NWS Radar"

  - platform: ffmpeg
    name: Wyze Cam 1
    input: !secret wyzecam1

  - platform: ffmpeg
    name: Wyze Cam 2
    input: !secret wyzecam2

  - platform: ffmpeg
    name: Wyze Cam 3
    input: !secret wyzecam3

  # - platform: ffmpeg
  #   name: Front Door Cam
  #   input: !secret front_cam

  - platform: mjpeg
    name: Octoprint
    still_image_url: "http://192.168.1.17/webcam/?action=snapshot"
    mjpeg_url: "http://192.168.1.17/webcam/?action=stream"

  - platform: local_file
    file_path: /local/mail_and_packages/mail_today.gif
    name: mail_usps

  - platform: generic
    name: Backyard Left
    still_image_url: !secret cam_102_url
    stream_source: !secret cam_102_url

  - platform: mjpeg
    name: Backyard Right
    mjpeg_url: !secret cam_105_url

Thanks Glenn…that’s two for two :smiley:

Appreciate the help, both cameras are working like a charm!

1 Like

That hasn’t been necessary for a long time. You can just delete it. You only need the stuff under amcrest.

Thanks Phil.

I moved the Bedser camera to its own file and deleted “camera.yaml”…this configuration also worked with both cameras!

Good to find multiple ways of using HA :smiley: