name: Tap timer
legacy_type: garza_irrigation_system
products:
  - id: zrsgzc8jktsricjj
    manufacturer: Holman
    model: WX1
    # DP decoding thanks to funtastix
  - id: ixckfr3zke5fgach
    manufacturer: RainPoint
    model: TCS005FRF
  - id: xnajzurgqo1ugohn
    manufacturer: Garza
    model: ITV103W
entities:
  - entity: valve
    name: Manual
    class: water
    dps:
      - id: 108
        type: boolean
        name: valve
        mapping:
          - dps_val: true
            value: false
          - dps_val: false
            value: true
      - id: 127
        type: string
        optional: true
        name: version
  - entity: sensor
    name: Soil temperature
    class: temperature
    category: diagnostic
    hidden: unavailable
    dps:
      - id: 101
        name: sensor
        type: integer
        optional: true
        unit: C
      - id: 115
        name: available
        type: boolean
        optional: true
        mapping:
          - dps_val: null
            value: false
  - entity: sensor
    name: Soil moisture
    class: moisture
    category: diagnostic
    hidden: unavailable
    dps:
      - id: 102
        name: sensor
        type: integer
        optional: true
        unit: "%"
      - id: 102
        type: integer
        optional: true
        name: available
        mapping:
          - dps_val: null
            value: false
          - dps_val: 65535
            value: false
          - dps_val: -1
            value: false
          - value: true
  - entity: sensor
    name: Water flow
    class: water
    category: diagnostic
    icon: "mdi:water"
    dps:
      - id: 103
        name: sensor
        type: integer
        unit: L
  - entity: sensor
    class: battery
    category: diagnostic
    dps:
      - id: 105
        type: integer
        name: sensor
        unit: "%"
        mapping:
          - dps_val: 0
            value: 10
          - dps_val: 1
            value: 50
          - dps_val: 2
            value: 100
  - entity: sensor
    translation_key: status
    class: enum
    category: diagnostic
    dps:
      - id: 106
        type: integer
        name: sensor
        mapping:
          - dps_val: 0
            value: idle
          - dps_val: 1
            value: manual
          - dps_val: 2
            value: auto
          - dps_val: 3
            value: rain_delay
  - entity: number
    translation_key: timer
    class: duration
    category: config
    dps:
      - id: 107
        type: integer
        name: value
        unit: min
        range:
          min: 0
          max: 60
  - entity: sensor
    translation_key: time_remaining
    class: duration
    category: diagnostic
    dps:
      - id: 109
        optional: true
        type: integer
        name: sensor
        unit: min
  - entity: sensor
    name: Start A encoded
    # this DP shows the start time, duration and days
    # for start A. Not controllable - use automation instead.
    category: diagnostic
    dps:
      - id: 110
        optional: true
        name: sensor
        type: base64
      - id: 110
        optional: true
        # flags for days of the week Sun-Sat, plus a bit for on/off
        name: days
        type: base64
        mask: "FF000000"
      - id: 110
        optional: true
        name: minutes_duration
        type: base64
        mask: "FF00000000"
      - id: 110
        optional: true
        name: hours_duration
        type: base64
        mask: "FF0000000000"
      - id: 110
        optional: true
        name: minutes_start
        type: base64
        mask: "FF000000000000"
      - id: 110
        optional: true
        name: hours_start
        type: base64
        mask: "FF00000000000000"
  - entity: sensor
    name: Start B encoded
    category: diagnostic
    dps:
      - id: 111
        optional: true
        name: sensor
        type: string
      - id: 111
        optional: true
        name: days
        type: base64
        mask: "FF000000"
      - id: 111
        optional: true
        name: minutes_duration
        type: base64
        mask: "FF00000000"
      - id: 111
        optional: true
        name: hours_duration
        type: base64
        mask: "FF0000000000"
      - id: 111
        optional: true
        name: minutes_start
        type: base64
        mask: "FF000000000000"
      - id: 111
        optional: true
        name: hours_start
        type: base64
        mask: "FF00000000000000"
  - entity: sensor
    name: Start C encoded
    category: diagnostic
    dps:
      - id: 112
        optional: true
        name: sensor
        type: string
      - id: 112
        optional: true
        name: days
        type: base64
        mask: "FF000000"
      - id: 112
        optional: true
        name: minutes_duration
        type: base64
        mask: "FF00000000"
      - id: 112
        optional: true
        name: hours_duration
        type: base64
        mask: "FF0000000000"
      - id: 112
        optional: true
        name: minutes_start
        type: base64
        mask: "FF000000000000"
      - id: 112
        optional: true
        name: hours_start
        type: base64
        mask: "FF00000000000000"
  - entity: select
    name: Watering delay
    translation_key: timer
    category: config
    dps:
      - id: 113
        name: option
        type: string
        optional: true
        mapping:
          - dps_val: 0
            value: cancel
          - dps_val: 24
            value: 24h
          - dps_val: 48
            value: 48h
          - dps_val: 72
            value: 72h
  - entity: select
    name: Time format
    category: config
    dps:
      - id: 114
        name: option
        type: string
        optional: true
        mapping:
          - dps_val: 12
            value: 12H
          - dps_val: 24
            value: 24H
  - entity: binary_sensor
    name: Soil sensor power OK
    category: diagnostic
    hidden: unavailable
    dps:
      - id: 117
        name: sensor
        optional: true
        type: boolean
      - id: 115
        name: available
        type: boolean
        optional: true
        mapping:
          - dps_val: null
            value: false
  - entity: select
    name: Units
    category: config
    dps:
      - id: 119
        name: option
        type: string
        optional: true
        mapping:
          - dps_val: 1
            value: "l/C"
          - dps_val: 2
            value: "gal/F"
  - entity: sensor
    name: Alarm status
    category: diagnostic
    dps:
      - id: 120
        name: sensor
        type: integer
  - entity: sensor
    # past 10 days of flow count history.
    name: Flow count encoded
    category: diagnostic
    dps:
      - id: 121
        optional: true
        name: sensor
        type: base64
      - id: 121
        optional: true
        name: 10_days
        type: base64
        mask: "FF"
      - id: 121
        optional: true
        name: 10_days_256
        type: base64
        mask: "FF00"
      - id: 121
        optional: true
        name: 9_days
        type: base64
        mask: "FF0000"
      - id: 121
        optional: true
        name: 9_days_256
        type: base64
        mask: "FF000000"
      - id: 121
        optional: true
        name: 8_days
        type: base64
        mask: "FF00000000"
      - id: 121
        optional: true
        name: 8_days_256
        type: base64
        mask: "FF0000000000"
      - id: 121
        optional: true
        name: 7_days
        type: base64
        mask: "FF000000000000"
      - id: 121
        optional: true
        name: 7_days_256
        type: base64
        mask: "FF00000000000000"
      - id: 121
        optional: true
        name: 6_days
        type: base64
        mask: "FF0000000000000000"
      - id: 121
        optional: true
        name: 6_days_256
        type: base64
        mask: "FF000000000000000000"
      - id: 121
        optional: true
        name: 5_days
        type: base64
        mask: "FF00000000000000000000"
      - id: 121
        optional: true
        name: 5_days_256
        type: base64
        mask: "FF0000000000000000000000"
      - id: 121
        optional: true
        name: 4_days
        type: base64
        mask: "FF000000000000000000000000"
      - id: 121
        optional: true
        name: 4_days_256
        type: base64
        mask: "FF00000000000000000000000000"
      - id: 121
        optional: true
        name: 3_days
        type: base64
        mask: "FF0000000000000000000000000000"
      - id: 121
        optional: true
        name: 3_days_256
        type: base64
        mask: "FF000000000000000000000000000000"
      - id: 121
        optional: true
        name: 2_days
        type: base64
        mask: "FF00000000000000000000000000000000"
      - id: 121
        optional: true
        name: 2_days_256
        type: base64
        mask: "FF0000000000000000000000000000000000"
      - id: 121
        optional: true
        name: 1_day
        type: base64
        mask: "FF000000000000000000000000000000000000"
      - id: 121
        optional: true
        name: 1_day_256
        type: base64
        mask: "FF00000000000000000000000000000000000000"
  - entity: sensor
    name: Temperature count encoded
    category: diagnostic
    dps:
      - id: 122
        optional: true
        name: sensor
        type: base64
  - entity: sensor
    name: Moisture count encoded
    category: diagnostic
    dps:
      - id: 123
        optional: true
        name: sensor
        type: base64
  - entity: binary_sensor
    name: Postponed due to rain
    category: diagnostic
    hidden: unavailable
    dps:
      - id: 125
        name: sensor
        type: boolean
        optional: true
      - id: 116
        optional: true
        name: available
        type: boolean
        mapping:
          - dps_val: null
            value: false
  - entity: sensor
    # based on starts A, B and C
    name: Next watering encoded
    category: diagnostic
    dps:
      - id: 128
        optional: true
        name: sensor
        type: base64
      - id: 128
        optional: true
        name: minute
        type: base64
        mask: "FF"
      - id: 128
        optional: true
        name: hour
        type: base64
        mask: "FF00"
      - id: 128
        optional: true
        name: day
        type: base64
        mask: "FF0000"
      - id: 128
        optional: true
        name: month
        type: base64
        mask: "FF000000"
      - id: 128
        optional: true
        name: year
        type: base64
        mask: "FF00000000"
