-
-
Save drinfernoo/2583469633bae46e65dd07e1a0c2e382 to your computer and use it in GitHub Desktop.
Home Assistant Local Issue Tracker
This file contains 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
## Comment out or remove the following block if not using the blueprint from: | |
## https://community.home-assistant.io/t/home-issue-tracker-notifications/371744 | |
automation: | |
- id: issue_tracker_notifications | |
alias: Issue Tracker Notifications | |
description: Send a notification whenever an issue is opened or closed from the Issue Tracker. | |
use_blueprint: | |
path: drinfernoo/issue_tracker_notifications.yaml | |
input: | |
notify_group: YOUR_NOTIFICATION_GROUP_HERE | |
counter: | |
issue_number: | |
name: Issue Number | |
initial: 1 | |
minimum: 1 | |
step: 1 | |
icon: mdi:ticket-confirmation | |
input_select: | |
filter_issues: | |
name: Filter Issues | |
options: | |
- All | |
- Open | |
- Closed | |
initial: Open | |
icon: mdi:filter | |
input_text: | |
issue_description: | |
name: Issue Description | |
initial: "" | |
icon: mdi:message-alert | |
script: | |
close_issue: | |
alias: Close Issue | |
description: Close an existing issue. | |
icon: mdi:close-circle-outline | |
fields: | |
issue_number: | |
name: Issue Number | |
description: The issue number to close | |
example: 42 | |
selector: | |
text: | |
user: | |
name: User | |
description: The user that closed this issue | |
example: Arthur Dent | |
default: "" | |
selector: | |
text: | |
variables: | |
issue_num: "{{ int(issue_number) }}" | |
issue: "binary_sensor.issue_{{ issue_num }}" | |
time: "{{ utcnow() }}" | |
sequence: | |
- alias: Close issue | |
service: mqtt.publish | |
data_template: | |
topic: "issue_tracker/{{ issue_num }}" | |
retain: true | |
payload: >- | |
{ | |
"status": "closed", | |
"description": "{{ state_attr(issue, 'description') }}", | |
"time": "{{ as_datetime(time) | as_local }}", | |
"number": "{{ issue_num }}", | |
"user": "{{ user }}" | |
} | |
open_issue: | |
alias: Open Issue | |
description: Open a new issue. | |
icon: mdi:alert-circle-outline | |
fields: | |
issue_number: | |
name: Issue Number | |
description: The issue number to open | |
example: 42 | |
default: "" | |
selector: | |
text: | |
issue_description: | |
name: Issue Description | |
description: Short description of the issue | |
example: Something's broken! | |
default: "" | |
selector: | |
text: | |
user: | |
name: User | |
description: The user that opened this issue | |
example: Arthur Dent | |
default: "" | |
selector: | |
text: | |
variables: | |
issue_num: "{{ issue_number }}" | |
issue_desc: "{{ issue_description }}" | |
time: "{{ utcnow() }}" | |
sequence: | |
- alias: Skip opening empty issues | |
condition: template | |
value_template: "{{ issue_desc != '' }}" | |
- alias: Open issue | |
service: mqtt.publish | |
data_template: | |
topic: "issue_tracker/{{ issue_num }}" | |
retain: true | |
payload: >- | |
{ | |
"status": "open", | |
"description": "{{ issue_desc }}", | |
"time": "{{ as_datetime(time) | as_local }}", | |
"number": "{{ issue_num }}", | |
"user": "{{ user }}" | |
} | |
- alias: Create sensor for issue | |
service: mqtt.publish | |
data_template: | |
topic: "homeassistant/binary_sensor/issue_tracker/{{ issue_num }}/config" | |
retain: true | |
payload: >- | |
{ | |
"name": "Issue #{{ issue_num }}", | |
"unique_id": "issue_{{ time | as_timestamp }}", | |
"state_topic": "issue_tracker/{{ issue_num }}", | |
"json_attributes_topic": "issue_tracker/{{ issue_num }}", | |
"value_template": "{{ '{{ ' + 'value_json.status' + ' }}' }}", | |
"icon": "mdi:bug", | |
"device": { | |
"identifiers": ["issue_tracker"], "name": "Issue Tracker" | |
}, | |
"payload_on": "open", | |
"payload_off": "closed" | |
} | |
- alias: Increment counter | |
service: counter.increment | |
target: | |
entity_id: counter.issue_number | |
- alias: Reset description | |
service: input_text.set_value | |
target: | |
entity_id: input_text.issue_description | |
data: | |
value: "" |
This file contains 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
type: entities | |
title: Issue Tracker | |
entities: | |
- entity: input_text.issue_description | |
name: Description | |
- type: custom:config-template-card | |
entities: | |
- counter.issue_number | |
- input_text.issue_description | |
row: | |
type: button | |
entity: script.open_issue | |
name: ' ' | |
icon: ' ' | |
action_name: Submit | |
tap_action: | |
action: call-service | |
service: script.open_issue | |
service_data: | |
user: ${ user.name } | |
issue_number: ${ states['counter.issue_number'].state } | |
issue_description: ${ states['input_text.issue_description'].state } | |
- type: divider | |
- type: custom:auto-entities | |
card: | |
type: entities | |
show_header_toggle: false | |
show_empty: false | |
entities: | |
- input_select.filter_issues | |
filter: | |
template: > | |
{% if is_state('input_select.filter_issues', 'Open') %} | |
{% set issue_state = ['on'] %} | |
{% elif is_state('input_select.filter_issues', 'Closed') %} | |
{% set issue_state = ['off'] %} | |
{% elif is_state('input_select.filter_issues', 'All') %} | |
{% set issue_state = ['on', 'off'] %} | |
{% endif %} | |
{% set issues = states.binary_sensor | selectattr('entity_id', 'match', | |
'binary_sensor.issue_*') | selectattr('state', 'in', issue_state) | | |
map(attribute='entity_id') | list %} | |
{% set issues = issues | map('regex_replace', '^.+_(\\d+)$', '\\1') | | |
map('int') | sort | map('string') | map('regex_replace', '^(\\d+)$', | |
'binary_sensor.issue_\\1') | list %} | |
[ {% for issue in (issues | reverse) %} | |
{ | |
"type": "custom:config-template-card", | |
"entities": "[{{ issue }}]", | |
"row": { | |
"type": "custom:template-entity-row", | |
"entity": "{{ issue }}", | |
"name": "{{ state_attr(issue, 'description') }}", | |
"active": {{ is_state(issue, 'on') }}, | |
"icon": "{{ "mdi:alert-circle-outline" if is_state(issue, 'on') else "mdi:close-circle-outline" }}", | |
"state": "{{ state_attr(issue, 'user') }}", | |
"secondary": "{{ '#' + state_attr(issue, 'number') + ' - ' + (state_attr(issue, 'status').replace('ed', '') | title) + 'ed on' }} {{ | |
float(state_attr(issue, 'time') | as_timestamp) | | |
timestamp_custom('%m/%d/%y at %-0I:%M %p') }}", | |
"hold_action": {% if is_state(issue, 'on') %} | |
{ | |
"action": "call-service", | |
"service": "script.close_issue", | |
"service_data": { | |
"issue_number": {{ state_attr(issue, "number") }}, | |
"user": "${ user.name }", | |
}, | |
"confirmation": { | |
"text": "Close issue #{{ state_attr(issue, 'number') }}?", | |
} | |
} | |
{% else %} | |
{ | |
"action": "call-service", | |
"service": "script.open_issue", | |
"service_data": { | |
"issue_number": {{ state_attr(issue, "number") }}, | |
"issue_description": "{{ state_attr(issue, "description") }}", | |
"user": "${ user.name }", | |
}, | |
"confirmation": { | |
"text": "Reopen issue #{{ state_attr(issue, 'number') }}?", | |
} | |
} | |
{% endif %} | |
} | |
}, | |
{% endfor %} ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The included card does require:
Example images of the card and notifications here: https://imgur.com/a/XCbRPCH
HA Community topic here: https://community.home-assistant.io/t/home-issue-tracker/371742
Blueprint to use for notifications here: https://community.home-assistant.io/t/home-issue-tracker-notifications/371744