Let me know if you run into any issues. Also of note, Bluetooth does not seem to work well through glass windows, especially for the Mi Flora sensors. Just keep this in mind if you have your Bluetooth dongle inside (near a window) and plants outside. Good luck!
blueprint:
name: Low moisture level detection & notification for all plant sensors
description: Regularly test all plant sensors with 'moisture' crossing
under their threshold.
domain: automation
input:
time:
name: Time to test on
description: Test is run at configured time
default: '10:00:00'
selector:
time: {}
day:
name: Weekday to test on
description: 'Test is run at configured time either everyday (0) or on a given
weekday (1: Monday ... 7: Sunday)'
default: 0
selector:
number:
min: 0.0
max: 7.0
mode: slider
step: 1.0
exclude:
name: Excluded Sensors
description: Plant sensors (e.g. cactus) to exclude from detection. Only entities are supported, devices must be expanded!
default: {entity_id: []}
selector:
target:
entity:
domain: plant
actions:
name: Actions
description: Notifications or similar to be run. {{sensors}} is replaced with
the names of sensors being low on moisture.
selector:
action: {}
variables:
day: !input 'day'
exclude: !input 'exclude'
sensors: >-
{% set result = namespace(sensors=[]) %}
{% for state in states.plant if 'moisture low' in state.attributes.problem %}
{% if not state.entity_id in exclude.entity_id %}
{% set result.sensors = result.sensors + [state.attributes.friendly_name] %}
{% endif %}
{% endfor %}
{{result.sensors|join(', ')}}
trigger:
- platform: time
at: !input 'time'
condition:
- '{{ sensors != '''' and (day | int == 0 or day | int == now().isoweekday()) }}'
action:
- choose: []
default: !input 'actions'
mode: single
I don’t have friendly names set on my plants, however, I think you would change state.name with state.attributes.friendly_name. I will test this out later on and let you know if it works, if it does, I will update the blueprint.
Edit: It worked. I updated the blueprint, you will have to re-download it.
It seems like state.attributes.friendly_name is same as state.name for plant entities.
Tried this in template editor:
{% set result = namespace( sensors = [] ) %}
{% for state in states.plant if 'moisture low' in state.attributes.problem %}
{% set result.sensors = result.sensors + [state.attributes.friendly_name] %}
{% endfor %}
{{result.sensors|join(', ')}}
But when I try to declare a friendly_name in <config>/plants.yaml config file I get a configuration error.
@cweakland, And is there any chance that you can make the plant sensors template logic into a binary_sensor like below, so that if any plant has moisture low then that state can be used to set the state of binary_sensor to on which in-turn can be used as a trigger in mobile_app or mediaplayer notification automation.
template:
- binary_sensor:
- name: People home
state: >
{{ is_state('device_tracker.sean', 'home')
or is_state('binary_sensor.hallway_134', 'on') }}
I believe it is the built in “plant status” card. Then I went on google, searched for an image I liked, download it, cropped it some, and tied it in via customize.yaml like so:
@cweakland Thank you so much, I am also using the built in plant card but entity_picture is something I didn’t know about before. It made me revisit customizing entities documentation. Thanks again.
sensors: >-
{% set result = namespace(sensors=[]) %}
{% for state in states.plant if 'Low' in state.attributes.moisture_status %}
{% if not state.entity_id in exclude.entity_id %}
{% set result.sensors = result.sensors + [state.attributes.friendly_name] %}
{% endif %}
{% endfor %}
{{result.sensors|join(', ')}}
This always results in the error:
“TypeError: argument of type ‘NoneType’ is not iterable”