[sonos] Make night mode time configurable
This commit is contained in:
parent
2c3b7fbb7b
commit
384ef20269
|
@ -5,12 +5,25 @@ automation:
|
|||
entity_id: media_player.den
|
||||
data_template:
|
||||
night_sound: >-
|
||||
{{ now().hour >= 22 }}
|
||||
{% set start = states.input_datetime.sonos_nightmode_start.attributes %}
|
||||
{% set end = states.input_datetime.sonos_nightmode_end.attributes %}
|
||||
{% set now_ = (now().hour, now().minute, now().second) %}
|
||||
{% set start_ = (start.hour, start.minute, start.second) %}
|
||||
{% set end_ = (end.hour, end.minute, end.second) %}
|
||||
{% if start_ > end_ -%}
|
||||
{{ now_ >= start_ or now_ < end_ }}
|
||||
{%- else -%}
|
||||
{{ now_ >= start_ and now_ < end_ }}
|
||||
{%- endif -%}
|
||||
trigger:
|
||||
- platform: time
|
||||
at: '22:30:00'
|
||||
- platform: time
|
||||
at: '08:00:00'
|
||||
- platform: template
|
||||
value_template: "{{ states('sensor.time') == (states.input_datetime.sonos_nightmode_start.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
|
||||
- platform: template
|
||||
value_template: "{{ states('sensor.time') == (states.input_datetime.sonos_nightmode_end.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
|
||||
sensor:
|
||||
- platform: time_date
|
||||
display:
|
||||
- time
|
||||
binary_sensor:
|
||||
- platform: template
|
||||
sensors:
|
||||
|
@ -18,6 +31,17 @@ binary_sensor:
|
|||
friendly_name: Sonos Den Night Mode
|
||||
value_template: >-
|
||||
{{ state_attr('media_player.den', 'night_sound') }}
|
||||
input_datetime:
|
||||
sonos_nightmode_start:
|
||||
name: Start Night Mode
|
||||
has_date: false
|
||||
has_time: true
|
||||
initial: '22:30'
|
||||
sonos_nightmode_end:
|
||||
name: End Night Mode
|
||||
has_date: false
|
||||
has_time: true
|
||||
initial: '08:00'
|
||||
script:
|
||||
sonos_tts:
|
||||
alias: "Sonos TTS"
|
||||
|
@ -59,6 +83,7 @@ group:
|
|||
- binary_sensor.den_night_mode
|
||||
- group.sonos_players
|
||||
- group.sonos_automations
|
||||
- group.sonos_options
|
||||
- group.sonos_scripts
|
||||
sonos_players:
|
||||
name: Sonos
|
||||
|
@ -68,6 +93,11 @@ group:
|
|||
name: Automations
|
||||
entities:
|
||||
- automation.toggle_sonos_night_mode
|
||||
sonos_options:
|
||||
name: Options
|
||||
entities:
|
||||
- input_datetime.sonos_nightmode_start
|
||||
- input_datetime.sonos_nightmode_end
|
||||
sonos_scripts:
|
||||
name: Scripts
|
||||
entities:
|
||||
|
|
Loading…
Reference in New Issue