Skip to content

Latest commit

 

History

History
170 lines (129 loc) · 4.82 KB

File metadata and controls

170 lines (129 loc) · 4.82 KB

🖥️ Example: Plant Search GUI

Build a simple plant search interface in Home Assistant using OpenPlantbook actions, helpers, and Lovelace cards.

OpenPlantbook GUI example

Note

This UI is not part of the integration — it's an example of what you can build with the OpenPlantbook actions.


📑 Table of Contents


📋 Helpers

Create these helpers to store search results and trigger the automations. You can create them via YAML or in the UI under SettingsDevices & ServicesHelpers.

Input Text — Search Field

input_text:
  openplantbook_search:
    name: Search OpenPlantbook

Input Select — Search Results Dropdown

input_select:
  openplantbook_searchresults:
    name: Openplantbook Search Results
    options:
      - "Search first"

Input Button — Clear Cache

input_button:
  openplantbook_clear_cache:
    name: Clear Openplantbook Cache

⚙️ Automations

These automations wire the helpers to the OpenPlantbook actions.

🔍 Search When Text Changes

Triggers a search whenever the search field is updated:

alias: Search Openplantbook
triggers:
  - trigger: state
    entity_id: input_text.openplantbook_search
actions:
  - action: openplantbook.search
    data:
      alias: "{{ states('input_text.openplantbook_search') }}"

📋 Populate Dropdown with Results

Fills the dropdown when search results arrive:

alias: Populate Openplantbook Dropdown
triggers:
  - trigger: state
    entity_id: openplantbook.search_result
actions:
  - action: input_select.set_options
    data:
      entity_id: input_select.openplantbook_searchresults
      options: |
        {% if states('openplantbook.search_result') | int(default=0) > 0 %}
          {{ states.openplantbook.search_result.attributes | list }}
        {% else %}
          [ "No plants found"]
        {% endif %}

🌱 Fetch Details on Selection

Gets full plant data when a species is selected from the dropdown:

alias: Get Info From Openplantbook
triggers:
  - trigger: state
    entity_id: input_select.openplantbook_searchresults
actions:
  - action: openplantbook.get
    data:
      species: "{{ states('input_select.openplantbook_searchresults') }}"

🗑️ Clear Cache on Button Press

alias: Clear Openplantbook cache
triggers:
  - trigger: state
    entity_id: input_button.openplantbook_clear_cache
actions:
  - action: openplantbook.clean_cache
    data:
      hours: 0

🃏 Lovelace Cards

Two cards: one for searching, one for displaying plant details.

Search Card

type: entities
title: Search OpenPlantbook
entities:
  - entity: input_text.openplantbook_search
  - entity: openplantbook.search_result
  - entity: input_select.openplantbook_searchresults
  - entity: input_button.openplantbook_clear_cache

Plant Info Card

A Markdown card that shows the selected plant's image, species, and thresholds:

type: markdown
title: Plant info
content: |
  {% set plant = "openplantbook." + states('input_select.openplantbook_searchresults') | replace(" ", "_") | replace("'", "") | replace(".", "") %}
  {% if states(plant) == "unknown" %}
  # Search for a plant
  {% else %}
  # {{ state_attr(plant, 'display_pid') }}
  {% set min_dli = ((state_attr(plant, 'min_light_mmol') | float(default=0) * 0.0036)) | round(0, default=0) %}
  {% set max_dli = ((state_attr(plant, 'max_light_mmol') | float(default=0) * 0.0036)) | round(0, default=0) %}

  ![Image]({{ state_attr(plant, 'image_url') | urlencode }})

  _{{ state_attr(plant, 'pid') }}_

  ## Thresholds

  |                      | Min                                       |    | Max                                       |      |
  |----------------------|------------------------------------------:|----|------------------------------------------:|------|
  | Moisture             | {{ state_attr(plant, 'min_soil_moist') }} |    | {{ state_attr(plant, 'max_soil_moist') }} | %     |
  | Conductivity         | {{ state_attr(plant, 'min_soil_ec') }}    |    | {{ state_attr(plant, 'max_soil_ec') }}    | μS/cm |
  | Temperature          | {{ state_attr(plant, 'min_temp') }}       |    | {{ state_attr(plant, 'max_temp') }}       | °C    |
  | Humidity             | {{ state_attr(plant, 'min_env_humid') }}  |    | {{ state_attr(plant, 'max_env_humid') }}  | %     |
  | Illumination         | {{ state_attr(plant, 'min_light_lux') }}  |    | {{ state_attr(plant, 'max_light_lux') }}  | lx    |
  | Daily Light Integral | {{ min_dli }}                             |    | {{ max_dli }}                             | mol/d⋅m² |
  {% endif %}