[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
|
entity_id: media_player.den
|
||||||
data_template:
|
data_template:
|
||||||
night_sound: >-
|
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:
|
trigger:
|
||||||
- platform: time
|
- platform: template
|
||||||
at: '22:30:00'
|
value_template: "{{ states('sensor.time') == (states.input_datetime.sonos_nightmode_start.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
|
||||||
- platform: time
|
- platform: template
|
||||||
at: '08:00:00'
|
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:
|
binary_sensor:
|
||||||
- platform: template
|
- platform: template
|
||||||
sensors:
|
sensors:
|
||||||
|
@ -18,6 +31,17 @@ binary_sensor:
|
||||||
friendly_name: Sonos Den Night Mode
|
friendly_name: Sonos Den Night Mode
|
||||||
value_template: >-
|
value_template: >-
|
||||||
{{ state_attr('media_player.den', 'night_sound') }}
|
{{ 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:
|
script:
|
||||||
sonos_tts:
|
sonos_tts:
|
||||||
alias: "Sonos TTS"
|
alias: "Sonos TTS"
|
||||||
|
@ -59,6 +83,7 @@ group:
|
||||||
- binary_sensor.den_night_mode
|
- binary_sensor.den_night_mode
|
||||||
- group.sonos_players
|
- group.sonos_players
|
||||||
- group.sonos_automations
|
- group.sonos_automations
|
||||||
|
- group.sonos_options
|
||||||
- group.sonos_scripts
|
- group.sonos_scripts
|
||||||
sonos_players:
|
sonos_players:
|
||||||
name: Sonos
|
name: Sonos
|
||||||
|
@ -68,6 +93,11 @@ group:
|
||||||
name: Automations
|
name: Automations
|
||||||
entities:
|
entities:
|
||||||
- automation.toggle_sonos_night_mode
|
- automation.toggle_sonos_night_mode
|
||||||
|
sonos_options:
|
||||||
|
name: Options
|
||||||
|
entities:
|
||||||
|
- input_datetime.sonos_nightmode_start
|
||||||
|
- input_datetime.sonos_nightmode_end
|
||||||
sonos_scripts:
|
sonos_scripts:
|
||||||
name: Scripts
|
name: Scripts
|
||||||
entities:
|
entities:
|
||||||
|
|
Loading…
Reference in New Issue