Hikvision cam with a power switch

Hi all,
Very new with HA, reading so many forums, but still need help, plz.
I got a PI4/8gb with SSD, working fine. core-2021.9.7. supervisor-2021.10.0

I now need to use my hikvision (DS-2CD2185FWD-IS) camera to detect intrusion and if there is, power a switch (Edimax sp-2101w).

Automations.yaml

alias: When CAMERA activated
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.ip_camera_motion
    to: 'on'
condition: []
action:
  - service: light.turn_on
    target:
      entity_id: switch.maprise
mode: single

configuration.yaml

binary_sensor:
  - platform: hikvision
    host: 192.168.0.107
    port: 80
    ssl: false
    username: sdfsdf
    password: ghfghfgh
    customize:
      motion:
        delay: 1
      line_crossing:
        ignored: true

switch:
  - platform: edimax
    name: MaPrise
    host: 192.168.0.112
    username: ertert
    password: dfgdfgg

I tried to reboot
Syntax seems ok, no error on start

Logbook
IP CAMERA Motion cleared (no motion detected)
5:46:55 PM - 4 minutes ago
IP CAMERA Motion detected motion
5:46:22 PM - 5 minutes ago

History
I can see the lines :

  • “When CAMERA activated” always green
  • “IP CAMERA Motion” red and flashing green when I move in front of the camera
  • “MaPrise” (power switch) always off

So, I guess Camera and switch are ok but that does not work.
Would you please help me to debug ? I did not find an easy method to test.

THANKS a lot

Change your service to switch.turn_on instead of light.turn_on

Great, I fixed that, you’re right.
But it still does not work. How can I debug ?

There were a 2nd error with MaPrise and not maprise.
I fixed that, rebooted, but it does not work.

I see in History ( “IP CAMERA Motion” red and flashing green when I move in front of the camera) but when I mouse over that line binary_sensor.ip_camera_motion**_2** is shown. Could that be the reason ?

Thanks again for your time…

It needs to be the correct name, go to dev tools to find the sensor in question.

Hello,

binary_sensor.ip_camera_motion_2 is the name… don’t know why but confirmed with Dev Tools.
MANY THANKS !!