Automation change mode zoneminder

Hi everyone, I’m trying to create an automation that changes the cameras from “Monitor” to “Modect” when the family group is away from home or from 23:00:00 to 07:00:00, and change from “Modect” to “Monitor” when the family group is at home.

this my beta code

- id: '1622197118844'
  alias: Attivazione Modect
  description: ''
  trigger:
  - platform: state
    entity_id: group.camera
    to: Monitor
  condition:
  - condition: or
    conditions:
    - condition: state
      entity_id: group.famiglia
      state: not_home
    - condition: time
      after: '23:00:00'
      before: 07:00:00
  action:
  - condition: state
    entity_id: switch.studio_state
    state: Modect
  - condition: state
    entity_id: switch.esterno_ing_state
    state: Modect
  mode: single
- id: '1622197379488'
  alias: Attivazione Monitor
  description: ''
  trigger:
  - platform: state
    entity_id: group.camera
    to: Modect
  condition:
  - condition: or
    conditions:
    - condition: state
      entity_id: group.famiglia
      state: home
    - condition: time
      after: 07:00:01
      before: '23:00:01'
  action:
  - condition: state
    entity_id: switch.studio_state
    state: Monitor
  - condition: state
    entity_id: switch.esterno_ing_state
    state: Monitor
  mode: single

You should use the time or the zoning as the triggers. Your action is wrong, too: you need to use a service not a condition. Something like this:

alias: Attivazione Modect
description:>
  Switches the camera to Modect mode when the family is not home or at night
id: fb914050-14e5-4489-9038-abd4999344a5
trigger:
  - platform: state
    entity_id: group:famiglia
    state: 'not_home'
  - platform: time
    at: "23:00:00"
action:
  # you need to work out the "to Modect" action

alias: Attivazione Monitor
description: >
  Switches the camera to Monitor mode when the family is home in the day
id: ed211cd6-4bc7-4678-b75b-5d31bfb4d6b9
trigger:
  - platform: state
    entity_id: group:famiglia
    state: 'home'
  - platform: time
    at: "07:00:00"
condition:
  - "{{ (states('group.famiglia')) == 'home' and (7 <= now().hour < 23) }}"
action:
  # you need to work out the "to Monitor" action

For the action, you need to figure out what service to call to switch your cameras between modes. I can’t suggest that without knowing more about them: do you have a switch.studio_state as an entity? Please post a screenshot of Developer Tools / States showing its State and Attributes.

this the screen:
switch

i need switch ‘on’ (modect) when group.famiglia is ‘not_home’ or time between 23:00:00 and 07:00:00
and switch ‘off’ (monitor9 when group.gamiglia is ‘home’ or time between 07:00:01 and 22:59:59

If turning that switch and the other one on and off does what you need, then it’s as simple as:

alias: Attivazione Modect
description:>
  Switches the camera to Modect mode when the family is not home or at night
id: fb914050-14e5-4489-9038-abd4999344a5
trigger:
  - platform: state
    entity_id: group:famiglia
    state: 'not_home'
  - platform: time
    at: "23:00:00"
action:
  - service: switch.turn_on
    entity_id: switch.studio_state
  - service: switch.turn_on
    entity_id: switch.esterno_ing_state

alias: Attivazione Monitor
description: >
  Switches the camera to Monitor mode when the family is home in the day
id: ed211cd6-4bc7-4678-b75b-5d31bfb4d6b9
trigger:
  - platform: state
    entity_id: group:famiglia
    state: 'home'
  - platform: time
    at: "07:00:00"
condition:
  - "{{ (states('group.famiglia')) == 'home' and (7 <= now().hour < 23) }}"
action:
  - service: switch.turn_off
    entity_id: switch.studio_state
  - service: switch.turn_off
    entity_id: switch.esterno_ing_state

The first automation turns the switches on when the family is away or it’s 23:00, and the second one turns the switches off when the family come home or at 07:00, checking that both conditions are true (family are home and it’s the daytime) before taking the action.

another question, which mode should I use?

single
restart
parallel
queued

Sorry, but the automation for activate monitor doesn’t work


Ok, so what was the state of group.famiglia at 07:00?

today the automation works fine, i change this:

condition:
  - "{{ (states('group.famiglia')) == 'home' and (7 <= now().hour < 23) }}"

in

  - condition: template
   value_template: '{{ (states(''group.famiglia'')) == ''home'' and (7 <= now().hour < 23) }}'

Glad it’s working, although I don’t understand why the shorthand version didn’t work for you.

i don’t know.

thx for the support.