Advanced Card programming and integration to Automation for Watering system

Hi, I’m very, very new to Home Assistant, and still learning it’s power.
I’d like to know where I can find advanced documentation to program the cards.
Here is what I want:

I need to create a watering programming interface to automate watering my plants here.
I created a lovelace (based on another topic that helped me a lot to understand the syntax) interface with :

  • 2 buttons (sunset and sunrise)

  • 1 conditional card to program time (time of day)

  • interval of watering

  • Days of week

    I successfully managed to hide the program time card if sunset or sunrise are activated.
    I want that the buttons sunset and sunrise to be exclusive, if I click one, the other is deactivated. How do I do that ?

    After all done, how do I integrate the interface with some automation ?
    For example, I’d like to test if sunset or sunrise are set, ignore manual watering time, and make an automation based on the cards I selected.

    I have 4 lines of watering. So, the work will be done for each of them.

Thanks

PLease… let me post what I’ve already done. It’s on the way… but I need to learn more to see if it will work as I want…
Sorry, but interface and names are in Portuguese…

Here are my card config:

type: vertical-stack
title: Ráfis
cards:
  - type: horizontal-stack
    cards:
      - type: button
        aspect_ratio: 2/1
        color: auto-no-temperature
        icon: 'mdi:watering-can'
        size: 22%
        state:
          - color: 'rgb(255, 255, 255)'
            icon: 'mdi:water'
            value: 'on'
          - color: 'rgba(25, 25, 25, 0.3)'
            styles:
              icon:
                - color: 'rgba(255, 255, 255, 0.3)'
              name:
                - color: 'rgba(255, 255, 255, 0.3)'
            value: unavailable
        confirmation:
          text: Deseja Iniciar a Rega agora ?
        tap_action:
          action: toggle
        hold_action:
          action: none
        show_icon: true
        show_name: false
        entity: light.sonoff_1000e1dcb5
        name: Status
        icon_height: 40px
      - type: button
        aspect_ratio: 2/1
        color: auto-no-temperature
        icon: 'mdi:brightness-auto'
        confirmation:
          text: Deseja Ativar Rega Automática ?
        tap_action:
          action: toggle
        hold_action:
          action: none
        show_icon: true
        show_name: true
        entity: automation.irrigacao_rafis
        name: Automação
        icon_height: 40px
  - type: entities
    entities:
      - entity: input_datetime.ultima_rega_rafis
        name: Última rega
        show_state: false
        tap_action:
          action: none
  - type: horizontal-stack
    title: Programação da Rega
    cards:
      - type: button
        tap_action:
          action: toggle
        hold_action:
          action: none
        show_icon: true
        show_name: true
        entity: input_boolean.rafis_nascer_do_sol
        name: Amanhecer
        icon_height: 40px
      - type: button
        tap_action:
          action: toggle
        hold_action:
          action: none
        show_icon: true
        show_name: true
        entity: input_boolean.rafis_por_do_sol
        name: Pôr do Sol
        icon_height: 40px
  - type: entities
    entities:
      - entity: input_number.intervalo_irriga_rafis
  - type: conditional
    conditions:
      - entity: input_boolean.rafis_nascer_do_sol
        state: 'off'
        tap_action:
          action: input_boolean.rafis_por_do_sol.toggle
      - entity: input_boolean.rafis_por_do_sol
        tap_action:
          action: toggle
        state: 'off'
    card:
      type: entities
      entities:
        - entity: sensor.hora_irriga_rafis
          name: Hora Programada
        - entity: input_number.rafis_irrigacao_hora
          name: Hora
        - entity: input_number.rafis_irrigacao_minutos
          name: Minutos


This will the following lovelace interface with the bottom part conditional:

For the sensors I have (for now):

