Autonomation, from form

Hello,

For my robomower i want it to mow for 45 minutus when it havent mowed yesterday (with the stock app schedule bacause of tome options), also mow now when there is a rainchange more than 10% tomorow.
-Can someone tell me if this is right,or do i need an % karakter in it?
-also, the triggers, does it go off when there all true, or just 1 of them?
i cant test it easy, can someone conform if this is right?
Thanks in advance

  alias: Grasmaaien
  description: ''
  trigger:
  - event: sunset
    platform: sun
  - at: '20:30'
    platform: time
  - entity_id: sensor.br_rainchance_1d
    from: '10'
    platform: state
  condition:
  - condition: template
    value_template: "        {% set last_run = state_attr('landroid_cloud.start',\
      \ 'last_triggered') %}\n        {{ last_run is none or (now().date() - last_run.date()).days\
      \ >= 1 }}"
  - condition: and
    conditions:
    - condition: not
      conditions:
      - condition: state
        entity_id: sensor.landroid_maaike_error
        state: Rain delay
  action:
  - data: {}
    service: landroid_cloud.start
  - timeout: '45'
    wait_template: ''
  - data: {}
    service: landroid_cloud.home

Please see the pinned message for how to correctly format code. Without you doing that it’s hard to follow the code.

For triggers… it’s explained here:

When any of the automation’s triggers becomes true (trigger fires), Home Assistant will validate the conditions, if any, and call the action.

Think of triggers & conditions this way.

Triggers are events (things that happen.) If you have more than one trigger, any one of them happening can cause the automation’s actions to run. So in your post, they are “sun setting”, “clock reaching 20:30”, “sensor.br_rainchance_1d's state changing from '10' to some other value.”

Conditions test the current state of the system. They are evaluated when one of the triggers “fires.” If true then the actions run. If not, then the actions don’t run.

So, think about when you want the actions to run. Then create a trigger for each of those events.

Next, think about what the state of the system must be for the actions to run when one of the triggers “fires.”

So putting that together, the actions run if the condition(s) is/are true when one of the trigger events occurs.

2 Likes

If you need an “and” function on a trigger you may need to try a template.

trigger:
  platform: template
  value_template: >
    {{ is_state('switch.living_room', 'on')
    and is_state('switch.house', 'off')
    and not is_state('sensor.motion', 'off')
    and is_state_attr('climate.thermostat', 'preset_mode', 'away')
    }}

This gives a few examples of ands with ‘not’ and added attributes.

Or just use conditions :wink:

This topic makes me think of the consequences of a robotic mower let loose by an imperfect automation.

Thanks all.

Taras, why do you think its imperfect, and what consequences?

I don’t think there’s a suggestion that your automation is necessarily imperfect. As to consequences,

image

1 Like

What Troon said.

My point was that the consequences of a bug in an automation that controls damage-inflicting devices are potentially greater than, say, a buggy automation that controls lighting. It doesn’t have to be a robotic mower, a remotely-operated garage door can have undesirable consequences or even a thermostat (that fails to heat an unoccupied vacation home in the dead of winter). Some automations just need extra care to handle various edge-cases to ensure they don’t cause costly (or even tragic) incidents.

There is indeed an advert in the UK to that end :wink:

1 Like