Closes # 1085 - With Trigger IDs.

This commit is contained in:
ccostan 2021-07-26 16:16:49 -04:00
parent d43131c3dd
commit b447aaff9a
7 changed files with 53 additions and 20 deletions

View File

@ -8,6 +8,7 @@
- platform: state - platform: state
entity_id: group.bed entity_id: group.bed
to: 'off' to: 'off'
for: "00:05:00"
condition: condition:
- condition: state - condition: state

View File

@ -51,3 +51,33 @@
- service: homeassistant.turn_off - service: homeassistant.turn_off
entity_id: group.landscaping entity_id: group.landscaping
- alias: 'Bed Presence AMP Trigger'
id: 26846f7b-bc76-43d2-99be-af552d2300f
trigger:
- platform: state
entity_id:
- binary_sensor.sleepnumber_carlo_carlo_is_in_bed
- binary_sensor.sleepnumber_carlo_stacey_is_in_bed
to: 'on'
id: "in_bed"
- platform: state
entity_id:
- binary_sensor.sleepnumber_carlo_carlo_is_in_bed
- binary_sensor.sleepnumber_carlo_stacey_is_in_bed
to: 'off'
id: "out_of_bed"
action:
choose:
- alias: "Some One in Bed"
conditions: " {{ trigger.id == 'in_bed'}} "
sequence:
- service: homeassistant.turn_off
target:
entity_id: switch.lr_amp
default:
- service: homeassistant.turn_on
target:
entity_id: switch.lr_amp

View File

@ -26,11 +26,6 @@ automation:
weekday: weekday:
- wed - wed
action: action:
- service: persistent_notification.create
data:
title: Low Ink
message: "{{ trigger.to_state.attributes.friendly_name }} is at {{ trigger.to_state.state }} "
notification_id: low-battery-alert
- service: script.notify_engine - service: script.notify_engine
data: data:
value1: "{{ trigger.to_state.attributes.friendly_name }} is at {{ trigger.to_state.state }} " value1: "{{ trigger.to_state.attributes.friendly_name }} is at {{ trigger.to_state.state }} "

View File

@ -16,11 +16,11 @@ homeassistant:
customize: customize:
sensor.holiday: sensor.holiday:
icon: mdi:beach icon: mdi:beach
friendly_name: US Holiday friendly_name: US Holiday
sensor.flag: sensor.flag:
icon: mdi:flag icon: mdi:flag
friendly_name: Flag Day friendly_name: Flag Day
@ -153,10 +153,6 @@ automation:
- condition: template - condition: template
value_template: "{{ states.sensor.holiday.state | trim != '' }}" value_template: "{{ states.sensor.holiday.state | trim != '' }}"
action: action:
- service: persistent_notification.create
data:
message: 'Today is {{ states.sensor.holiday.state }}.'
title: '{{ states.sensor.holiday.state }}'
- delay: '0{{ (range(4, 8)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}' - delay: '0{{ (range(4, 8)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}'
- service: script.tweet_engine_image - service: script.tweet_engine_image

View File

@ -50,9 +50,3 @@ automation:
value1: 'Hard Drive Monitor:' value1: 'Hard Drive Monitor:'
value2: "Your harddrive is running out of Space! /dev/root:{{ states.sensor.disk_use_percent.state }}%!" value2: "Your harddrive is running out of Space! /dev/root:{{ states.sensor.disk_use_percent.state }}%!"
who: 'carlo' who: 'carlo'
- service: persistent_notification.create
data:
title: "Hard Drive Monitor:"
message: "Your harddrive is running out of Space! /dev/root:{{ states.sensor.disk_use_percent.state }}%!"
notification_id: "Critical Alert"

View File

@ -39,6 +39,9 @@ class SearchCard extends ct.LitElement {
this.search_text = this.config.search_text || "Type to search..."; this.search_text = this.config.search_text || "Type to search...";
this.actions = BUILTIN_ACTIONS.concat(this.config.actions || []); this.actions = BUILTIN_ACTIONS.concat(this.config.actions || []);
this.included_domains = this.config.included_domains;
this.excluded_domains = this.config.excluded_domains || [];
} }
getCardSize() { getCardSize() {
@ -122,16 +125,22 @@ class SearchCard extends ct.LitElement {
var searchRegex = new RegExp(searchText, 'i'); var searchRegex = new RegExp(searchText, 'i');
for (var entity_id in this.hass.states) { for (var entity_id in this.hass.states) {
if ( if (
(entity_id.search(searchRegex) >= 0) ||
( (
"friendly_name" in this.hass.states[entity_id].attributes && entity_id.search(searchRegex) >= 0 ||
this.hass.states[entity_id].attributes.friendly_name.search(searchRegex) >= 0 this.hass.states[entity_id].attributes.friendly_name?.search(searchRegex) >= 0
)
&&
(
this.included_domains
? this.included_domains.includes(entity_id.split(".")[0])
: !this.excluded_domains.includes(entity_id.split(".")[0])
) )
) { ) {
this.results.push(entity_id); this.results.push(entity_id);
} }
} }
} catch (err) { } catch (err) {
console.warn(err);
} }
this.active_actions = this._getActivatedActions(searchText); this.active_actions = this._getActivatedActions(searchText);
@ -196,3 +205,11 @@ setTimeout(() => {
setConfig() { throw new Error("Can't find card-tools. See https://github.com/thomasloven/lovelace-card-tools");} setConfig() { throw new Error("Can't find card-tools. See https://github.com/thomasloven/lovelace-card-tools");}
}); });
}, 2000); }, 2000);
window.customCards = window.customCards || [];
window.customCards.push({
type: "search-card",
name: "Search Card",
preview: true,
description: "Card to search entities"
});