- platform: template                                                                                         
  sensors:                                                                                                   
    hora_irriga_rafis:                                                                                       
      friendly_name: 'Hora Irrigacao Rafis'                                                                  
      value_template: "{{'{:02d}:{:02d}'.format(states('input_number.rafis_irrigacao_hora') | int, states('in
                                                                                                             
    nextsunrise:                                                                                             
      entity_id: sun.sun                                                                                     
      friendly_name: 'Next Sunrise'                                                                          
      value_template: >                                                                                      
        {{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom(' %I:%M %p') | replace(" 0"
      icon_template: mdi:weather-sunset-up                                                                   
                                                                                                             
    nextsunset:                                                                                              
      entity_id: sun.sun                                                                                     
      friendly_name: 'Next Sunset'                                                                           
      value_template: >                                                                                      
         {{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom(' %I:%M %p') | replace(" 
      icon_template: mdi:weather-sunset-down                                                                 
                                                                                                             
- platform: time_date                                                                                        
  display_options:                                                                                           
    - 'time'                                                                                                 
      

Now, I need an automation to use these controls. Specially, to treat the trigger should be : if sunrise or sunset is selected, the manual time chosen will be the active one, and respecting the days interval (condition).

Since I’m pretty new to this, I don’ t know which is the better aproach. I’m thinking in putting as a trigger a template that tests all times, something like:

if sunset or sunrise is activated: 
      if now() is sunrise and sunrise is activated, return true
      else if now() is sunset and sunset is activated, return true
else if now() is manual time return true

And on condition I put the days interval configured, like (ignore the names, need to check):

{{ ((states.sensor.time.last_changed - states.device_rafis.last_changed).total_seconds() / 3600) >  states('input_number.interval_days') }}

Please… any help ?

Thanks a lot.

Or would be better, the TRIGGER be activated on sunrise, sunset and manual time, and on CONDITION I put all other tests ?
could somebody give me some light ?

I’m alone here. I managed to do almost all programming, but it is not works as I wanted. But the problem is on the automation condition. All post the card here and open another automation.

type: vertical-stack
title: Ráfis
cards:
  - type: horizontal-stack
    cards:
      - type: button
        aspect_ratio: 2/1
        color: auto-no-temperature
        icon: 'mdi:watering-can'
        size: 22%
        state:
          - color: 'rgb(255, 255, 255)'
            icon: 'mdi:water'
            value: 'on'
          - color: 'rgba(25, 25, 25, 0.3)'
            styles:
              icon:
                - color: 'rgba(255, 255, 255, 0.3)'
              name:
                - color: 'rgba(255, 255, 255, 0.3)'
            value: unavailable
        confirmation:
          text: Deseja Iniciar a Rega agora ?
        tap_action:
          action: toggle
        hold_action:
          action: none
        show_icon: true
        show_name: false
        entity: light.sonoff_1000e1dcb5
        name: Status
        icon_height: 40px
      - type: button
        aspect_ratio: 2/1
        color: auto-no-temperature
        icon: 'mdi:brightness-auto'
        confirmation:
          text: Deseja Ativar Rega Automática ?
        tap_action:
          action: toggle
        hold_action:
          action: none
        show_icon: true
        show_name: true
        entity: automation.lovelace_irrigacao_rafis
        name: Automação
        icon_height: 40px
  - type: horizontal-stack
    cards:
      - type: markdown
        content: '## Última Rega:'
        style:
          text-align: left
      - type: markdown
        content: >-
          *{{as_timestamp(states("input_datetime.ultima_rega_rafis"))|timestamp_custom("%d/%m/%Y
          às %H:%M") }}*
  - type: horizontal-stack
    title: Programação da Rega
    cards:
      - type: button
        tap_action:
          action: toggle
        hold_action:
          action: none
        show_icon: true
        show_name: true
        entity: input_boolean.rafis_nascer_do_sol
        name: Amanhecer
        icon_height: 40px
      - type: button
        tap_action:
          action: toggle
        hold_action:
          action: none
        show_icon: true
        show_name: true
        entity: input_boolean.rafis_por_do_sol
        name: Pôr do Sol
        icon_height: 40px
  - type: entities
    entities:
      - entity: input_number.intervalo_irriga_rafis
  - type: conditional
    conditions:
      - entity: input_boolean.rafis_nascer_do_sol
        state: 'off'
        tap_action:
          action: input_boolean.rafis_por_do_sol.toggle
      - entity: input_boolean.rafis_por_do_sol
        tap_action:
          action: toggle
        state: 'off'
    card:
      type: entities
      entities:
        - entity: sensor.hora_irriga_rafis
          name: Hora Programada
        - entity: input_number.rafis_irrigacao_hora
          name: Hora
        - entity: input_number.rafis_irrigacao_minutos
          name: Minutos