78 lines
2.1 KiB
YAML
78 lines
2.1 KiB
YAML
group:
|
|
twitch_channels:
|
|
name: Twitch Channels
|
|
entities:
|
|
- sensor.correlr
|
|
- sensor.onedeadgod
|
|
sensor:
|
|
- platform: twitch
|
|
client_id: !secret twitch_client_id
|
|
channels:
|
|
- correlr
|
|
- onedeadgod
|
|
- wildspice
|
|
- matthewdgroves
|
|
- Vindeflei
|
|
- platform: template
|
|
sensors:
|
|
active_twitch_streams:
|
|
friendly_name: Active Twitch streams
|
|
value_template: >-
|
|
{% if is_state('binary_sensor.twitch_stream_active', 'on') %}
|
|
{{ states
|
|
| selectattr("entity_id", "in",
|
|
states.group.twitch_channels.attributes.entity_id)
|
|
| selectattr('state', 'eq', 'streaming')
|
|
| map(attribute='attributes.friendly_name')
|
|
| join(', ')
|
|
}}
|
|
{% endif %}
|
|
|
|
binary_sensor:
|
|
- platform: template
|
|
sensors:
|
|
twitch_stream_active:
|
|
friendly_name: Twitch stream is active
|
|
value_template: >-
|
|
{{ is_state('sensor.correlr', 'streaming')
|
|
or is_state('sensor.onedeadgod', 'streaming')
|
|
}}
|
|
automation:
|
|
- alias: Turn on Twitch OTA indicator light
|
|
action:
|
|
- service: light.turn_on
|
|
data_template:
|
|
entity_id: light.candle
|
|
transition: 1.0
|
|
color_name: >-
|
|
{% if is_state('sensor.correlr', 'streaming') %}
|
|
purple
|
|
{% else %}
|
|
red
|
|
{% endif %}
|
|
brightness: 255
|
|
- service: light.turn_on
|
|
data_template:
|
|
entity_id: light.candle
|
|
flash: long
|
|
trigger:
|
|
- platform: state
|
|
entity_id: sensor.active_twitch_streams
|
|
condition:
|
|
- condition: state
|
|
entity_id: binary_sensor.twitch_stream_active
|
|
state: 'on'
|
|
- condition: state
|
|
entity_id: binary_sensor.occupied
|
|
state: 'on'
|
|
- alias: Turn off Twitch OTA indicator light
|
|
action:
|
|
- service: light.turn_off
|
|
data:
|
|
entity_id: light.candle
|
|
transition: 1.0
|
|
trigger:
|
|
- platform: state
|
|
entity_id: binary_sensor.twitch_stream_active
|
|
to: 'off'
|