Irrigation Hunter X-Core remote control using REM pin

@dehaas Your script package helped me a lot. I translated it to english and added some more zones. Here is my updated version

##################################
# Irrigate zone selectbox       #
##################################
input_select:
  irrigate_zone:
    name: Irrigate zone
    options:
      - zone1
      - zone2
      - zone2
      - zone3
      - zone4
      - zone5
      - zone6
      - zone7

template:
  - sensor:
    - name: irrigate_map_zone
      state: >
        {% set mapper =
          { 'zone1':'1',
            'zone2':'2',
            'zone3':'3',
            'zone4':'4',
            'zone5':'5',
            'zone6':'6',
            'zone7':'7'} %}
        {% set state = states('input_select.irrigate_zone') %}
        {% set id = mapper[state] if state in mapper %}
        {{ id }}

input_text:
  irrigation_active_zone:
    initial: inactive

##################################
# Irrigation zone time selection   #
##################################
input_number:
  irrigate_timer_1:
    name: Timer zone1
    initial: 60
    min: 1
    max: 120
    step: 1

  irrigate_timer_2:
    name: Timer zone2
    initial: 60
    min: 1
    max: 120
    step: 1

  irrigate_timer_3:
    name: Timer zone3
    initial: 60
    min: 1
    max: 120
    step: 1

  irrigate_timer_4:
    name: Timer zone4
    initial: 60
    min: 1
    max: 120
    step: 1

  irrigate_timer_5:
    name: Timer zone5
    initial: 60
    min: 1
    max: 120
    step: 1

  irrigate_timer_6:
    name: Timer zone6
    initial: 60
    min: 1
    max: 120
    step: 1

  irrigate_timer_7:
    name: Timer zone7
    initial: 60
    min: 1
    max: 120
    step: 1
################################################
# Selected Sprinkler switch script & timer #
################################################
timer:
  irrigation_time_remaining:
    name: Remaining Time
    duration: "00:00:00"

switch:
  - platform: template
    switches:
      irrigate_lawn:
        friendly_name: "Sprinkler On/Off"
        turn_on:
          - service: script.turn_on
            data:
              entity_id: script.irrigation_on
          - service: timer.start
            target:
              entity_id: timer.irrigation_time_remaining
            data:
              duration: "{{ states('input_number.irrigate_timer_' ~ states('sensor.irrigate_map_zone')) | int  * 60 }}"
          - service: input_text.set_value
            target:
              entity_id: input_text.irrigation_active_zone
            data:
              value: "{{ states('sensor.irrigate_map_zone') }}"
        turn_off:
          - service: script.turn_on
            data:
              entity_id: script.irrigation_off
          - service: timer.finish
            target:
              entity_id: timer.irrigation_time_remaining
          - service: input_text.set_value
            target:
              entity_id: input_text.irrigation_active_zone
            data:
              value: inactive
        icon_template: >-
               {% if is_state('switch.irrigate_lawn', 'on') %}
               mdi:water-pump
               {% else %}
               mdi:water-pump-off
               {% endif %}

##################################
# Invoke mqtt            #
##################################
script:
  irrigation_on:
    alias: Sprinkler On
    sequence:
    - service: mqtt.publish
      data_template:
        topic_template: hunter/X-CORE/zone/{{ states('sensor.irrigate_map_zone') }}
        payload_template: >
          { "action": "start", "time": {{ states('input_number.irrigate_timer_' ~ states('sensor.irrigate_map_zone')) | int }} }

  irrigation_off:
    alias: Sprinkler Off
    sequence:
    - service: mqtt.publish
      data_template:
        topic_template: hunter/X-CORE/zone/{{ states('input_text.irrigation_active_zone') }}
        payload_template: >
          { "action": "stop" }

##################################
# Reset switch when timer finishes #
##################################
automation:
  - id: '1655392256832'
    alias: Irrigatie - reset switch wanneer timer klaar is
    description: ''
    trigger:
    - platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.irrigation_time_remaining
    condition: []
    action:
    - service: switch.turn_off
      data: {}
      target:
        entity_id: switch.irrigate_lawn
    mode: single

I also made a similar UI card as yours. I added a conditonal card which will show corresponding zone time input. I tried template entity card, to conditionally show the corresponding zone time input, but it quite doesn’t do what I wanted :

type: entities
entities:
  - input_select.irrigate_zone
  - type: conditional
    conditions:
      - entity: sensor.irrigate_map_zone
        state: '1'
    row:
      entity: input_number.irrigate_timer_1
  - type: conditional
    conditions:
      - entity: sensor.irrigate_map_zone
        state: '2'
    row:
      entity: input_number.irrigate_timer_2
  - type: conditional
    conditions:
      - entity: sensor.irrigate_map_zone
        state: '3'
    row:
      entity: input_number.irrigate_timer_3
  - type: conditional
    conditions:
      - entity: sensor.irrigate_map_zone
        state: '4'
    row:
      entity: input_number.irrigate_timer_4
  - type: conditional
    conditions:
      - entity: sensor.irrigate_map_zone
        state: '5'
    row:
      entity: input_number.irrigate_timer_5
  - type: conditional
    conditions:
      - entity: sensor.irrigate_map_zone
        state: '6'
    row:
      entity: input_number.irrigate_timer_6
  - type: conditional
    conditions:
      - entity: sensor.irrigate_map_zone
        state: '7'
    row:
      entity: input_number.irrigate_timer_7
  - type: custom:template-entity-row
    entity: input_number.irrigate_timer_{{ states('sensor.irrigate_map_zone')}}
  - entity: switch.irrigate_lawn
  - entity: timer.irrigation_time_remaining
  - input_text.irrigation_active_zone

1 Like