Forked from Firerouge/low-toner-level-detection-notification-for-all-IPP-printers.yaml
Last active
April 30, 2023 21:01
-
-
Save JohnNeville/eaf431719d50449d4f9c0635664d7c3c to your computer and use it in GitHub Desktop.
Home Assistant Blueprint: Low ink level detection & notification for all IPP printers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Low ink level detection & notification for all IPP printers | |
description: Regularly test all sensors with 'ink' marker_type for crossing | |
a certain ink level threshold and if so execute an action. | |
domain: automation | |
input: | |
threshold: | |
name: Ink warning level threshold | |
description: Ink sensors below threshold are assumed to be low-ink. | |
default: 20 | |
selector: | |
number: | |
min: 5.0 | |
max: 100.0 | |
unit_of_measurement: '%' | |
mode: slider | |
step: 5.0 | |
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 | |
actions: | |
name: Actions | |
description: Notifications or similar to be run. {{sensors}} is replaced with | |
the names of sensors being low on ink. | |
selector: | |
action: {} | |
source_url: https://gist.github.com/JohnNeville/eaf431719d50449d4f9c0635664d7c3c | |
variables: | |
day: !input 'day' | |
threshold: !input 'threshold' | |
sensors: >- | |
{% set result = namespace(sensors=[]) %} | |
{% set inksensors = states.sensor | selectattr('attributes.marker_type', 'defined') | selectattr('attributes.marker_type', '==', 'ink') %} | |
{% for state in inksensors %} | |
{% if 0 <= state.state | int(-1) < threshold %} | |
{% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ ' %)'] %} | |
{% 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment