- alias: Update Height
  trigger:
    platform: state
    entity_id:
      - input_number.jc_pecan_grade
      - input_number.jc_crush_amount
  action:
    service: mqtt.publish
    data:
      topic: /jc/height
      payload_template:
        "{{ ((states('input_number.jc_pecan_grade') | int) - (states('input_number.jc_crush_amount')
        | float)) | int }}"
  id: 4c9a1a4d2ded4dbeac71ee63ef297de2
- id: "1705938099970"
  alias: Experiment Duration
  description: Run the vibratory conveyor for 15 second intervals
  trigger:
    - platform: device
      type: turned_on
      device_id: bdc5f90b963bab0edf03bfeeff494858
      entity_id: f2132fd3b40e6062062421b5a7923067
      domain: switch
  condition:
    - condition: state
      entity_id: switch.jc_limit_feed_duration
      state: "on"
  action:
    - delay:
        seconds: "{{ states('number.jc_feed_time') | float }}"
    - type: turn_off
      device_id: bdc5f90b963bab0edf03bfeeff494858
      entity_id: f2132fd3b40e6062062421b5a7923067
      domain: switch
  mode: single
- id: "1714686528002"
  alias: Tag bin4b is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1DD6A704
  condition: []
  action:
    - service: mqtt.publish
      metadata: {}
      data_template:
        qos: "1"
        retain: true
        topic: /sheller/bin4
        payload: "{{ states('sensor.sheller_scale') | float - 3.92 | round(2) }}"
  mode: single
- id: "1714691006075"
  alias: Tag bin4a is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1699DD04
  condition: []
  action:
    - service: mqtt.publish
      metadata: {}
      data_template:
        qos: "1"
        retain: true
        topic: /sheller/bin4
        payload: "{{ states('sensor.sheller_scale') | float - 4.0 | round(2) }}"
  mode: single
- id: "1714691234056"
  alias: Tag bin3a is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 17D18B04
  condition: []
  action:
    - service: mqtt.publish
      metadata: {}
      data_template:
        qos: "1"
        retain: true
        topic: /sheller/bin3
        payload: "{{ states('sensor.sheller_scale') | float - 7.23 | round(2) }}"
  mode: single
- id: "1714691252744"
  alias: Tag bin3b is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1B9E6204
  condition: []
  action:
    - service: mqtt.publish
      metadata: {}
      data_template:
        qos: "1"
        retain: true
        topic: /sheller/bin3
        payload: "{{ states('sensor.sheller_scale') | float - 7.13 | round(2) }}"
  mode: single
- id: "1714691270889"
  alias: Tag bin2a is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 72F8A704
  condition: []
  action:
    - service: mqtt.publish
      metadata: {}
      data_template:
        qos: "1"
        retain: true
        topic: /sheller/bin2
        payload: "{{ states('sensor.sheller_scale') | float - 7.02 | round(2) }}"
  mode: single
- id: "1714691288523"
  alias: Tag bin2b is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1A414204
  condition: []
  action:
    - service: mqtt.publish
      metadata: {}
      data_template:
        qos: "1"
        retain: true
        topic: /sheller/bin2
        payload: "{{ states('sensor.sheller_scale') | float - 7.0 | round(2) }}"
  mode: single
- id: "1714691306464"
  alias: Tag bin1a is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1AECA004
  condition: []
  action:
    - service: mqtt.publish
      metadata: {}
      data_template:
        qos: "1"
        retain: true
        topic: /sheller/bin1
        payload: "{{ states('sensor.sheller_scale') | float - 5.69 | round(2) }}"
  mode: single
- id: "1714691321231"
  alias: Tag bin1b is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1983D704
  condition: []
  action:
    - service: mqtt.publish
      metadata: {}
      data_template:
        qos: "1"
        retain: true
        topic: /sheller/bin1
        payload: "{{ states('sensor.sheller_scale') | float - 5.52 | round(2) }}"
  mode: single
- id: "1715008110813"
  alias: Tag take-general-mass-sample is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1ADE4304
  condition: []
  action:
    - service: input_select.select_option
      target:
        entity_id: input_select.mass_sample_mode
      data:
        option: General Yield Sample
  mode: single
- id: "1715008192820"
  alias: Tag take-halves-mass-sample is scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1B983A04
  condition: []
  action:
    - service: input_select.select_option
      target:
        entity_id: input_select.mass_sample_mode
      data:
        option: Half Yield Sample
  mode: single
- id: "1716233507175"
  alias: Cup 1 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: "11275204"
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "1"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233528548"
  alias: Cup 2 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 123E8904
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "2"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233545612"
  alias: Cup 3 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1FD4D704
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "3"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233563052"
  alias: Cup 4 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: "12619704"
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "4"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233589077"
  alias: Cup 5 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 105B1904
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "5"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233604589"
  alias: Cup 6 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 10A49304
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "6"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233621036"
  alias: Cup 7 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1145FB04
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "7"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233634788"
  alias: Cup 8 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: "11866104"
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "8"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233649980"
  alias: Cup 9 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1FBCF604
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "9"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233677941"
  alias: Cup 10 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 11261C04
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "10"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233694725"
  alias: Cup 11 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 116CE504
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "11"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233716972"
  alias: Cup 12 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: "10192204"
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "12"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233734357"
  alias: Cup 13 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1051FF04
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "13"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233749157"
  alias: Cup 14 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 10E1A404
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "14"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233763405"
  alias: Cup 15 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 1FB63C04
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "15"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716233790021"
  alias: Cup 16 Scanned
  description: ""
  trigger:
    - platform: tag
      tag_id: 10F61E04
  condition: []
  action:
    - service: input_select.select_option
      metadata: {}
      data:
        option: "16"
      target:
        entity_id: input_select.activecup
  mode: single
- id: "1716234851972"
  alias: Virtual Scale Weigh
  description: ""
  trigger:
    - platform: numeric_state
      entity_id:
        - sensor.precision_scale
      above: 0
  condition:
    - condition: not
      conditions:
        - condition: state
          entity_id: input_select.activecup
          state: None
  action:
    - variables:
        cup_entity_prefix: sensor.cup_{{ states('input_select.activecup') }}
        cup_tare_entity: "{{cup_entity_prefix + '_tare_weight'}}"
        cup_general_entity: "{{cup_entity_prefix + '_general_sample_weight'}}"
        cup_half_entity: "{{cup_entity_prefix + '_half_sample_weight'}}"
    - choose:
        - conditions:
            - condition: state
              entity_id: input_select.mass_sample_mode
              state: Tare
          sequence:
            - service: mqtt.publish
              metadata: {}
              data_template:
                topic: /scale/cup{{ states('input_select.activecup') }}/tare
                payload: "{{ states('sensor.precision_scale') }}"
                retain: true
        - conditions:
            - condition: state
              entity_id: input_select.mass_sample_mode
              state: General Yield Sample
          sequence:
            - service: mqtt.publish
              metadata: {}
              data_template:
                topic: /scale/cup{{ states('input_select.activecup') }}/general
                payload:
                  "{{ states('sensor.precision_scale') | float - states(cup_tare_entity)
                  | float if states('sensor.precision_scale') > states(cup_tare_entity)
                  else 0 }}"
                retain: true
            - service: mqtt.publish
              metadata: {}
              data_template:
                topic: /scale/cup{{ states('input_select.activecup') }}/half
                payload: 0
                retain: true
        - conditions:
            - condition: state
              entity_id: input_select.mass_sample_mode
              state: Half Yield Sample
          sequence:
            - service: mqtt.publish
              metadata: {}
              data_template:
                topic: /scale/cup{{ states('input_select.activecup') }}/half
                payload:
                  "{{ states('sensor.precision_scale') | float - states(cup_tare_entity)
                  | float  if states('sensor.precision_scale') > states(cup_tare_entity)
                  else 0 }}"
                retain: true
            - delay:
                hours: 0
                minutes: 0
                seconds: 2
                milliseconds: 0
            - service: mqtt.publish
              metadata: {}
              data_template:
                topic: /half_yield
                payload:
                  "{{ states(cup_half_entity) | float / states(cup_general_entity)
                  | float * 100 }}"
                retain: true
      default: []
    - service: input_select.select_option
      target:
        entity_id: input_select.activecup
      data:
        option: None
  mode: single
- id: "1717534824373"
  alias: Drum PID
  description: ""
  trigger:
    - platform: state
      entity_id:
        - sensor.drum_pid
  condition: []
  action:
    - service: light.turn_on
      metadata: {}
      data:
        brightness: "{{ states('sensor.drum_pid') | int }}"
      target:
        entity_id: light.shellyplus010v_e86beae4d350_light_0
  mode: single
- id: "1717535056368"
  alias: Paddle PID
  description: ""
  trigger:
    - platform: state
      entity_id:
        - sensor.paddle_pid
  condition: []
  action:
    - service: light.turn_on
      metadata: {}
      data:
        brightness: "{{ states('sensor.paddle_pid') | int }}"
      target:
        entity_id: light.shellyplus010v_e86beae4df24_light_0
  mode: single
- id: "1721673617742"
  alias: Turn on Lights for Motion Events
  description: ""
  trigger:
    - platform: state
      entity_id:
        - switch.tp_link_power_strip_d7c1_vibratory_conveyor
      to: "on"
  condition: []
  action:
    - service: light.turn_on
      metadata: {}
      data: {}
      target:
        entity_id: light.tp_link_power_strip_d7c1_zima_board
  mode: single
- id: "1721673662507"
  alias: Turn off Lights with no Motion Detection
  description: ""
  trigger:
    - platform: state
      entity_id:
        - switch.tp_link_power_strip_d7c1_vibratory_conveyor
      to: "off"
  condition: []
  action:
    - service: light.turn_off
      target:
        entity_id:
          - light.tp_link_power_strip_d7c1_zima_board
      data: {}
  mode: single
- id: "1724078394290"
  alias: Link Vibratory Conveyors
  description: ""
  trigger:
    - platform: state
      entity_id:
        - switch.shellyplus1pm_c049ef8c7310_switch_0
      from: "off"
      to: "on"
  condition: []
  action:
    - service: switch.turn_on
      target:
        entity_id:
          - switch.tp_link_power_strip_d7c1_vibratory_conveyor
      data: {}
  mode: single
- alias: "Set theme at startup"
  trigger:
    platform: homeassistant
    event: start
  action:
    service: frontend.set_theme
    data:
      name: Dawg
