Compare commits
24 Commits
01bad587b8
...
main
Author | SHA1 | Date | |
---|---|---|---|
a947806618 | |||
439ead1047 | |||
20c86831f1 | |||
61b018270b | |||
911477d381 | |||
1ee475ee4a | |||
cae28341fe | |||
17cfa429ea | |||
791d7d504f | |||
631cdae751 | |||
06321730e0 | |||
5ac8ceacfe | |||
4981cbfa2e | |||
e5ddf02c34 | |||
ebf11021e2 | |||
72ce055810 | |||
8461f43bca | |||
ca599eab7a | |||
fef90d5a78 | |||
1f151a804e | |||
31da165db1 | |||
dd390001ee | |||
7993a9174a | |||
fe40743fd1 |
@@ -1 +1 @@
|
||||
2025.3.1
|
||||
2025.9.0
|
510
automations.yaml
510
automations.yaml
@@ -38,7 +38,7 @@
|
||||
input:
|
||||
person_entity: person.marcus_scholz
|
||||
zone_entity: zone.home
|
||||
notify_device: 6adad2de67b26c864cfcb1a91bd12e48
|
||||
notify_device: 773450cae5e93524731940ad081846d9
|
||||
- id: '1623526683767'
|
||||
alias: Licht bei Sonnenaufgang ausschalten
|
||||
description: ''
|
||||
@@ -69,9 +69,11 @@
|
||||
alias: Gute Nacht!
|
||||
description: Schalte alles (außer Schlafzimmer) aus, sobald das Schlaftracking startet.
|
||||
triggers:
|
||||
- entity_id: input_text.sleep_as_android
|
||||
to: sleep_tracking_started
|
||||
trigger: state
|
||||
- trigger: state
|
||||
entity_id:
|
||||
- event.sleep_as_android_schlaf_tracking
|
||||
attribute: event_type
|
||||
to: started
|
||||
conditions: []
|
||||
actions:
|
||||
- target:
|
||||
@@ -89,23 +91,63 @@
|
||||
- data:
|
||||
message: Gute Nacht!
|
||||
action: notify.mobile_app_le2123
|
||||
- data:
|
||||
media:
|
||||
media_content_id: media-source://tts/tts.piper?message=Gute+Nacht%2C+schlaf+gut.
|
||||
media_content_type: provider
|
||||
metadata:
|
||||
title: Gute Nacht, schlaf gut.
|
||||
thumbnail: https://brands.home-assistant.io/_/tts/logo.png
|
||||
media_class: app
|
||||
children_media_class:
|
||||
navigateIds:
|
||||
- {}
|
||||
- media_content_type: app
|
||||
media_content_id: media-source://tts
|
||||
- media_content_type: provider
|
||||
media_content_id: media-source://tts/tts.piper?message=Gute+Nacht%2C+schlaf+gut.
|
||||
action: media_player.play_media
|
||||
enabled: true
|
||||
target:
|
||||
entity_id: media_player.home_assistant_voice_09c0e7_media_player
|
||||
- data:
|
||||
media:
|
||||
media_content_id: media-source://tts/tts.piper?message=Gute+Nacht%2C+schlaf+gut.
|
||||
media_content_type: provider
|
||||
metadata:
|
||||
title: Gute Nacht, schlaf gut.
|
||||
thumbnail: https://brands.home-assistant.io/_/tts/logo.png
|
||||
media_class: app
|
||||
children_media_class:
|
||||
navigateIds:
|
||||
- {}
|
||||
- media_content_type: app
|
||||
media_content_id: media-source://tts
|
||||
- media_content_type: provider
|
||||
media_content_id: media-source://tts/tts.piper?message=Gute+Nacht%2C+schlaf+gut.
|
||||
action: media_player.play_media
|
||||
enabled: true
|
||||
target:
|
||||
entity_id: media_player.m5stack_atom_echo
|
||||
- target:
|
||||
entity_id: media_player.raspiaudio_muse_luxe
|
||||
data:
|
||||
media_content_id: media-source://tts/tts.piper?message=Gute+Nacht%2C+schlaf+gut.
|
||||
media_content_type: provider
|
||||
metadata:
|
||||
title: Gute Nacht, schlaf gut.
|
||||
thumbnail: https://brands.home-assistant.io/_/tts/logo.png
|
||||
media_class: app
|
||||
children_media_class:
|
||||
navigateIds:
|
||||
- {}
|
||||
- media_content_type: app
|
||||
media_content_id: media-source://tts
|
||||
- media_content_type: provider
|
||||
media:
|
||||
media_content_id: media-source://tts/tts.piper?message=Gute+Nacht%2C+schlaf+gut.
|
||||
media_content_type: provider
|
||||
metadata:
|
||||
title: Gute Nacht, schlaf gut.
|
||||
thumbnail: https://brands.home-assistant.io/_/tts/logo.png
|
||||
media_class: app
|
||||
children_media_class:
|
||||
navigateIds:
|
||||
- {}
|
||||
- media_content_type: app
|
||||
media_content_id: media-source://tts
|
||||
- media_content_type: provider
|
||||
media_content_id: media-source://tts/tts.piper?message=Gute+Nacht%2C+schlaf+gut.
|
||||
action: media_player.play_media
|
||||
enabled: true
|
||||
- target:
|
||||
area_id:
|
||||
- wohnzimmer
|
||||
@@ -124,28 +166,45 @@
|
||||
- id: '1623868115464'
|
||||
alias: 420!
|
||||
description: ''
|
||||
trigger:
|
||||
- platform: time
|
||||
at: '16:20'
|
||||
condition: []
|
||||
action:
|
||||
- service: notify.mobile_app_le2123
|
||||
triggers:
|
||||
- at: '16:20'
|
||||
trigger: time
|
||||
conditions: []
|
||||
actions:
|
||||
- action: notify.mobile_app_apollo
|
||||
data:
|
||||
message: Lodere es, Lustknabe.
|
||||
title: 420!
|
||||
- data:
|
||||
title: 420!
|
||||
message: Lodere es, Lustknabe.
|
||||
- service: tts.speak
|
||||
data:
|
||||
action: notify.mobile_app_le2123
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.raspiaudio_muse_luxe
|
||||
message: 4 20 lodere es, Lustknabe
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
action: tts.speak
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.home_assistant_voice_09c0e7_media_player
|
||||
message: 4 20 lodere es, Lustknabe
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
action: tts.speak
|
||||
- data:
|
||||
qos: 0
|
||||
retain: false
|
||||
topic: awtrix_b8658c/notify
|
||||
topic: awtrix_kitchen/notify
|
||||
payload: '{"text": "420, lodere es, Lustknabe!"}'
|
||||
action: mqtt.publish
|
||||
- data:
|
||||
qos: 0
|
||||
retain: false
|
||||
topic: awtrix_desk/notify
|
||||
payload: '{"text": "420, lodere es, Lustknabe!"}'
|
||||
action: mqtt.publish
|
||||
mode: single
|
||||
- id: '1623911524804'
|
||||
alias: TV Anti-Reflexion (undo)
|
||||
@@ -172,70 +231,91 @@
|
||||
- id: '1623941937228'
|
||||
alias: Licht im Schlafzimmer zur Schlafenszeit einschalten
|
||||
description: Bei Beginn der empfohlenen Schlafenszeit.
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: input_text.sleep_as_android
|
||||
triggers:
|
||||
- trigger: state
|
||||
entity_id:
|
||||
- event.sleep_as_android_benutzerbenachrichtigung
|
||||
attribute: event_type
|
||||
to: time_to_bed_alarm_alert
|
||||
for: 00:05:00
|
||||
condition:
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: person.marcus_scholz
|
||||
state: home
|
||||
action:
|
||||
- service: light.turn_on
|
||||
target:
|
||||
actions:
|
||||
- target:
|
||||
device_id: 68868390eda35e969ec60a13020f2407
|
||||
data: {}
|
||||
- service: tts.speak
|
||||
data:
|
||||
action: light.turn_on
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.raspiaudio_muse_luxe
|
||||
message: Ab ins Bett, Schlafenszeit.
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
action: tts.speak
|
||||
enabled: true
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.home_assistant_voice_09c0e7_media_player_2
|
||||
message: Ab ins Bett, Schlafenszeit.
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
action: tts.speak
|
||||
enabled: true
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.m5stack_atom_echo
|
||||
message: Ab ins Bett, Schlafenszeit.
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
action: tts.speak
|
||||
enabled: true
|
||||
mode: single
|
||||
- id: '1623954512941'
|
||||
alias: Licht im Schlafzimmer zum Aufwachen einschalten
|
||||
description: Nach der Alarmquittierung
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: input_text.sleep_as_android
|
||||
to: alarm_alert_start
|
||||
condition:
|
||||
triggers:
|
||||
- trigger: state
|
||||
entity_id:
|
||||
- event.sleep_as_android_schlaf_tracking
|
||||
attribute: event_type
|
||||
to: stopped
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: person.marcus_scholz
|
||||
state: home
|
||||
action:
|
||||
actions:
|
||||
- delay:
|
||||
hours: 0
|
||||
minutes: 0
|
||||
seconds: 30
|
||||
minutes: 1
|
||||
seconds: 0
|
||||
milliseconds: 0
|
||||
- service: light.turn_on
|
||||
target:
|
||||
- target:
|
||||
device_id: 68868390eda35e969ec60a13020f2407
|
||||
data: {}
|
||||
action: light.turn_on
|
||||
mode: single
|
||||
- id: '1624820688449'
|
||||
alias: 'Anruf: Beim Klingeln grün blinken'
|
||||
description: ''
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: sensor.fritz_box_7490_call_monitor_dem_commander1024_seine_cloud
|
||||
triggers:
|
||||
- entity_id: sensor.fritz_box_7490_call_monitor_dem_commander1024_seine_cloud
|
||||
to: ringing
|
||||
- platform: state
|
||||
entity_id: sensor.le2123_phone_state
|
||||
trigger: state
|
||||
- entity_id:
|
||||
- sensor.le2123_phone_state_2
|
||||
to: ringing
|
||||
- platform: state
|
||||
to: ringing
|
||||
entity_id: sensor.moto_g_100_phone_state
|
||||
condition:
|
||||
trigger: state
|
||||
- to: ringing
|
||||
entity_id:
|
||||
- sensor.xt2125_4_phone_state
|
||||
trigger: state
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: person.marcus_scholz
|
||||
state: home
|
||||
action:
|
||||
- service: light.turn_on
|
||||
data:
|
||||
actions:
|
||||
- data:
|
||||
rgb_color:
|
||||
- 9
|
||||
- 255
|
||||
@@ -244,8 +324,8 @@
|
||||
entity_id:
|
||||
- light.awtrix_desk_indicator_1
|
||||
- light.awtrix_kitchen_indicator_1
|
||||
- service: scene.create
|
||||
data:
|
||||
action: light.turn_on
|
||||
- data:
|
||||
scene_id: wled_last_state
|
||||
snapshot_entities:
|
||||
- light.kuche
|
||||
@@ -254,51 +334,53 @@
|
||||
- select.kuche_color_palette
|
||||
- select.wohnzimmer_vorne_color_palette
|
||||
- select.wohnzimmer_hinten_color_palette
|
||||
- service: scene.turn_on
|
||||
target:
|
||||
action: scene.create
|
||||
- target:
|
||||
entity_id: scene.grun_blinken
|
||||
data: {}
|
||||
action: scene.turn_on
|
||||
- delay:
|
||||
hours: 0
|
||||
minutes: 0
|
||||
seconds: 5
|
||||
milliseconds: 0
|
||||
- service: scene.turn_on
|
||||
target:
|
||||
- target:
|
||||
entity_id: scene.wled_last_state
|
||||
data: {}
|
||||
action: scene.turn_on
|
||||
- delay:
|
||||
hours: 0
|
||||
minutes: 0
|
||||
seconds: 15
|
||||
milliseconds: 0
|
||||
- service: light.turn_off
|
||||
data: {}
|
||||
- data: {}
|
||||
target:
|
||||
entity_id:
|
||||
- light.awtrix_desk_indicator_1
|
||||
- light.awtrix_kitchen_indicator_1
|
||||
action: light.turn_off
|
||||
mode: single
|
||||
- id: '1625481640348'
|
||||
alias: 'Anruf: Beim Telefonieren Musik pausieren'
|
||||
description: ''
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: sensor.fritz_box_7490_call_monitor_telefonbuch
|
||||
triggers:
|
||||
- entity_id: sensor.fritz_box_7490_call_monitor_telefonbuch
|
||||
to: talking
|
||||
- platform: state
|
||||
entity_id: sensor.le2123_phone_state
|
||||
trigger: state
|
||||
- entity_id:
|
||||
- sensor.le2123_phone_state_2
|
||||
to: talking
|
||||
- platform: state
|
||||
entity_id: sensor.moto_g_100_phone_state
|
||||
trigger: state
|
||||
- entity_id:
|
||||
- sensor.xt2125_4_phone_state
|
||||
to: talking
|
||||
condition:
|
||||
trigger: state
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: person.marcus_scholz
|
||||
state: home
|
||||
action:
|
||||
- service: scene.create
|
||||
data:
|
||||
actions:
|
||||
- data:
|
||||
scene_id: media_last_state
|
||||
snapshot_entities:
|
||||
- media_player.wohnzimmer_main
|
||||
@@ -306,24 +388,27 @@
|
||||
- media_player.ccze
|
||||
- media_player.spotify_marcus_scholz
|
||||
- media_player.xboxonex
|
||||
- service: media_player.media_pause
|
||||
target:
|
||||
action: scene.create
|
||||
- target:
|
||||
area_id:
|
||||
- schlafzimmer
|
||||
- wohnzimmer
|
||||
action: media_player.media_pause
|
||||
data: {}
|
||||
- wait_for_trigger:
|
||||
- platform: state
|
||||
entity_id: sensor.j9110_phone_state
|
||||
- entity_id: sensor.j9110_phone_state
|
||||
to: idle
|
||||
from: talking
|
||||
- platform: state
|
||||
entity_id: sensor.fritz_box_7490_call_monitor_telefonbuch
|
||||
trigger: state
|
||||
- entity_id: sensor.fritz_box_7490_call_monitor_telefonbuch
|
||||
to: idle
|
||||
from: talking
|
||||
- service: scene.turn_on
|
||||
target:
|
||||
trigger: state
|
||||
- target:
|
||||
entity_id:
|
||||
- scene.media_last_state
|
||||
action: scene.turn_on
|
||||
data: {}
|
||||
mode: single
|
||||
- id: '1628972104416'
|
||||
alias: Raumduft nach einer Stunde wieder ausschalten
|
||||
@@ -349,25 +434,27 @@
|
||||
- id: '1628972885682'
|
||||
alias: Raumduft zum Aufstehen einschalten
|
||||
description: ''
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: input_text.sleep_as_android
|
||||
to: sleep_tracking_stopped
|
||||
condition:
|
||||
triggers:
|
||||
- trigger: state
|
||||
entity_id:
|
||||
- event.sleep_as_android_schlaf_tracking
|
||||
attribute: event_type
|
||||
to: stopped
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: person.marcus_scholz
|
||||
state: home
|
||||
action:
|
||||
actions:
|
||||
- type: turn_on
|
||||
device_id: 5a08ac4c3b3893b540a9934fa92dccfa
|
||||
entity_id: switch.flur_raumduft
|
||||
domain: switch
|
||||
- service: light.turn_on
|
||||
data: {}
|
||||
- data: {}
|
||||
target:
|
||||
entity_id:
|
||||
- light.awtrix_desk_matrix
|
||||
- light.awtrix_kitchen_matrix
|
||||
- light.awtrix_528bd4_matrix
|
||||
- light.awtrix_b8658c_matrix
|
||||
action: light.turn_on
|
||||
mode: single
|
||||
- id: '1630914505161'
|
||||
alias: Beim Verlassen der Wohnung alles abschalten
|
||||
@@ -456,26 +543,23 @@
|
||||
- id: '1675778284738'
|
||||
alias: Stündliche Zeitansage
|
||||
description: ''
|
||||
trigger:
|
||||
- platform: time_pattern
|
||||
minutes: '0'
|
||||
triggers:
|
||||
- minutes: '0'
|
||||
seconds: '0'
|
||||
hours: '*'
|
||||
condition:
|
||||
trigger: time_pattern
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: person.marcus_scholz
|
||||
state: home
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: input_text.sleep_as_android
|
||||
state: sleep_tracking_stopped
|
||||
- condition: state
|
||||
entity_id: input_text.sleep_as_android
|
||||
state: alarm_alert_dismiss
|
||||
action:
|
||||
- service: tts.speak
|
||||
data:
|
||||
entity_id: event.sleep_as_android_schlaf_tracking
|
||||
attribute: event_type
|
||||
state: stopped
|
||||
actions:
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.raspiaudio_muse_luxe
|
||||
message: '{{message}}
|
||||
@@ -484,14 +568,35 @@
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
enabled: true
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
action: tts.speak
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.home_assistant_voice_09c0e7_media_player
|
||||
message: '{{message}}
|
||||
|
||||
'
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
enabled: true
|
||||
action: tts.speak
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.m5stack_atom_echo
|
||||
message: '{{message}}
|
||||
|
||||
'
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
enabled: true
|
||||
action: tts.speak
|
||||
- data:
|
||||
topic: awtrix_desk/notify
|
||||
payload: '{"text": "{{message}}", "icon": "clockcolor", "duration": 16}'
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
action: mqtt.publish
|
||||
- data:
|
||||
topic: awtrix_kitchen/notify
|
||||
payload: '{"text": "{{message}}", "icon": "clockcolor", "duration": 16}'
|
||||
action: mqtt.publish
|
||||
variables:
|
||||
message: '{% set t = now().hour %} {% set m = ''Morgen'' if t < 12 else ''Nachmittag''
|
||||
if t < 18 else ''Abend'' %} Guten {{m}} Marcus. Draußen sind es {{states(''sensor.aussentemperatur'')}}
|
||||
@@ -515,16 +620,16 @@
|
||||
alias: Fenster schließen, wenn es warm wird
|
||||
description: Tagsüber im Sommer, wenn die Außentemperatur sich der Innentemperatur
|
||||
annähert.
|
||||
trigger:
|
||||
- platform: numeric_state
|
||||
entity_id:
|
||||
triggers:
|
||||
- entity_id:
|
||||
- sensor.aussentemperatur
|
||||
above: sensor.wohnungstemperatur
|
||||
for:
|
||||
hours: 0
|
||||
minutes: 5
|
||||
seconds: 0
|
||||
condition:
|
||||
trigger: numeric_state
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: person.marcus_scholz
|
||||
state: home
|
||||
@@ -534,16 +639,15 @@
|
||||
- condition: sun
|
||||
after: sunrise
|
||||
before: sunset
|
||||
action:
|
||||
- service: notify.mobile_app_le2123
|
||||
data:
|
||||
actions:
|
||||
- data:
|
||||
title: Schlaues lüften
|
||||
message: '{{message}}
|
||||
|
||||
'
|
||||
enabled: true
|
||||
- service: tts.speak
|
||||
data:
|
||||
action: notify.mobile_app_le2123
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.raspiaudio_muse_luxe
|
||||
message: '{{message}}
|
||||
@@ -551,6 +655,7 @@
|
||||
'
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
action: tts.speak
|
||||
variables:
|
||||
message: 'Die Außentemperatur ist mit {{states(''sensor.aussentemperatur'')}}
|
||||
° Celsius {{((states(''sensor.aussentemperatur'')|float)-(states(''sensor.wohnungstemperatur'')|float))
|
||||
@@ -562,40 +667,37 @@
|
||||
- id: '1686327239749'
|
||||
alias: Fenster öffnen wenn es kühler wird
|
||||
description: Im Sommer, wenn die Außentemperatur sich der Innentemperatur annähert.
|
||||
trigger:
|
||||
- platform: numeric_state
|
||||
entity_id:
|
||||
triggers:
|
||||
- entity_id:
|
||||
- sensor.aussentemperatur
|
||||
for:
|
||||
hours: 0
|
||||
minutes: 5
|
||||
seconds: 0
|
||||
below: sensor.wohnungstemperatur
|
||||
condition:
|
||||
trigger: numeric_state
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: person.marcus_scholz
|
||||
state: home
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: input_text.sleep_as_android
|
||||
entity_id: event.sleep_as_android_schlaf_tracking
|
||||
state: sleep_tracking_stopped
|
||||
- condition: state
|
||||
entity_id: input_text.sleep_as_android
|
||||
state: alarm_alert_dismiss
|
||||
attribute: event_type
|
||||
- condition: state
|
||||
entity_id: sensor.season
|
||||
state: summer
|
||||
action:
|
||||
- service: notify.mobile_app_le2123
|
||||
data:
|
||||
actions:
|
||||
- data:
|
||||
title: Schlaues lüften
|
||||
message: '{{message}}
|
||||
|
||||
'
|
||||
enabled: true
|
||||
- service: tts.speak
|
||||
data:
|
||||
action: notify.mobile_app_le2123
|
||||
- data:
|
||||
cache: true
|
||||
media_player_entity_id: media_player.raspiaudio_muse_luxe
|
||||
message: '{{message}}
|
||||
@@ -603,6 +705,7 @@
|
||||
'
|
||||
target:
|
||||
entity_id: tts.piper
|
||||
action: tts.speak
|
||||
mode: single
|
||||
variables:
|
||||
message: 'Die Außentemperatur ist mit {{states(''sensor.aussentemperatur'')}}
|
||||
@@ -670,14 +773,13 @@
|
||||
- id: '1698954553138'
|
||||
alias: 'Awtrix: Jahresfortschirtt'
|
||||
description: Jahresfortschritt in %
|
||||
trigger:
|
||||
- platform: time_pattern
|
||||
hours: '*'
|
||||
triggers:
|
||||
- hours: '*'
|
||||
minutes: 0
|
||||
condition: []
|
||||
action:
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
trigger: time_pattern
|
||||
conditions: []
|
||||
actions:
|
||||
- data:
|
||||
payload: '{# Get current timestamp #} {%- set now = now() -%} {# Start of current
|
||||
year #} {%- set startOfYear = now.replace(year=now.year, month=1, day=1, hour=0,
|
||||
minute=0, second=0, microsecond=0) -%} {# Determine end of current year #}
|
||||
@@ -687,9 +789,24 @@
|
||||
= as_timestamp(now) - as_timestamp(startOfYear) -%} {%- set progress = ( current
|
||||
/ total * 100 ) | round(0, "floor", 0) -%} {# Output #} { "text": "{{ progress
|
||||
}} %", "icon": "y2023"}'
|
||||
topic: awtrix_b8658c/custom/yearprogress
|
||||
topic: awtrix_desk/custom/yearprogress
|
||||
qos: 0
|
||||
retain: false
|
||||
action: mqtt.publish
|
||||
- data:
|
||||
payload: '{# Get current timestamp #} {%- set now = now() -%} {# Start of current
|
||||
year #} {%- set startOfYear = now.replace(year=now.year, month=1, day=1, hour=0,
|
||||
minute=0, second=0, microsecond=0) -%} {# Determine end of current year #}
|
||||
{%- set endOfYear = startOfYear.replace(month=12, day=31, hour=23, minute=59,
|
||||
second=59, microsecond=999999) -%} {# Calculate progress #} {%- set total
|
||||
= as_timestamp(endOfYear) - as_timestamp(startOfYear) -%} {%- set current
|
||||
= as_timestamp(now) - as_timestamp(startOfYear) -%} {%- set progress = ( current
|
||||
/ total * 100 ) | round(0, "floor", 0) -%} {# Output #} { "text": "{{ progress
|
||||
}} %", "icon": "y2023"}'
|
||||
topic: awtrix_kitchen/custom/yearprogress
|
||||
qos: 0
|
||||
retain: false
|
||||
action: mqtt.publish
|
||||
mode: single
|
||||
- id: '1699955800413'
|
||||
alias: 'Awtrix: Laufender Spotify Song'
|
||||
@@ -729,19 +846,19 @@
|
||||
- id: '1699969052661'
|
||||
alias: 'Awtrix: Matrix einschalten'
|
||||
description: ''
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: person.marcus_scholz
|
||||
triggers:
|
||||
- entity_id: person.marcus_scholz
|
||||
to: home
|
||||
from: not_home
|
||||
condition: []
|
||||
action:
|
||||
- service: light.turn_on
|
||||
data: {}
|
||||
trigger: state
|
||||
conditions: []
|
||||
actions:
|
||||
- data: {}
|
||||
target:
|
||||
entity_id:
|
||||
- light.awtrix_desk_matrix
|
||||
- light.awtrix_kitchen_matrix
|
||||
- light.awtrix_b8658c_matrix
|
||||
- light.awtrix_528bd4_matrix
|
||||
action: light.turn_on
|
||||
mode: single
|
||||
- id: '1700482951854'
|
||||
alias: Licht bei Sonnenuntergang einschalten (XMas)
|
||||
@@ -808,44 +925,42 @@
|
||||
controller_device: f3b032ad1f3ccc658a7d4588cc0e5c0c
|
||||
helper_last_controller_event: input_text.styrbar_wohnzimmer_moodlight_letztes_event
|
||||
action_button_up_short:
|
||||
- service: light.turn_on
|
||||
data: {}
|
||||
- data: {}
|
||||
target:
|
||||
device_id:
|
||||
- 4edd9b9df7d1f6f2fe7dcc2e5c0eb968
|
||||
- 6dcbd87b459412144bddc42af3ae8b83
|
||||
action: light.turn_on
|
||||
action_button_down_short:
|
||||
- service: light.turn_off
|
||||
data: {}
|
||||
- data: {}
|
||||
target:
|
||||
device_id:
|
||||
- 6dcbd87b459412144bddc42af3ae8b83
|
||||
- 4edd9b9df7d1f6f2fe7dcc2e5c0eb968
|
||||
action: light.turn_off
|
||||
action_button_left_short:
|
||||
- service: script.wled_random_effect
|
||||
data: {}
|
||||
- data: {}
|
||||
action: script.wled_random_effect
|
||||
action_button_right_short:
|
||||
- service: script.wled_random_palette
|
||||
data: {}
|
||||
- data: {}
|
||||
action: script.wled_random_palette
|
||||
action_button_up_long:
|
||||
- service: light.turn_on
|
||||
metadata: {}
|
||||
data:
|
||||
brightness_pct: 10
|
||||
target:
|
||||
entity_id: light.wohnzimmer_moodlight
|
||||
action_button_down_long: []
|
||||
- action: script.moodlight_orange_plasma
|
||||
data: {}
|
||||
action_button_down_long:
|
||||
- action: script.moodlight_neutral
|
||||
data: {}
|
||||
action_button_down_double:
|
||||
- service: light.turn_off
|
||||
target:
|
||||
- target:
|
||||
device_id: 9f42805af5b7e423023595390342b9ac
|
||||
data: {}
|
||||
action: light.turn_off
|
||||
action_button_up_double:
|
||||
- service: light.turn_on
|
||||
metadata: {}
|
||||
- metadata: {}
|
||||
data: {}
|
||||
target:
|
||||
device_id: 9f42805af5b7e423023595390342b9ac
|
||||
action: light.turn_on
|
||||
button_up_double_press: true
|
||||
button_down_double_press: true
|
||||
- id: '1702588441751'
|
||||
@@ -868,41 +983,41 @@
|
||||
input:
|
||||
remote: bd97db2ae9b0104d50dc6a343315608b
|
||||
double_dot_single_press:
|
||||
- service: light.turn_off
|
||||
target:
|
||||
- target:
|
||||
device_id:
|
||||
- 68868390eda35e969ec60a13020f2407
|
||||
data: {}
|
||||
action: light.turn_off
|
||||
double_dot_double_press:
|
||||
- service: light.turn_off
|
||||
metadata: {}
|
||||
- metadata: {}
|
||||
data: {}
|
||||
target:
|
||||
device_id: 3c86ddd39979139f29645308815c0271
|
||||
action: light.turn_off
|
||||
single_dot_single_press:
|
||||
- service: light.turn_on
|
||||
metadata: {}
|
||||
- metadata: {}
|
||||
data: {}
|
||||
target:
|
||||
device_id: 68868390eda35e969ec60a13020f2407
|
||||
action: light.turn_on
|
||||
single_dot_double_press:
|
||||
- service: light.turn_on
|
||||
metadata: {}
|
||||
- metadata: {}
|
||||
data: {}
|
||||
target:
|
||||
device_id: 3c86ddd39979139f29645308815c0271
|
||||
action: light.turn_on
|
||||
double_dot_long_press:
|
||||
- service: switch.turn_off
|
||||
metadata: {}
|
||||
- metadata: {}
|
||||
data: {}
|
||||
target:
|
||||
device_id: b7c1c80b21406c5608e38aa0c7e7e439
|
||||
action: switch.turn_off
|
||||
single_dot_long_press:
|
||||
- service: switch.turn_on
|
||||
metadata: {}
|
||||
- metadata: {}
|
||||
data: {}
|
||||
target:
|
||||
device_id: b7c1c80b21406c5608e38aa0c7e7e439
|
||||
action: switch.turn_on
|
||||
- id: '1705488817426'
|
||||
alias: Let's Encrypt
|
||||
description: Zertifikat prüfen und verlängern via Addon
|
||||
@@ -1132,3 +1247,34 @@
|
||||
target:
|
||||
entity_id: input_boolean.waschetrockner_aktiv
|
||||
mode: single
|
||||
- id: '1756756139646'
|
||||
alias: Türklingel
|
||||
description: Benachrichtigung über Wohnungs- oder Haustürklingeln
|
||||
triggers:
|
||||
- trigger: mqtt
|
||||
topic: gdoor/bus_rx
|
||||
actions:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ trigger.payload_json.action == ''BUTTON_RING'' and trigger.payload_json.parameters
|
||||
== ''0560'' }}'
|
||||
sequence:
|
||||
- data:
|
||||
data:
|
||||
push:
|
||||
interruption-level: time-sensitive
|
||||
message: Türklingel (außen)
|
||||
action: notify.alle_mobilen_gerate
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ trigger.payload_json.action == ''BUTTON_FLOOR'' and trigger.payload_json.parameters
|
||||
== ''FF6F'' and trigger.payload_json.busdata == ''0110139A59A6FF6FA1CC''}}'
|
||||
sequence:
|
||||
- data:
|
||||
data:
|
||||
push:
|
||||
interruption-level: time-sensitive
|
||||
message: Türklingel (innen)
|
||||
action: notify.alle_mobilen_gerate
|
||||
mode: single
|
||||
|
@@ -1,7 +0,0 @@
|
||||
- sensor:
|
||||
# Raspberry Pi CPU temp
|
||||
name: "CPU Temp"
|
||||
unique_id: '4144237916258'
|
||||
command: "cat /sys/class/thermal/thermal_zone0/temp"
|
||||
unit_of_measurement: "°C"
|
||||
value_template: "{{ value | multiply(0.001) | round(1) }}"
|
@@ -11,15 +11,13 @@ http:
|
||||
tts:
|
||||
- platform: picotts_remote
|
||||
language: "de-DE"
|
||||
- platform: google_translate
|
||||
language: "de"
|
||||
|
||||
# Include modules
|
||||
group: !include groups.yaml
|
||||
automation: !include automations.yaml
|
||||
automation webhooks: !include automations_webhooks.yaml
|
||||
script: !include scripts.yaml
|
||||
scene: !include scenes.yaml
|
||||
notify: !include notify.yaml
|
||||
|
||||
# Enable additional integrations
|
||||
# Enable 'wake_on_lan' intrgration
|
||||
@@ -31,18 +29,17 @@ homeassistant:
|
||||
|
||||
# Additional sensors
|
||||
sensor: !include sensors.yaml
|
||||
command_line: !include commandline.yaml
|
||||
utility_meter: !include utility_meters.yaml
|
||||
|
||||
# MQTT sensors
|
||||
mqtt: !include mqtt.yaml
|
||||
mqtt: !include mqtt.yaml
|
||||
mqtt_statestream: !include mqtt_statestream.yaml
|
||||
|
||||
# Template sensors
|
||||
template: !include template.yaml
|
||||
|
||||
# calendar integration
|
||||
calendar: !include calendars.yaml
|
||||
ics_calendar: !include ics_calendars.yaml
|
||||
|
||||
# DB-recorder configuration
|
||||
recorder: !include recorder.yaml
|
||||
@@ -53,7 +50,7 @@ bluetooth:
|
||||
# Bluetooth Low Energy tracker
|
||||
device_tracker:
|
||||
- platform: bluetooth_le_tracker
|
||||
track_new_devices: true
|
||||
track_new_devices: false
|
||||
|
||||
generic_hygrostat:
|
||||
- name: Badezimmer
|
||||
@@ -74,4 +71,3 @@ generic_hygrostat:
|
||||
away_humidity: 60
|
||||
away_fixed: true
|
||||
sensor_stale_duration: 00:15:00
|
||||
|
||||
|
@@ -4,12 +4,18 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from lhpapi import HochwasserPortalAPI, LHPError
|
||||
from lhpapi import HochwasserPortalAPI, LHPError, get_all_stations
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.selector import (
|
||||
SelectOptionDict,
|
||||
SelectSelector,
|
||||
SelectSelectorConfig,
|
||||
SelectSelectorMode,
|
||||
)
|
||||
|
||||
from .const import CONF_ADD_UNAVAILABLE, CONF_PEGEL_IDENTIFIER, DOMAIN, LOGGER
|
||||
|
||||
@@ -50,12 +56,29 @@ class HochwasserPortalConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return self.async_create_entry(title=f"{api.name}", data=user_input)
|
||||
|
||||
stations_dict = await self.hass.async_add_executor_job(get_all_stations)
|
||||
LOGGER.debug(
|
||||
"%i stations found on Github",
|
||||
len(stations_dict),
|
||||
)
|
||||
stations = [SelectOptionDict(value="---", label="")]
|
||||
stations.extend(
|
||||
SelectOptionDict(value=k, label=f"{v} ({k})")
|
||||
for k, v in stations_dict.items()
|
||||
)
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
errors=errors,
|
||||
data_schema=vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_PEGEL_IDENTIFIER): cv.string,
|
||||
vol.Required(CONF_PEGEL_IDENTIFIER): SelectSelector(
|
||||
SelectSelectorConfig(
|
||||
options=stations,
|
||||
mode=SelectSelectorMode.DROPDOWN,
|
||||
sort=True,
|
||||
custom_value=True,
|
||||
)
|
||||
),
|
||||
vol.Required(CONF_ADD_UNAVAILABLE, default=False): cv.boolean,
|
||||
}
|
||||
),
|
||||
|
@@ -9,6 +9,6 @@
|
||||
"iot_class": "cloud_polling",
|
||||
"issue_tracker": "https://github.com/stephan192/hochwasserportal/issues",
|
||||
"loggers": ["hochwasserportal"],
|
||||
"requirements": ["lhpapi==1.0.3"],
|
||||
"version": "1.0.1"
|
||||
"requirements": ["lhpapi==1.0.5"],
|
||||
"version": "1.0.3"
|
||||
}
|
@@ -4,6 +4,7 @@ import logging
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
import voluptuous as vol
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_EXCLUDE,
|
||||
CONF_INCLUDE,
|
||||
@@ -14,24 +15,35 @@ from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.helpers.issue_registry import (
|
||||
IssueSeverity,
|
||||
async_create_issue,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN, UPGRADE_URL
|
||||
from .const import (
|
||||
CONF_ACCEPT_HEADER,
|
||||
CONF_ADV_CONNECT_OPTS,
|
||||
CONF_CALENDARS,
|
||||
CONF_CONNECTION_TIMEOUT,
|
||||
CONF_DAYS,
|
||||
CONF_DOWNLOAD_INTERVAL,
|
||||
CONF_INCLUDE_ALL_DAY,
|
||||
CONF_OFFSET_HOURS,
|
||||
CONF_PARSER,
|
||||
CONF_REQUIRES_AUTH,
|
||||
CONF_SET_TIMEOUT,
|
||||
CONF_SUMMARY_DEFAULT,
|
||||
CONF_SUMMARY_DEFAULT_DEFAULT,
|
||||
CONF_USER_AGENT,
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
PLATFORMS: list[Platform] = [Platform.CALENDAR]
|
||||
|
||||
CONF_DEVICE_ID = "device_id"
|
||||
CONF_CALENDARS = "calendars"
|
||||
CONF_DAYS = "days"
|
||||
CONF_INCLUDE_ALL_DAY = "include_all_day"
|
||||
CONF_PARSER = "parser"
|
||||
CONF_DOWNLOAD_INTERVAL = "download_interval"
|
||||
CONF_USER_AGENT = "user_agent"
|
||||
CONF_OFFSET_HOURS = "offset_hours"
|
||||
CONF_ACCEPT_HEADER = "accept_header"
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
@@ -81,6 +93,13 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
vol.Optional(
|
||||
CONF_ACCEPT_HEADER, default=""
|
||||
): cv.string,
|
||||
vol.Optional(
|
||||
CONF_CONNECTION_TIMEOUT, default=300
|
||||
): cv.positive_float,
|
||||
vol.Optional(
|
||||
CONF_SUMMARY_DEFAULT,
|
||||
default=CONF_SUMMARY_DEFAULT_DEFAULT,
|
||||
): cv.string,
|
||||
}
|
||||
)
|
||||
]
|
||||
@@ -92,22 +111,150 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
STORAGE_KEY = DOMAIN
|
||||
STORAGE_VERSION_MAJOR = 1
|
||||
STORAGE_VERSION_MINOR = 0
|
||||
|
||||
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up calendars."""
|
||||
_LOGGER.debug("Setting up ics_calendar component")
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
|
||||
if DOMAIN in config and config[DOMAIN]:
|
||||
hass.helpers.discovery.load_platform(
|
||||
PLATFORMS[0], DOMAIN, config[DOMAIN], config
|
||||
_LOGGER.debug("discovery.load_platform called")
|
||||
discovery.load_platform(
|
||||
hass=hass,
|
||||
component=PLATFORMS[0],
|
||||
platform=DOMAIN,
|
||||
discovered=config[DOMAIN],
|
||||
hass_config=config,
|
||||
)
|
||||
else:
|
||||
_LOGGER.error(
|
||||
"No configuration found! If you upgraded from ics_calendar v3.2.0 "
|
||||
"or older, you need to update your configuration! See "
|
||||
"%s for more information.",
|
||||
UPGRADE_URL,
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"deprecated_yaml_configuration",
|
||||
is_fixable=False,
|
||||
issue_domain=DOMAIN,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="YAML_Warning",
|
||||
)
|
||||
_LOGGER.warning(
|
||||
"YAML configuration of ics_calendar is deprecated and will be "
|
||||
"removed in ics_calendar v5.0.0. Your configuration items have "
|
||||
"been imported. Please remove them from your configuration.yaml "
|
||||
"file."
|
||||
)
|
||||
|
||||
config_entry = _async_find_matching_config_entry(hass)
|
||||
if not config_entry:
|
||||
if config[DOMAIN].get("calendars"):
|
||||
for calendar in config[DOMAIN].get("calendars"):
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=dict(calendar),
|
||||
)
|
||||
)
|
||||
return True
|
||||
|
||||
# update entry with any changes
|
||||
if config[DOMAIN].get("calendars"):
|
||||
for calendar in config[DOMAIN].get("calendars"):
|
||||
hass.config_entries.async_update_entry(
|
||||
config_entry, data=dict(calendar)
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@callback
|
||||
def _async_find_matching_config_entry(hass):
|
||||
for entry in hass.config_entries.async_entries(DOMAIN):
|
||||
if entry.source == SOURCE_IMPORT:
|
||||
return entry
|
||||
return None
|
||||
|
||||
|
||||
async def async_migrate_entry(hass, entry: ConfigEntry):
|
||||
"""Migrate old config entry."""
|
||||
# Don't downgrade entries
|
||||
if entry.version > STORAGE_VERSION_MAJOR:
|
||||
return False
|
||||
|
||||
if entry.version == STORAGE_VERSION_MAJOR:
|
||||
new_data = {**entry.data}
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
entry,
|
||||
data=new_data,
|
||||
minor_version=STORAGE_VERSION_MINOR,
|
||||
version=STORAGE_VERSION_MAJOR,
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Implement async_setup_entry."""
|
||||
full_data: dict = add_missing_defaults(entry)
|
||||
hass.config_entries.async_update_entry(entry=entry, data=full_data)
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][entry.entry_id] = full_data
|
||||
await hass.config_entries.async_forward_entry_setups(entry, ["calendar"])
|
||||
return True
|
||||
|
||||
|
||||
def add_missing_defaults(
|
||||
entry: ConfigEntry,
|
||||
) -> dict:
|
||||
"""Initialize missing data."""
|
||||
data = {
|
||||
CONF_NAME: "",
|
||||
CONF_URL: "",
|
||||
CONF_ADV_CONNECT_OPTS: False,
|
||||
CONF_SET_TIMEOUT: False,
|
||||
CONF_REQUIRES_AUTH: False,
|
||||
CONF_INCLUDE_ALL_DAY: False,
|
||||
CONF_REQUIRES_AUTH: False,
|
||||
CONF_USERNAME: "",
|
||||
CONF_PASSWORD: "",
|
||||
CONF_PARSER: "rie",
|
||||
CONF_PREFIX: "",
|
||||
CONF_DAYS: 1,
|
||||
CONF_DOWNLOAD_INTERVAL: 15,
|
||||
CONF_USER_AGENT: "",
|
||||
CONF_EXCLUDE: "",
|
||||
CONF_INCLUDE: "",
|
||||
CONF_OFFSET_HOURS: 0,
|
||||
CONF_ACCEPT_HEADER: "",
|
||||
CONF_CONNECTION_TIMEOUT: 300.0,
|
||||
CONF_SUMMARY_DEFAULT: CONF_SUMMARY_DEFAULT_DEFAULT,
|
||||
}
|
||||
data.update(entry.data)
|
||||
|
||||
if CONF_USERNAME in entry.data or CONF_PASSWORD in entry.data:
|
||||
data[CONF_REQUIRES_AUTH] = True
|
||||
if (
|
||||
CONF_USER_AGENT in entry.data
|
||||
or CONF_ACCEPT_HEADER in entry.data
|
||||
or CONF_CONNECTION_TIMEOUT in entry.data
|
||||
):
|
||||
data[CONF_ADV_CONNECT_OPTS] = True
|
||||
if CONF_CONNECTION_TIMEOUT in entry.data:
|
||||
data[CONF_SET_TIMEOUT] = True
|
||||
|
||||
return data
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload entry."""
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
entry, PLATFORMS
|
||||
)
|
||||
if unload_ok:
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
|
||||
return unload_ok
|
||||
|
@@ -1,7 +1,8 @@
|
||||
"""Support for ICS Calendar."""
|
||||
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
# import homeassistant.helpers.config_validation as cv
|
||||
# import voluptuous as vol
|
||||
@@ -12,6 +13,7 @@ from homeassistant.components.calendar import (
|
||||
extract_offset,
|
||||
is_offset_reached,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_EXCLUDE,
|
||||
CONF_INCLUDE,
|
||||
@@ -24,23 +26,28 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import generate_entity_id
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.httpx_client import get_async_client
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.util.dt import now as hanow
|
||||
|
||||
from . import (
|
||||
from .calendardata import CalendarData
|
||||
from .const import (
|
||||
CONF_ACCEPT_HEADER,
|
||||
CONF_CALENDARS,
|
||||
CONF_CONNECTION_TIMEOUT,
|
||||
CONF_DAYS,
|
||||
CONF_DOWNLOAD_INTERVAL,
|
||||
CONF_INCLUDE_ALL_DAY,
|
||||
CONF_OFFSET_HOURS,
|
||||
CONF_PARSER,
|
||||
CONF_SET_TIMEOUT,
|
||||
CONF_SUMMARY_DEFAULT,
|
||||
CONF_USER_AGENT,
|
||||
DOMAIN,
|
||||
)
|
||||
from .calendardata import CalendarData
|
||||
from .filter import Filter
|
||||
from .icalendarparser import ICalendarParser
|
||||
from .getparser import GetParser
|
||||
from .parserevent import ParserEvent
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -51,6 +58,34 @@ OFFSET = "!!"
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the calendar in background."""
|
||||
hass.async_create_task(
|
||||
_async_setup_entry_bg_task(hass, config_entry, async_add_entities)
|
||||
)
|
||||
|
||||
|
||||
async def _async_setup_entry_bg_task(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the calendar."""
|
||||
data = hass.data[DOMAIN][config_entry.entry_id]
|
||||
device_id = f"{data[CONF_NAME]}"
|
||||
entity = ICSCalendarEntity(
|
||||
hass,
|
||||
generate_entity_id(ENTITY_ID_FORMAT, device_id, hass=hass),
|
||||
hass.data[DOMAIN][config_entry.entry_id],
|
||||
config_entry.entry_id,
|
||||
)
|
||||
async_add_entities([entity])
|
||||
|
||||
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
@@ -70,8 +105,13 @@ def setup_platform(
|
||||
"""
|
||||
_LOGGER.debug("Setting up ics calendars")
|
||||
if discovery_info is not None:
|
||||
calendars: list = discovery_info.get(CONF_CALENDARS)
|
||||
_LOGGER.debug(
|
||||
"setup_platform: ignoring discovery_info, already imported!"
|
||||
)
|
||||
# calendars: list = discovery_info.get(CONF_CALENDARS)
|
||||
calendars = []
|
||||
else:
|
||||
_LOGGER.debug("setup_platform: discovery_info is None")
|
||||
calendars: list = config.get(CONF_CALENDARS)
|
||||
|
||||
calendar_devices = []
|
||||
@@ -91,10 +131,13 @@ def setup_platform(
|
||||
CONF_INCLUDE: calendar.get(CONF_INCLUDE),
|
||||
CONF_OFFSET_HOURS: calendar.get(CONF_OFFSET_HOURS),
|
||||
CONF_ACCEPT_HEADER: calendar.get(CONF_ACCEPT_HEADER),
|
||||
CONF_CONNECTION_TIMEOUT: calendar.get(CONF_CONNECTION_TIMEOUT),
|
||||
}
|
||||
device_id = f"{device_data[CONF_NAME]}"
|
||||
entity_id = generate_entity_id(ENTITY_ID_FORMAT, device_id, hass=hass)
|
||||
calendar_devices.append(ICSCalendarEntity(entity_id, device_data))
|
||||
calendar_devices.append(
|
||||
ICSCalendarEntity(hass, entity_id, device_data)
|
||||
)
|
||||
|
||||
add_entities(calendar_devices)
|
||||
|
||||
@@ -102,7 +145,13 @@ def setup_platform(
|
||||
class ICSCalendarEntity(CalendarEntity):
|
||||
"""A CalendarEntity for an ICS Calendar."""
|
||||
|
||||
def __init__(self, entity_id: str, device_data):
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
entity_id: str,
|
||||
device_data,
|
||||
unique_id: str = None,
|
||||
):
|
||||
"""Construct ICSCalendarEntity.
|
||||
|
||||
:param entity_id: Entity id for the calendar
|
||||
@@ -111,14 +160,16 @@ class ICSCalendarEntity(CalendarEntity):
|
||||
:type device_data: dict
|
||||
"""
|
||||
_LOGGER.debug(
|
||||
"Initializing calendar: %s with URL: %s",
|
||||
"Initializing calendar: %s with URL: %s, uniqueid: %s",
|
||||
device_data[CONF_NAME],
|
||||
device_data[CONF_URL],
|
||||
unique_id,
|
||||
)
|
||||
self.data = ICSCalendarData(device_data)
|
||||
self.data = ICSCalendarData(hass, device_data)
|
||||
self.entity_id = entity_id
|
||||
self._attr_unique_id = f"ICSCalendar.{unique_id}"
|
||||
self._event = None
|
||||
self._name = device_data[CONF_NAME]
|
||||
self._attr_name = device_data[CONF_NAME]
|
||||
self._last_call = None
|
||||
|
||||
@property
|
||||
@@ -131,12 +182,7 @@ class ICSCalendarEntity(CalendarEntity):
|
||||
return self._event
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the calendar."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
def should_poll(self) -> bool:
|
||||
"""Indicate if the calendar should be polled.
|
||||
|
||||
If the last call to update or get_api_events was not within the minimum
|
||||
@@ -168,25 +214,50 @@ class ICSCalendarEntity(CalendarEntity):
|
||||
_LOGGER.debug(
|
||||
"%s: async_get_events called; calling internal.", self.name
|
||||
)
|
||||
return await self.data.async_get_events(hass, start_date, end_date)
|
||||
return await self.data.async_get_events(start_date, end_date)
|
||||
|
||||
def update(self):
|
||||
async def async_update(self):
|
||||
"""Get the current or next event."""
|
||||
self.data.update()
|
||||
self._event = self.data.event
|
||||
await self.data.async_update()
|
||||
self._event: CalendarEvent | None = self.data.event
|
||||
self._attr_extra_state_attributes = {
|
||||
"offset_reached": is_offset_reached(
|
||||
self._event.start_datetime_local, self.data.offset
|
||||
"offset_reached": (
|
||||
is_offset_reached(
|
||||
self._event.start_datetime_local, self.data.offset
|
||||
)
|
||||
if self._event
|
||||
else False
|
||||
)
|
||||
if self._event
|
||||
else False
|
||||
}
|
||||
|
||||
async def async_create_event(self, **kwargs: Any):
|
||||
"""Raise error, this is a read-only calendar."""
|
||||
raise NotImplementedError()
|
||||
|
||||
async def async_delete_event(
|
||||
self,
|
||||
uid: str,
|
||||
recurrence_id: str | None = None,
|
||||
recurrence_range: str | None = None,
|
||||
) -> None:
|
||||
"""Raise error, this is a read-only calendar."""
|
||||
raise NotImplementedError()
|
||||
|
||||
async def async_update_event(
|
||||
self,
|
||||
uid: str,
|
||||
event: dict[str, Any],
|
||||
recurrence_id: str | None = None,
|
||||
recurrence_range: str | None = None,
|
||||
) -> None:
|
||||
"""Raise error, this is a read-only calendar."""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class ICSCalendarData: # pylint: disable=R0902
|
||||
"""Class to use the calendar ICS client object to get next event."""
|
||||
|
||||
def __init__(self, device_data):
|
||||
def __init__(self, hass: HomeAssistant, device_data):
|
||||
"""Set up how we are going to connect to the URL.
|
||||
|
||||
:param device_data Information about the calendar
|
||||
@@ -196,18 +267,25 @@ class ICSCalendarData: # pylint: disable=R0902
|
||||
self._offset_hours = device_data[CONF_OFFSET_HOURS]
|
||||
self.include_all_day = device_data[CONF_INCLUDE_ALL_DAY]
|
||||
self._summary_prefix: str = device_data[CONF_PREFIX]
|
||||
self.parser = ICalendarParser.get_instance(device_data[CONF_PARSER])
|
||||
self._summary_default: str = device_data[CONF_SUMMARY_DEFAULT]
|
||||
self.parser = GetParser.get_parser(device_data[CONF_PARSER])
|
||||
self.parser.set_filter(
|
||||
Filter(device_data[CONF_EXCLUDE], device_data[CONF_INCLUDE])
|
||||
)
|
||||
self.offset = None
|
||||
self.event = None
|
||||
self._hass = hass
|
||||
|
||||
self._calendar_data = CalendarData(
|
||||
get_async_client(hass),
|
||||
_LOGGER,
|
||||
self.name,
|
||||
device_data[CONF_URL],
|
||||
timedelta(minutes=device_data[CONF_DOWNLOAD_INTERVAL]),
|
||||
{
|
||||
"name": self.name,
|
||||
"url": device_data[CONF_URL],
|
||||
"min_update_time": timedelta(
|
||||
minutes=device_data[CONF_DOWNLOAD_INTERVAL]
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
self._calendar_data.set_headers(
|
||||
@@ -217,22 +295,23 @@ class ICSCalendarData: # pylint: disable=R0902
|
||||
device_data[CONF_ACCEPT_HEADER],
|
||||
)
|
||||
|
||||
if device_data.get(CONF_SET_TIMEOUT):
|
||||
self._calendar_data.set_timeout(
|
||||
device_data[CONF_CONNECTION_TIMEOUT]
|
||||
)
|
||||
|
||||
async def async_get_events(
|
||||
self, hass: HomeAssistant, start_date: datetime, end_date: datetime
|
||||
self, start_date: datetime, end_date: datetime
|
||||
) -> list[CalendarEvent]:
|
||||
"""Get all events in a specific time frame.
|
||||
|
||||
:param hass: Home Assistant object
|
||||
:type hass: HomeAssistant
|
||||
:param start_date: The first starting date to consider
|
||||
:type start_date: datetime
|
||||
:param end_date: The last starting date to consider
|
||||
:type end_date: datetime
|
||||
"""
|
||||
event_list = []
|
||||
if await hass.async_add_executor_job(
|
||||
self._calendar_data.download_calendar
|
||||
):
|
||||
event_list: list[ParserEvent] = []
|
||||
if await self._calendar_data.download_calendar():
|
||||
_LOGGER.debug("%s: Setting calendar content", self.name)
|
||||
self.parser.set_content(self._calendar_data.get())
|
||||
try:
|
||||
@@ -248,22 +327,27 @@ class ICSCalendarData: # pylint: disable=R0902
|
||||
self.name,
|
||||
exc_info=True,
|
||||
)
|
||||
event_list = []
|
||||
event_list: list[ParserEvent] = []
|
||||
|
||||
for event in event_list:
|
||||
event.summary = self._summary_prefix + event.summary
|
||||
if not event.summary:
|
||||
event.summary = self._summary_default
|
||||
# Since we skipped the validation code earlier, invoke it now,
|
||||
# before passing the object outside this component
|
||||
event.validate()
|
||||
|
||||
return event_list
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
async def async_update(self):
|
||||
"""Get the current or next event."""
|
||||
_LOGGER.debug("%s: Update was called", self.name)
|
||||
if self._calendar_data.download_calendar():
|
||||
parser_event: ParserEvent | None = None
|
||||
if await self._calendar_data.download_calendar():
|
||||
_LOGGER.debug("%s: Setting calendar content", self.name)
|
||||
self.parser.set_content(self._calendar_data.get())
|
||||
try:
|
||||
self.event = self.parser.get_current_event(
|
||||
parser_event: ParserEvent | None = self.parser.get_current_event(
|
||||
include_all_day=self.include_all_day,
|
||||
now=hanow(),
|
||||
days=self._days,
|
||||
@@ -273,18 +357,24 @@ class ICSCalendarData: # pylint: disable=R0902
|
||||
_LOGGER.error(
|
||||
"update: %s: Failed to parse ICS!", self.name, exc_info=True
|
||||
)
|
||||
if self.event is not None:
|
||||
if parser_event is not None:
|
||||
_LOGGER.debug(
|
||||
"%s: got event: %s; start: %s; end: %s; all_day: %s",
|
||||
self.name,
|
||||
self.event.summary,
|
||||
self.event.start,
|
||||
self.event.end,
|
||||
self.event.all_day,
|
||||
parser_event.summary,
|
||||
parser_event.start,
|
||||
parser_event.end,
|
||||
parser_event.all_day,
|
||||
)
|
||||
(summary, offset) = extract_offset(self.event.summary, OFFSET)
|
||||
self.event.summary = self._summary_prefix + summary
|
||||
(summary, offset) = extract_offset(parser_event.summary, OFFSET)
|
||||
parser_event.summary = self._summary_prefix + summary
|
||||
if not parser_event.summary:
|
||||
parser_event.summary = self._summary_default
|
||||
self.offset = offset
|
||||
# Invoke validation here, since it was skipped when creating the
|
||||
# ParserEvent
|
||||
parser_event.validate()
|
||||
self.event: CalendarEvent = parser_event
|
||||
return True
|
||||
|
||||
_LOGGER.debug("%s: No event found!", self.name)
|
||||
|
@@ -1,23 +1,25 @@
|
||||
"""Provide CalendarData class."""
|
||||
import zlib
|
||||
from datetime import timedelta
|
||||
from gzip import BadGzipFile, GzipFile
|
||||
from logging import Logger
|
||||
from threading import Lock
|
||||
from urllib.error import ContentTooShortError, HTTPError, URLError
|
||||
from urllib.request import (
|
||||
HTTPBasicAuthHandler,
|
||||
HTTPDigestAuthHandler,
|
||||
HTTPPasswordMgrWithDefaultRealm,
|
||||
build_opener,
|
||||
install_opener,
|
||||
urlopen,
|
||||
)
|
||||
|
||||
import re
|
||||
from logging import Logger
|
||||
from math import floor
|
||||
|
||||
import httpx
|
||||
import httpx_auth
|
||||
from homeassistant.util.dt import now as hanow
|
||||
|
||||
# from urllib.error import ContentTooShortError, HTTPError, URLError
|
||||
|
||||
class CalendarData:
|
||||
|
||||
class DigestWithMultiAuth(httpx.DigestAuth, httpx_auth.SupportMultiAuth):
|
||||
"""Describes a DigestAuth authentication."""
|
||||
|
||||
def __init__(self, username: str, password: str):
|
||||
"""Construct Digest authentication that supports Multi Auth."""
|
||||
httpx.DigestAuth.__init__(self, username, password)
|
||||
|
||||
|
||||
class CalendarData: # pylint: disable=R0902
|
||||
"""CalendarData class.
|
||||
|
||||
The CalendarData class is used to download and cache calendar data from a
|
||||
@@ -25,32 +27,33 @@ class CalendarData:
|
||||
instance.
|
||||
"""
|
||||
|
||||
opener_lock = Lock()
|
||||
|
||||
def __init__(
|
||||
self, logger: Logger, name: str, url: str, min_update_time: timedelta
|
||||
self,
|
||||
async_client: httpx.AsyncClient,
|
||||
logger: Logger,
|
||||
conf: dict,
|
||||
):
|
||||
"""Construct CalendarData object.
|
||||
|
||||
:param async_client: An httpx.AsyncClient object for requests
|
||||
:type httpx.AsyncClient
|
||||
:param logger: The logger for reporting problems
|
||||
:type logger: Logger
|
||||
:param name: The name of the calendar (used for reporting problems)
|
||||
:type name: str
|
||||
:param url: The URL of the calendar
|
||||
:type url: str
|
||||
:param min_update_time: The minimum time between downloading data from
|
||||
the URL when requested
|
||||
:type min_update_time: timedelta
|
||||
:param conf: Configuration options
|
||||
:type conf: dict
|
||||
"""
|
||||
self._auth = None
|
||||
self._calendar_data = None
|
||||
self._headers = []
|
||||
self._last_download = None
|
||||
self._min_update_time = min_update_time
|
||||
self._opener = None
|
||||
self._min_update_time = conf["min_update_time"]
|
||||
self.logger = logger
|
||||
self.name = name
|
||||
self.url = url
|
||||
self.name = conf["name"]
|
||||
self.url = conf["url"]
|
||||
self.connection_timeout = None
|
||||
self._httpx = async_client
|
||||
|
||||
def download_calendar(self) -> bool:
|
||||
async def download_calendar(self) -> bool:
|
||||
"""Download the calendar data.
|
||||
|
||||
This only downloads data if self.min_update_time has passed since the
|
||||
@@ -59,20 +62,25 @@ class CalendarData:
|
||||
returns: True if data was downloaded, otherwise False.
|
||||
rtype: bool
|
||||
"""
|
||||
now = hanow()
|
||||
self.logger.debug("%s: download_calendar start", self.name)
|
||||
if (
|
||||
self._calendar_data is None
|
||||
or self._last_download is None
|
||||
or (now - self._last_download) > self._min_update_time
|
||||
or (hanow() - self._last_download) > self._min_update_time
|
||||
):
|
||||
self._last_download = now
|
||||
self._calendar_data = None
|
||||
next_url: str = self._make_url()
|
||||
self.logger.debug(
|
||||
"%s: Downloading calendar data from: %s", self.name, self.url
|
||||
"%s: Downloading calendar data from: %s",
|
||||
self.name,
|
||||
next_url,
|
||||
)
|
||||
self._download_data()
|
||||
await self._download_data(next_url)
|
||||
self._last_download = hanow()
|
||||
self.logger.debug("%s: download_calendar done", self.name)
|
||||
return self._calendar_data is not None
|
||||
|
||||
self.logger.debug("%s: download_calendar skipped download", self.name)
|
||||
return False
|
||||
|
||||
def get(self) -> str:
|
||||
@@ -92,10 +100,8 @@ class CalendarData:
|
||||
):
|
||||
"""Set a user agent, accept header, and/or user name and password.
|
||||
|
||||
The user name and password will be set into an HTTPBasicAuthHandler an
|
||||
an HTTPDigestAuthHandler. Both are attached to a new urlopener, so
|
||||
that HTTP Basic Auth and HTTP Digest Auth will be supported when
|
||||
opening the URL.
|
||||
The user name and password will be set into an auth object that
|
||||
supports both Basic Auth and Digest Auth for httpx.
|
||||
|
||||
If the user_agent parameter is not "", a User-agent header will be
|
||||
added to the urlopener.
|
||||
@@ -110,81 +116,63 @@ class CalendarData:
|
||||
:type accept_header: str
|
||||
"""
|
||||
if user_name != "" and password != "":
|
||||
passman = HTTPPasswordMgrWithDefaultRealm()
|
||||
passman.add_password(None, self.url, user_name, password)
|
||||
basic_auth_handler = HTTPBasicAuthHandler(passman)
|
||||
digest_auth_handler = HTTPDigestAuthHandler(passman)
|
||||
self._opener = build_opener(
|
||||
digest_auth_handler, basic_auth_handler
|
||||
)
|
||||
self._auth = httpx_auth.Basic(
|
||||
user_name, password
|
||||
) + DigestWithMultiAuth(user_name, password)
|
||||
|
||||
additional_headers = []
|
||||
if user_agent != "":
|
||||
additional_headers.append(("User-agent", user_agent))
|
||||
self._headers.append(("User-agent", user_agent))
|
||||
if accept_header != "":
|
||||
additional_headers.append(("Accept", accept_header))
|
||||
if len(additional_headers) > 0:
|
||||
if self._opener is None:
|
||||
self._opener = build_opener()
|
||||
self._opener.addheaders = additional_headers
|
||||
self._headers.append(("Accept", accept_header))
|
||||
|
||||
def _decode_data(self, conn):
|
||||
if (
|
||||
"Content-Encoding" in conn.headers
|
||||
and conn.headers["Content-Encoding"] == "gzip"
|
||||
):
|
||||
reader = GzipFile(fileobj=conn)
|
||||
else:
|
||||
reader = conn
|
||||
try:
|
||||
return self._decode_stream(reader.read()).replace("\0", "")
|
||||
except zlib.error:
|
||||
self.logger.error(
|
||||
"%s: Failed to uncompress gzip data from url(%s): zlib",
|
||||
self.name,
|
||||
self.url,
|
||||
)
|
||||
except BadGzipFile as gzip_error:
|
||||
self.logger.error(
|
||||
"%s: Failed to uncompress gzip data from url(%s): %s",
|
||||
self.name,
|
||||
self.url,
|
||||
gzip_error.strerror,
|
||||
)
|
||||
return None
|
||||
def set_timeout(self, connection_timeout: float):
|
||||
"""Set the connection timeout.
|
||||
|
||||
def _decode_stream(self, strm):
|
||||
for encoding in "utf-8-sig", "utf-8", "utf-16":
|
||||
try:
|
||||
return strm.decode(encoding)
|
||||
except UnicodeDecodeError:
|
||||
continue
|
||||
return None
|
||||
:param connection_timeout: The timeout value in seconds.
|
||||
:type connection_timeout: float
|
||||
"""
|
||||
self.connection_timeout = connection_timeout
|
||||
|
||||
def _download_data(self):
|
||||
def _decode_data(self, data):
|
||||
return data.replace("\0", "")
|
||||
|
||||
async def _download_data(self, url): # noqa: C901
|
||||
"""Download the calendar data."""
|
||||
self.logger.debug("%s: _download_data start", self.name)
|
||||
try:
|
||||
with CalendarData.opener_lock:
|
||||
if self._opener is not None:
|
||||
install_opener(self._opener)
|
||||
with urlopen(self._make_url()) as conn:
|
||||
self._calendar_data = self._decode_data(conn)
|
||||
except HTTPError as http_error:
|
||||
response = await self._httpx.get(
|
||||
url,
|
||||
auth=self._auth,
|
||||
headers=self._headers,
|
||||
follow_redirects=True,
|
||||
timeout=self.connection_timeout,
|
||||
)
|
||||
if response.status_code >= 400:
|
||||
raise httpx.HTTPStatusError(
|
||||
"status error", request=None, response=response
|
||||
)
|
||||
self._calendar_data = self._decode_data(response.text)
|
||||
self.logger.debug("%s: _download_data done", self.name)
|
||||
except httpx.HTTPStatusError as http_status_error:
|
||||
self.logger.error(
|
||||
"%s: Failed to open url(%s): %s",
|
||||
self.name,
|
||||
self.url,
|
||||
http_error.reason,
|
||||
http_status_error.response.status_code,
|
||||
)
|
||||
except ContentTooShortError as content_too_short_error:
|
||||
except httpx.TimeoutException:
|
||||
self.logger.error(
|
||||
"%s: Could not download calendar data: %s",
|
||||
self.name,
|
||||
content_too_short_error.reason,
|
||||
"%s: Timeout opening url: %s", self.name, self.url
|
||||
)
|
||||
except URLError as url_error:
|
||||
except httpx.DecodingError:
|
||||
self.logger.error(
|
||||
"%s: Failed to open url: %s", self.name, url_error.reason
|
||||
"%s: Error decoding data from url: %s", self.name, self.url
|
||||
)
|
||||
except httpx.InvalidURL:
|
||||
self.logger.error("%s: Invalid URL: %s", self.name, self.url)
|
||||
except httpx.HTTPError:
|
||||
self.logger.error(
|
||||
"%s: Error decoding data from url: %s", self.name, self.url
|
||||
)
|
||||
except: # pylint: disable=W0702
|
||||
self.logger.error(
|
||||
@@ -192,7 +180,45 @@ class CalendarData:
|
||||
)
|
||||
|
||||
def _make_url(self):
|
||||
"""Replace templates in url and encode."""
|
||||
now = hanow()
|
||||
return self.url.replace("{year}", f"{now.year:04}").replace(
|
||||
"{month}", f"{now.month:02}"
|
||||
year: int = now.year
|
||||
month: int = now.month
|
||||
url = self.url
|
||||
(month, year, url) = self._get_month_year(url, month, year)
|
||||
return url.replace("{year}", f"{year:04}").replace(
|
||||
"{month}", f"{month:02}"
|
||||
)
|
||||
|
||||
def _get_year_as_months(self, url: str, month: int) -> int:
|
||||
year_match = re.search("\\{year([-+])([0-9]+)\\}", url)
|
||||
if year_match:
|
||||
if year_match.group(1) == "-":
|
||||
month = month - (int(year_match.group(2)) * 12)
|
||||
else:
|
||||
month = month + (int(year_match.group(2)) * 12)
|
||||
url = url.replace(year_match.group(0), "{year}")
|
||||
return (month, url)
|
||||
|
||||
def _get_month_year(self, url: str, month: int, year: int) -> int:
|
||||
(month, url) = self._get_year_as_months(url, month)
|
||||
print(f"month: {month}\n")
|
||||
month_match = re.search("\\{month([-+])([0-9]+)\\}", url)
|
||||
if month_match:
|
||||
if month_match.group(1) == "-":
|
||||
month = month - int(month_match.group(2))
|
||||
else:
|
||||
month = month + int(month_match.group(2))
|
||||
if month < 1:
|
||||
year -= floor(abs(month) / 12) + 1
|
||||
month = month % 12
|
||||
if month == 0:
|
||||
month = 12
|
||||
elif month > 12:
|
||||
year += abs(floor(month / 12))
|
||||
month = month % 12
|
||||
if month == 0:
|
||||
month = 12
|
||||
year -= 1
|
||||
url = url.replace(month_match.group(0), "{month}")
|
||||
return (month, year, url)
|
||||
|
330
custom_components/ics_calendar/config_flow.py
Normal file
330
custom_components/ics_calendar/config_flow.py
Normal file
@@ -0,0 +1,330 @@
|
||||
"""Config Flow for ICS Calendar."""
|
||||
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Dict, Optional, Self
|
||||
from urllib.parse import quote
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
import voluptuous as vol
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_EXCLUDE,
|
||||
CONF_INCLUDE,
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_PREFIX,
|
||||
CONF_URL,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.helpers.selector import selector
|
||||
|
||||
from . import (
|
||||
CONF_ACCEPT_HEADER,
|
||||
CONF_ADV_CONNECT_OPTS,
|
||||
CONF_CONNECTION_TIMEOUT,
|
||||
CONF_DAYS,
|
||||
CONF_DOWNLOAD_INTERVAL,
|
||||
CONF_INCLUDE_ALL_DAY,
|
||||
CONF_OFFSET_HOURS,
|
||||
CONF_PARSER,
|
||||
CONF_REQUIRES_AUTH,
|
||||
CONF_SET_TIMEOUT,
|
||||
CONF_SUMMARY_DEFAULT,
|
||||
CONF_USER_AGENT,
|
||||
)
|
||||
from .const import CONF_SUMMARY_DEFAULT_DEFAULT, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CALENDAR_NAME_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_NAME): cv.string,
|
||||
vol.Optional(CONF_DAYS, default=1): cv.positive_int,
|
||||
vol.Optional(CONF_INCLUDE_ALL_DAY, default=False): cv.boolean,
|
||||
}
|
||||
)
|
||||
|
||||
CALENDAR_OPTS_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_EXCLUDE, default=""): cv.string,
|
||||
vol.Optional(CONF_INCLUDE, default=""): cv.string,
|
||||
vol.Optional(CONF_PREFIX, default=""): cv.string,
|
||||
vol.Optional(CONF_DOWNLOAD_INTERVAL, default=15): cv.positive_int,
|
||||
vol.Optional(CONF_OFFSET_HOURS, default=0): int,
|
||||
vol.Optional(CONF_PARSER, default="rie"): selector(
|
||||
{"select": {"options": ["rie", "ics"], "mode": "dropdown"}}
|
||||
),
|
||||
vol.Optional(
|
||||
CONF_SUMMARY_DEFAULT, default=CONF_SUMMARY_DEFAULT_DEFAULT
|
||||
): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
CONNECT_OPTS_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_URL): cv.string,
|
||||
vol.Optional(CONF_REQUIRES_AUTH, default=False): cv.boolean,
|
||||
vol.Optional(CONF_ADV_CONNECT_OPTS, default=False): cv.boolean,
|
||||
}
|
||||
)
|
||||
|
||||
AUTH_OPTS_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_USERNAME, default=""): cv.string,
|
||||
vol.Optional(CONF_PASSWORD, default=""): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
ADVANCED_CONNECT_OPTS_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_ACCEPT_HEADER, default=""): cv.string,
|
||||
vol.Optional(CONF_USER_AGENT, default=""): cv.string,
|
||||
vol.Optional(CONF_SET_TIMEOUT, default=False): cv.boolean,
|
||||
}
|
||||
)
|
||||
|
||||
TIMEOUT_OPTS_SCHEMA = vol.Schema(
|
||||
{vol.Optional(CONF_CONNECTION_TIMEOUT, default=None): cv.positive_float}
|
||||
)
|
||||
|
||||
|
||||
def is_array_string(arr_str: str) -> bool:
|
||||
"""Return true if arr_str starts with [ and ends with ]."""
|
||||
return arr_str.startswith("[") and arr_str.endswith("]")
|
||||
|
||||
|
||||
def format_url(url: str) -> str:
|
||||
"""Format a URL using quote() and ensure any templates are not quoted."""
|
||||
is_quoted = bool(re.search("%[0-9A-Fa-f][0-9A-Fa-f]", url))
|
||||
if not is_quoted:
|
||||
year_match = re.search("\\{(year([-+][0-9]+)?)\\}", url)
|
||||
month_match = re.search("\\{(month([-+][0-9]+)?)\\}", url)
|
||||
has_template: bool = year_match or month_match
|
||||
url = quote(url, safe=":/?&=")
|
||||
if has_template:
|
||||
year_template = year_match.group(1)
|
||||
month_template = month_match.group(1)
|
||||
year_template1 = year_template.replace("+", "%2[Bb]")
|
||||
month_template1 = month_template.replace("+", "%2[Bb]")
|
||||
url = re.sub(
|
||||
f"%7[Bb]{year_template1}%7[Dd]",
|
||||
f"{{{year_template}}}",
|
||||
url,
|
||||
)
|
||||
url = re.sub(
|
||||
f"%7[Bb]{month_template1}%7[Dd]",
|
||||
f"{{{month_template}}}",
|
||||
url,
|
||||
)
|
||||
if url.startswith("webcal://"):
|
||||
url = re.sub("^webcal://", "https://", url)
|
||||
|
||||
return url
|
||||
|
||||
|
||||
class ICSCalendarConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Config Flow for ICS Calendar."""
|
||||
|
||||
VERSION = 1
|
||||
MINOR_VERSION = 0
|
||||
|
||||
data: Optional[Dict[str, Any]]
|
||||
|
||||
def __init__(self):
|
||||
"""Construct ICSCalendarConfigFlow."""
|
||||
self.data = {}
|
||||
|
||||
def is_matching(self, _other_flow: Self) -> bool:
|
||||
"""Match discovery method.
|
||||
|
||||
This method doesn't do anything, because this integration has no
|
||||
discoverable components.
|
||||
"""
|
||||
return False
|
||||
|
||||
async def async_step_reauth(self, user_input=None):
|
||||
"""Re-authenticateon auth error."""
|
||||
# self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
# self.context["entry_id"]
|
||||
# )
|
||||
return await self.async_step_reauth_confirm(user_input)
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input=None
|
||||
) -> ConfigFlowResult:
|
||||
"""Dialog to inform user that reauthentication is required."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
step_id="reauth_confirm", data_schema=vol.Schema({})
|
||||
)
|
||||
return await self.async_step_user()
|
||||
|
||||
# Don't allow reconfigure for now!
|
||||
# async def async_step_reconfigure(
|
||||
# self, user_input: dict[str, Any] | None = None
|
||||
# ) -> ConfigFlowResult:
|
||||
# """Reconfigure entry."""
|
||||
# return await self.async_step_user(user_input)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: Optional[Dict[str, Any]] = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Start of Config Flow."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
user_input[CONF_NAME] = user_input[CONF_NAME].strip()
|
||||
if not user_input[CONF_NAME]:
|
||||
errors[CONF_NAME] = "empty_name"
|
||||
else:
|
||||
self._async_abort_entries_match(
|
||||
{CONF_NAME: user_input[CONF_NAME]}
|
||||
)
|
||||
|
||||
if not errors:
|
||||
self.data = user_input
|
||||
return await self.async_step_calendar_opts()
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=CALENDAR_NAME_SCHEMA,
|
||||
errors=errors,
|
||||
last_step=False,
|
||||
)
|
||||
|
||||
async def async_step_calendar_opts( # noqa: R701,C901
|
||||
self, user_input: Optional[Dict[str, Any]] = None
|
||||
):
|
||||
"""Calendar Options step for ConfigFlow."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
user_input[CONF_EXCLUDE] = user_input[CONF_EXCLUDE].strip()
|
||||
user_input[CONF_INCLUDE] = user_input[CONF_INCLUDE].strip()
|
||||
if (
|
||||
user_input[CONF_EXCLUDE]
|
||||
and user_input[CONF_EXCLUDE] == user_input[CONF_INCLUDE]
|
||||
):
|
||||
errors[CONF_EXCLUDE] = "exclude_include_cannot_be_the_same"
|
||||
else:
|
||||
if user_input[CONF_EXCLUDE] and not is_array_string(
|
||||
user_input[CONF_EXCLUDE]
|
||||
):
|
||||
errors[CONF_EXCLUDE] = "exclude_must_be_array"
|
||||
if user_input[CONF_INCLUDE] and not is_array_string(
|
||||
user_input[CONF_INCLUDE]
|
||||
):
|
||||
errors[CONF_INCLUDE] = "include_must_be_array"
|
||||
|
||||
if user_input[CONF_DOWNLOAD_INTERVAL] < 15:
|
||||
_LOGGER.error("download_interval_too_small error")
|
||||
errors[CONF_DOWNLOAD_INTERVAL] = "download_interval_too_small"
|
||||
|
||||
if not user_input[CONF_SUMMARY_DEFAULT]:
|
||||
user_input[CONF_SUMMARY_DEFAULT] = CONF_SUMMARY_DEFAULT_DEFAULT
|
||||
|
||||
if not errors:
|
||||
self.data.update(user_input)
|
||||
return await self.async_step_connect_opts()
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="calendar_opts",
|
||||
data_schema=CALENDAR_OPTS_SCHEMA,
|
||||
errors=errors,
|
||||
last_step=False,
|
||||
)
|
||||
|
||||
async def async_step_connect_opts(
|
||||
self, user_input: Optional[Dict[str, Any]] = None
|
||||
):
|
||||
"""Connect Options step for ConfigFlow."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
user_input[CONF_URL] = user_input[CONF_URL].strip()
|
||||
if not user_input[CONF_URL]:
|
||||
errors[CONF_URL] = "empty_url"
|
||||
|
||||
if not errors:
|
||||
user_input[CONF_URL] = format_url(user_input[CONF_URL])
|
||||
|
||||
self.data.update(user_input)
|
||||
if user_input.get(CONF_REQUIRES_AUTH, False):
|
||||
return await self.async_step_auth_opts()
|
||||
if user_input.get(CONF_ADV_CONNECT_OPTS, False):
|
||||
return await self.async_step_adv_connect_opts()
|
||||
return self.async_create_entry(
|
||||
title=self.data[CONF_NAME],
|
||||
data=self.data,
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="connect_opts",
|
||||
data_schema=CONNECT_OPTS_SCHEMA,
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_auth_opts(
|
||||
self, user_input: Optional[Dict[str, Any]] = None
|
||||
):
|
||||
"""Auth Options step for ConfigFlow."""
|
||||
if user_input is not None:
|
||||
self.data.update(user_input)
|
||||
if self.data.get(CONF_ADV_CONNECT_OPTS, False):
|
||||
return await self.async_step_adv_connect_opts()
|
||||
return self.async_create_entry(
|
||||
title=self.data[CONF_NAME],
|
||||
data=self.data,
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="auth_opts", data_schema=AUTH_OPTS_SCHEMA
|
||||
)
|
||||
|
||||
async def async_step_adv_connect_opts(
|
||||
self, user_input: Optional[Dict[str, Any]] = None
|
||||
):
|
||||
"""Advanced Connection Options step for ConfigFlow."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
|
||||
if not errors:
|
||||
self.data.update(user_input)
|
||||
if user_input.get(CONF_SET_TIMEOUT, False):
|
||||
return await self.async_step_timeout_opts()
|
||||
return self.async_create_entry(
|
||||
title=self.data[CONF_NAME],
|
||||
data=self.data,
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="adv_connect_opts",
|
||||
data_schema=ADVANCED_CONNECT_OPTS_SCHEMA,
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_timeout_opts(
|
||||
self, user_input: Optional[Dict[str, Any]] = None
|
||||
):
|
||||
"""Timeout Options step for ConfigFlow."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
|
||||
if not errors:
|
||||
self.data.update(user_input)
|
||||
return self.async_create_entry(
|
||||
title=self.data[CONF_NAME],
|
||||
data=self.data,
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="timeout_opts",
|
||||
data_schema=TIMEOUT_OPTS_SCHEMA,
|
||||
errors=errors,
|
||||
last_step=True,
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_data):
|
||||
"""Import config from configuration.yaml."""
|
||||
return self.async_create_entry(
|
||||
title=import_data[CONF_NAME],
|
||||
data=import_data,
|
||||
)
|
@@ -1,7 +1,24 @@
|
||||
"""Constants for ics_calendar platform."""
|
||||
VERSION = "4.1.0"
|
||||
|
||||
VERSION = "5.1.3"
|
||||
DOMAIN = "ics_calendar"
|
||||
UPGRADE_URL = (
|
||||
"https://github.com/franc6/ics_calendar/blob/releases/"
|
||||
"UpgradeTo4.0AndLater.md"
|
||||
)
|
||||
|
||||
CONF_DEVICE_ID = "device_id"
|
||||
CONF_CALENDARS = "calendars"
|
||||
CONF_DAYS = "days"
|
||||
CONF_INCLUDE_ALL_DAY = "include_all_day"
|
||||
CONF_PARSER = "parser"
|
||||
CONF_DOWNLOAD_INTERVAL = "download_interval"
|
||||
CONF_USER_AGENT = "user_agent"
|
||||
CONF_OFFSET_HOURS = "offset_hours"
|
||||
CONF_ACCEPT_HEADER = "accept_header"
|
||||
CONF_CONNECTION_TIMEOUT = "connection_timeout"
|
||||
CONF_SET_TIMEOUT = "set_connection_timeout"
|
||||
CONF_REQUIRES_AUTH = "requires_auth"
|
||||
CONF_ADV_CONNECT_OPTS = "advanced_connection_options"
|
||||
CONF_SUMMARY_DEFAULT = "summary_default"
|
||||
# It'd be really nifty if this could be a translatable string, but it seems
|
||||
# that's not supported, unless I want to roll my own interpretation of the
|
||||
# translate/*.json files. :(
|
||||
# See also https://github.com/home-assistant/core/issues/125075
|
||||
CONF_SUMMARY_DEFAULT_DEFAULT = "No title"
|
||||
|
@@ -1,9 +1,10 @@
|
||||
"""Provide Filter class."""
|
||||
|
||||
import re
|
||||
from ast import literal_eval
|
||||
from typing import List, Optional, Pattern
|
||||
|
||||
from homeassistant.components.calendar import CalendarEvent
|
||||
from .parserevent import ParserEvent
|
||||
|
||||
|
||||
class Filter:
|
||||
@@ -113,11 +114,11 @@ class Filter:
|
||||
add_event = self._is_included(summary, description)
|
||||
return add_event
|
||||
|
||||
def filter_event(self, event: CalendarEvent) -> bool:
|
||||
def filter_event(self, event: ParserEvent) -> bool:
|
||||
"""Check if the event should be included or not.
|
||||
|
||||
:param event: The event to examine
|
||||
:type event: CalendarEvent
|
||||
:type event: ParserEvent
|
||||
:return: true if the event should be included, otherwise false
|
||||
:rtype: bool
|
||||
"""
|
||||
|
27
custom_components/ics_calendar/getparser.py
Normal file
27
custom_components/ics_calendar/getparser.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""Provide GetParser class."""
|
||||
|
||||
from .icalendarparser import ICalendarParser
|
||||
from .parsers.parser_ics import ParserICS
|
||||
from .parsers.parser_rie import ParserRIE
|
||||
|
||||
|
||||
class GetParser: # pylint: disable=R0903
|
||||
"""Provide get_parser to return an instance of ICalendarParser.
|
||||
|
||||
The class provides a static method , get_instace, to get a parser instance.
|
||||
The non static methods allow this class to act as an "interface" for the
|
||||
parser classes.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_parser(parser: str, *args) -> ICalendarParser | None:
|
||||
"""Get an instance of the requested parser."""
|
||||
# parser_cls = ICalendarParser.get_class(parser)
|
||||
# if parser_cls is not None:
|
||||
# return parser_cls(*args)
|
||||
if parser == "rie":
|
||||
return ParserRIE(*args)
|
||||
if parser == "ics":
|
||||
return ParserICS(*args)
|
||||
|
||||
return None
|
@@ -1,39 +1,14 @@
|
||||
"""Provide ICalendarParser class."""
|
||||
import importlib
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from homeassistant.components.calendar import CalendarEvent
|
||||
|
||||
from .filter import Filter
|
||||
from .parserevent import ParserEvent
|
||||
|
||||
|
||||
class ICalendarParser:
|
||||
"""Provide interface for various parser classes.
|
||||
|
||||
The class provides a static method , get_instace, to get a parser instance.
|
||||
The non static methods allow this class to act as an "interface" for the
|
||||
parser classes.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_class(parser: str):
|
||||
"""Get the class of the requested parser."""
|
||||
parser_module_name = ".parsers.parser_" + parser
|
||||
parser = "Parser" + parser.upper()
|
||||
try:
|
||||
module = importlib.import_module(parser_module_name, __package__)
|
||||
return getattr(module, parser)
|
||||
except ImportError:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_instance(parser: str, *args):
|
||||
"""Get an instance of the requested parser."""
|
||||
parser_cls = ICalendarParser.get_class(parser)
|
||||
if parser_cls is not None:
|
||||
return parser_cls(*args)
|
||||
return None
|
||||
"""Provide interface for various parser classes."""
|
||||
|
||||
def set_content(self, content: str):
|
||||
"""Parse content into a calendar object.
|
||||
@@ -57,7 +32,7 @@ class ICalendarParser:
|
||||
end: datetime,
|
||||
include_all_day: bool,
|
||||
offset_hours: int = 0,
|
||||
) -> list[CalendarEvent]:
|
||||
) -> list[ParserEvent]:
|
||||
"""Get a list of events.
|
||||
|
||||
Gets the events from start to end, including or excluding all day
|
||||
@@ -71,7 +46,7 @@ class ICalendarParser:
|
||||
:param offset_hours the number of hours to offset the event
|
||||
:type offset_hours int
|
||||
:returns a list of events, or an empty list
|
||||
:rtype list[CalendarEvent]
|
||||
:rtype list[ParserEvent]
|
||||
"""
|
||||
|
||||
def get_current_event(
|
||||
@@ -80,7 +55,7 @@ class ICalendarParser:
|
||||
now: datetime,
|
||||
days: int,
|
||||
offset_hours: int = 0,
|
||||
) -> Optional[CalendarEvent]:
|
||||
) -> Optional[ParserEvent]:
|
||||
"""Get the current or next event.
|
||||
|
||||
Gets the current event, or the next upcoming event with in the
|
||||
@@ -93,5 +68,5 @@ class ICalendarParser:
|
||||
:type days int
|
||||
:param offset_hours the number of hours to offset the event
|
||||
:type offset_hours int
|
||||
:returns a CalendarEvent or None
|
||||
:returns a ParserEvent or None
|
||||
"""
|
||||
|
@@ -1,13 +1,13 @@
|
||||
{
|
||||
|
||||
"domain": "ics_calendar",
|
||||
"name": "ics Calendar",
|
||||
"codeowners": ["@franc6"],
|
||||
"config_flow": true,
|
||||
"dependencies": [],
|
||||
"documentation": "https://github.com/franc6/ics_calendar",
|
||||
"integration_type": "service",
|
||||
"iot_class": "cloud_polling",
|
||||
"issue_tracker": "https://github.com/franc6/ics_calendar/issues",
|
||||
"requirements": ["ics>=0.7.2", "recurring_ical_events>=2.0.2", "icalendar>=5.0.4"],
|
||||
"version": "4.1.0"
|
||||
"requirements": ["icalendar~=6.1","python-dateutil>=2.9.0.post0","pytz>=2024.1","recurring_ical_events~=3.5,>=3.5.2","ics==0.7.2","arrow","httpx_auth>=0.22.0,<=0.23.1"],
|
||||
"version": "5.1.3"
|
||||
}
|
||||
|
20
custom_components/ics_calendar/parserevent.py
Normal file
20
custom_components/ics_calendar/parserevent.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""Provide ParserEvent class."""
|
||||
|
||||
import dataclasses
|
||||
|
||||
from homeassistant.components.calendar import CalendarEvent
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class ParserEvent(CalendarEvent):
|
||||
"""Class to represent CalendarEvent without validation."""
|
||||
|
||||
def validate(self) -> None:
|
||||
"""Invoke __post_init__ from CalendarEvent."""
|
||||
return super().__post_init__()
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
"""Don't do validation steps for this class."""
|
||||
# This is necessary to prevent problems when creating events that don't
|
||||
# have a summary. We'll add a summary after the event is created, not
|
||||
# before, to reduce code repitition.
|
@@ -1,14 +1,15 @@
|
||||
"""Support for ics parser."""
|
||||
|
||||
import re
|
||||
from datetime import date, datetime, timedelta
|
||||
from typing import Optional, Union
|
||||
|
||||
from arrow import Arrow, get as arrowget
|
||||
from homeassistant.components.calendar import CalendarEvent
|
||||
from ics import Calendar
|
||||
|
||||
from ..filter import Filter
|
||||
from ..icalendarparser import ICalendarParser
|
||||
from ..parserevent import ParserEvent
|
||||
from ..utility import compare_event_dates
|
||||
|
||||
|
||||
@@ -41,7 +42,7 @@ class ParserICS(ICalendarParser):
|
||||
|
||||
def get_event_list(
|
||||
self, start, end, include_all_day: bool, offset_hours: int = 0
|
||||
) -> list[CalendarEvent]:
|
||||
) -> list[ParserEvent]:
|
||||
"""Get a list of events.
|
||||
|
||||
Gets the events from start to end, including or excluding all day
|
||||
@@ -55,9 +56,9 @@ class ParserICS(ICalendarParser):
|
||||
:param offset_hours the number of hours to offset the event
|
||||
:type offset_hours int
|
||||
:returns a list of events, or an empty list
|
||||
:rtype list[CalendarEvent]
|
||||
:rtype list[ParserEvent]
|
||||
"""
|
||||
event_list: list[CalendarEvent] = []
|
||||
event_list: list[ParserEvent] = []
|
||||
|
||||
if self._calendar is not None:
|
||||
# ics 0.8 takes datetime not Arrow objects
|
||||
@@ -75,7 +76,7 @@ class ParserICS(ICalendarParser):
|
||||
# summary = event.summary
|
||||
# elif hasattr(event, "name"):
|
||||
summary = event.name
|
||||
calendar_event: CalendarEvent = CalendarEvent(
|
||||
calendar_event: ParserEvent = ParserEvent(
|
||||
summary=summary,
|
||||
start=ParserICS.get_date(
|
||||
event.begin, event.all_day, offset_hours
|
||||
@@ -97,7 +98,7 @@ class ParserICS(ICalendarParser):
|
||||
now: datetime,
|
||||
days: int,
|
||||
offset_hours: int = 0,
|
||||
) -> Optional[CalendarEvent]:
|
||||
) -> Optional[ParserEvent]:
|
||||
"""Get the current or next event.
|
||||
|
||||
Gets the current event, or the next upcoming event with in the
|
||||
@@ -110,7 +111,7 @@ class ParserICS(ICalendarParser):
|
||||
:type int
|
||||
:param offset_hours the number of hours to offset the event
|
||||
:type int
|
||||
:returns a CalendarEvent or None
|
||||
:returns a ParserEvent or None
|
||||
"""
|
||||
if self._calendar is None:
|
||||
return None
|
||||
@@ -144,7 +145,7 @@ class ParserICS(ICalendarParser):
|
||||
# summary = temp_event.summary
|
||||
# elif hasattr(event, "name"):
|
||||
summary = temp_event.name
|
||||
return CalendarEvent(
|
||||
return ParserEvent(
|
||||
summary=summary,
|
||||
start=ParserICS.get_date(
|
||||
temp_event.begin, temp_event.all_day, offset_hours
|
||||
|
@@ -1,13 +1,14 @@
|
||||
"""Support for recurring_ical_events parser."""
|
||||
|
||||
from datetime import date, datetime, timedelta
|
||||
from typing import Optional, Union
|
||||
|
||||
import recurring_ical_events as rie
|
||||
from homeassistant.components.calendar import CalendarEvent
|
||||
from icalendar import Calendar
|
||||
|
||||
from ..filter import Filter
|
||||
from ..icalendarparser import ICalendarParser
|
||||
from ..parserevent import ParserEvent
|
||||
from ..utility import compare_event_dates
|
||||
|
||||
|
||||
@@ -45,7 +46,7 @@ class ParserRIE(ICalendarParser):
|
||||
end: datetime,
|
||||
include_all_day: bool,
|
||||
offset_hours: int = 0,
|
||||
) -> list[CalendarEvent]:
|
||||
) -> list[ParserEvent]:
|
||||
"""Get a list of events.
|
||||
|
||||
Gets the events from start to end, including or excluding all day
|
||||
@@ -59,12 +60,12 @@ class ParserRIE(ICalendarParser):
|
||||
:param offset_hours the number of hours to offset the event
|
||||
:type offset_hours int
|
||||
:returns a list of events, or an empty list
|
||||
:rtype list[CalendarEvent]
|
||||
:rtype list[ParserEvent]
|
||||
"""
|
||||
event_list: list[CalendarEvent] = []
|
||||
event_list: list[ParserEvent] = []
|
||||
|
||||
if self._calendar is not None:
|
||||
for event in rie.of(self._calendar).between(
|
||||
for event in rie.of(self._calendar, skip_bad_series=True).between(
|
||||
start - timedelta(hours=offset_hours),
|
||||
end - timedelta(hours=offset_hours),
|
||||
):
|
||||
@@ -73,7 +74,7 @@ class ParserRIE(ICalendarParser):
|
||||
if all_day and not include_all_day:
|
||||
continue
|
||||
|
||||
calendar_event: CalendarEvent = CalendarEvent(
|
||||
calendar_event: ParserEvent = ParserEvent(
|
||||
summary=event.get("SUMMARY"),
|
||||
start=start,
|
||||
end=end,
|
||||
@@ -91,7 +92,7 @@ class ParserRIE(ICalendarParser):
|
||||
now: datetime,
|
||||
days: int,
|
||||
offset_hours: int = 0,
|
||||
) -> Optional[CalendarEvent]:
|
||||
) -> Optional[ParserEvent]:
|
||||
"""Get the current or next event.
|
||||
|
||||
Gets the current event, or the next upcoming event with in the
|
||||
@@ -104,17 +105,17 @@ class ParserRIE(ICalendarParser):
|
||||
:type int
|
||||
:param offset_hours the number of hours to offset the event
|
||||
:type offset_hours int
|
||||
:returns a CalendarEvent or None
|
||||
:returns a ParserEvent or None
|
||||
"""
|
||||
if self._calendar is None:
|
||||
return None
|
||||
|
||||
temp_event: CalendarEvent = None
|
||||
temp_event = None
|
||||
temp_start: date | datetime = None
|
||||
temp_end: date | datetime = None
|
||||
temp_all_day: bool = None
|
||||
end: datetime = now + timedelta(days=days)
|
||||
for event in rie.of(self._calendar).between(
|
||||
for event in rie.of(self._calendar, skip_bad_series=True).between(
|
||||
now - timedelta(hours=offset_hours),
|
||||
end - timedelta(hours=offset_hours),
|
||||
):
|
||||
@@ -139,7 +140,7 @@ class ParserRIE(ICalendarParser):
|
||||
if temp_event is None:
|
||||
return None
|
||||
|
||||
return CalendarEvent(
|
||||
return ParserEvent(
|
||||
summary=temp_event.get("SUMMARY"),
|
||||
start=temp_start,
|
||||
end=temp_end,
|
||||
|
77
custom_components/ics_calendar/strings.json
Normal file
77
custom_components/ics_calendar/strings.json
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"issues": {
|
||||
"YAML_Warning": {
|
||||
"title": "YAML configuration is deprecated for ICS Calendar",
|
||||
"description": "YAML configuration of ics_calendar is deprecated and will be removed in ics_calendar v5.0.0. Your configuration items have been imported. Please remove them from your configuration.yaml file."
|
||||
}
|
||||
},
|
||||
"title": "ICS Calendar",
|
||||
"config": {
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"name": "Name",
|
||||
"days": "Days",
|
||||
"include_all_day": "Include all day events?"
|
||||
},
|
||||
"title": "Add Calendar"
|
||||
},
|
||||
"calendar_opts": {
|
||||
"data": {
|
||||
"exclude": "Exclude filter",
|
||||
"include": "Include filter",
|
||||
"prefix": "String to prefix all event summaries",
|
||||
"download_interval": "Download interval (minutes)",
|
||||
"offset_hours": "Number of hours to offset event times",
|
||||
"parser": "Parser (rie or ics)",
|
||||
"summary_default": "Summary if event doesn't have one"
|
||||
},
|
||||
"title": "Calendar Options"
|
||||
},
|
||||
"connect_opts": {
|
||||
"data": {
|
||||
"url": "URL of ICS file",
|
||||
"requires_auth": "Requires authentication?",
|
||||
"advanced_connection_options": "Set advanced connection options?"
|
||||
},
|
||||
"title": "Connection Options"
|
||||
},
|
||||
"auth_opts": {
|
||||
"data": {
|
||||
"username": "Username",
|
||||
"password": "Password"
|
||||
},
|
||||
"description": "Please note this component supports only HTTP Basic Auth and HTTP Digest Auth. More advanced authentication, like OAuth is not supported at this time.",
|
||||
"title": "Authentication"
|
||||
},
|
||||
"adv_connect_opts": {
|
||||
"data": {
|
||||
"accept_header": "Custom Accept header for broken servers",
|
||||
"user_agent": "Custom User-agent header",
|
||||
"set_connection_timeout": "Change connection timeout?"
|
||||
},
|
||||
"title": "Advanced Connection Options"
|
||||
},
|
||||
"timeout_opts": {
|
||||
"data": {
|
||||
"connection_timeout": "Connection timeout in seconds"
|
||||
},
|
||||
"title": "Connection Timeout Options"
|
||||
},
|
||||
"reauth_confirm": {
|
||||
"description": "Authorization failed for calendar. Please re-configured the calendar URL and/or authentication settings.",
|
||||
"title": "Authorization Failure for ICS Calendar"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"empty_name": "The calendar name must not be empty.",
|
||||
"empty_url": "The url must not be empty.",
|
||||
"download_interval_too_small": "The download interval must be at least 15.",
|
||||
"exclude_include_cannot_be_the_same": "The exclude and include strings must not be the same",
|
||||
"exclude_must_be_array": "The exclude option must be an array of strings or regular expressions. See https://github.com/franc6/ics_calendar/blob/releases/README.md#filters for more information.",
|
||||
"include_must_be_array": "The include option must be an array of strings or regular expressions. See https://github.com/franc6/ics_calendar/blob/releases/README.md#filters for more information."
|
||||
},
|
||||
"abort": {
|
||||
}
|
||||
}
|
||||
}
|
76
custom_components/ics_calendar/translations/de.json
Normal file
76
custom_components/ics_calendar/translations/de.json
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"issues": {
|
||||
"YAML_Warning": {
|
||||
"title": "YAML-Konfiguration für ICS-Kalender ist veraltet",
|
||||
"description": "Die YAML-Konfiguration von ics_calendar ist veraltet und wird in ics_calendar v5.0.0 entfernt. Deine Konfigurationselemente wurden importiert. Bitte entferne sie aus deiner configuration.yaml-Datei."
|
||||
}
|
||||
},
|
||||
"title": "ICS-Kalender",
|
||||
"config": {
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"name": "Name",
|
||||
"days": "Tage",
|
||||
"include_all_day": "Ganztägige Ereignisse einbeziehen?"
|
||||
},
|
||||
"title": "Kalender hinzufügen"
|
||||
},
|
||||
"calendar_opts": {
|
||||
"data": {
|
||||
"exclude": "auszuschließende Ereignisse",
|
||||
"include": "einzuschließende Ereignisse",
|
||||
"prefix": "String, um allen Zusammenfassungen ein Präfix hinzuzufügen",
|
||||
"download_interval": "Download-Intervall (Minuten)",
|
||||
"offset_hours": "Anzahl der Stunden, um Ereigniszeiten zu versetzen",
|
||||
"parser": "Parser (rie oder ics)"
|
||||
},
|
||||
"title": "Kalender-Optionen"
|
||||
},
|
||||
"connect_opts": {
|
||||
"data": {
|
||||
"url": "URL der ICS-Datei",
|
||||
"requires_auth": "Erfordert Authentifizierung?",
|
||||
"advanced_connection_options": "Erweiterte Verbindungsoptionen festlegen?"
|
||||
},
|
||||
"title": "Verbindungsoptionen"
|
||||
},
|
||||
"auth_opts": {
|
||||
"data": {
|
||||
"username": "Benutzername",
|
||||
"password": "Passwort"
|
||||
},
|
||||
"description": "Bitte beachte, dass nur HTTP Basic Auth und HTTP Digest Auth unterstützt wird. Authentifizierungsmethoden wie OAuth werden derzeit nicht unterstützt.",
|
||||
"title": "Authentifizierung"
|
||||
},
|
||||
"adv_connect_opts": {
|
||||
"data": {
|
||||
"accept_header": "Eigener Accept-Header für fehlerhafte Server",
|
||||
"user_agent": "Eigener User-Agent-Header",
|
||||
"set_connection_timeout": "Verbindungstimeout ändern?"
|
||||
},
|
||||
"title": "Erweiterte Verbindungsoptionen"
|
||||
},
|
||||
"timeout_opts": {
|
||||
"data": {
|
||||
"connection_timeout": "Verbindungstimeout in Sekunden"
|
||||
},
|
||||
"title": "Verbindungstimeout-Optionen"
|
||||
},
|
||||
"reauth_confirm": {
|
||||
"description": "Die Autorisierung für den Kalender ist fehlgeschlagen. Bitte konfiguriere die Kalender-URL und/oder die Authentifizierungseinstellungen neu.",
|
||||
"title": "Autorisierungsfehler für ICS-Kalender"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"empty_name": "Der Kalendername darf nicht leer sein.",
|
||||
"empty_url": "Die URL darf nicht leer sein.",
|
||||
"download_interval_too_small": "Das Download-Intervall muss mindestens 15 betragen.",
|
||||
"exclude_include_cannot_be_the_same": "Die Ausschluss- und Einschluss-Strings dürfen nicht identisch sein.",
|
||||
"exclude_must_be_array": "Die \"auszuschließenden Ereignisse\" müssen ein Array von Zeichenfolgen oder regulären Ausdrücken sein. Weitere Informationen finden Sie unter https://github.com/franc6/ics_calendar/blob/releases/README.md#filters.",
|
||||
"include_must_be_array": "Die \"einzuschließenden Ereignisse\" müssen ein Array von Zeichenfolgen oder regulären Ausdrücken sein. Weitere Informationen finden Sie unter https://github.com/franc6/ics_calendar/blob/releases/README.md#filters."
|
||||
},
|
||||
"abort": {
|
||||
}
|
||||
}
|
||||
}
|
77
custom_components/ics_calendar/translations/en.json
Normal file
77
custom_components/ics_calendar/translations/en.json
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"issues": {
|
||||
"YAML_Warning": {
|
||||
"title": "YAML configuration is deprecated for ICS Calendar",
|
||||
"description": "YAML configuration of ics_calendar is deprecated and will be removed in ics_calendar v5.0.0. Your configuration items have been imported. Please remove them from your configuration.yaml file."
|
||||
}
|
||||
},
|
||||
"title": "ICS Calendar",
|
||||
"config": {
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"name": "Name",
|
||||
"days": "Days",
|
||||
"include_all_day": "Include all day events?"
|
||||
},
|
||||
"title": "Add Calendar"
|
||||
},
|
||||
"calendar_opts": {
|
||||
"data": {
|
||||
"exclude": "Exclude filter",
|
||||
"include": "Include filter",
|
||||
"prefix": "String to prefix all event summaries",
|
||||
"download_interval": "Download interval (minutes)",
|
||||
"offset_hours": "Number of hours to offset event times",
|
||||
"parser": "Parser (rie or ics)",
|
||||
"summary_default": "Summary if event doesn't have one"
|
||||
},
|
||||
"title": "Calendar Options"
|
||||
},
|
||||
"connect_opts": {
|
||||
"data": {
|
||||
"url": "URL of ICS file",
|
||||
"requires_auth": "Requires authentication?",
|
||||
"advanced_connection_options": "Set advanced connection options?"
|
||||
},
|
||||
"title": "Connection Options"
|
||||
},
|
||||
"auth_opts": {
|
||||
"data": {
|
||||
"username": "Username",
|
||||
"password": "Password"
|
||||
},
|
||||
"description": "Please note this component supports only HTTP Basic Auth and HTTP Digest Auth. More advanced authentication, like OAuth is not supported at this time.",
|
||||
"title": "Authentication"
|
||||
},
|
||||
"adv_connect_opts": {
|
||||
"data": {
|
||||
"accept_header": "Custom Accept header for broken servers",
|
||||
"user_agent": "Custom User-agent header",
|
||||
"set_connection_timeout": "Change connection timeout?"
|
||||
},
|
||||
"title": "Advanced Connection Options"
|
||||
},
|
||||
"timeout_opts": {
|
||||
"data": {
|
||||
"connection_timeout": "Connection timeout in seconds"
|
||||
},
|
||||
"title": "Connection Timeout Options"
|
||||
},
|
||||
"reauth_confirm": {
|
||||
"description": "Authorization failed for calendar. Please re-configured the calendar URL and/or authentication settings.",
|
||||
"title": "Authorization Failure for ICS Calendar"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"empty_name": "The calendar name must not be empty.",
|
||||
"empty_url": "The url must not be empty.",
|
||||
"download_interval_too_small": "The download interval must be at least 15.",
|
||||
"exclude_include_cannot_be_the_same": "The exclude and include strings must not be the same",
|
||||
"exclude_must_be_array": "The exclude option must be an array of strings or regular expressions. See https://github.com/franc6/ics_calendar/blob/releases/README.md#filters for more information.",
|
||||
"include_must_be_array": "The include option must be an array of strings or regular expressions. See https://github.com/franc6/ics_calendar/blob/releases/README.md#filters for more information."
|
||||
},
|
||||
"abort": {
|
||||
}
|
||||
}
|
||||
}
|
77
custom_components/ics_calendar/translations/es.json
Normal file
77
custom_components/ics_calendar/translations/es.json
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"issues": {
|
||||
"YAML_Warning": {
|
||||
"title": "La configuración YAML está obsoleta para ICS Calendar",
|
||||
"description": "La configuración YAML de ics_calendar está obsoleta y se eliminará en ics_calendar v5.0.0. Sus elementos de configuración se han importado. Elimínelos de su archivo configuration.yaml."
|
||||
}
|
||||
},
|
||||
"title": "ICS Calendar",
|
||||
"config": {
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"name": "Nombre",
|
||||
"days": "Días",
|
||||
"include_all_day": "¿Incluir eventos de todo el día?"
|
||||
},
|
||||
"title": "Agregar calendario"
|
||||
},
|
||||
"calendar_opts": {
|
||||
"data": {
|
||||
"exclude": "Excluir filtro",
|
||||
"include": "Incluir filtro",
|
||||
"prefix": "Cadena que precederá a todos los resúmenes de eventos",
|
||||
"download_interval": "Intervalo de descarga (minutos)",
|
||||
"offset_hours": "Número de horas para compensar los tiempos del evento",
|
||||
"parser": "Parser (rie or ics)",
|
||||
"summary_default": "Resumen si el evento no tiene uno"
|
||||
},
|
||||
"title": "Opciones de calendario"
|
||||
},
|
||||
"connect_opts": {
|
||||
"data": {
|
||||
"url": "URL del archivo ICS",
|
||||
"requires_auth": "¿Requiere autentificación?",
|
||||
"advanced_connection_options": "¿Establecer opciones de conexión avanzadas?"
|
||||
},
|
||||
"title": "Opciones de conexión"
|
||||
},
|
||||
"auth_opts": {
|
||||
"data": {
|
||||
"username": "Nombre de usuario",
|
||||
"password": "Contraseña"
|
||||
},
|
||||
"description": "Tenga en cuenta que este componente solo admite la autenticación básica HTTP y la autenticación HTTP Digest. Actualmente, no se admiten autenticaciones más avanzadas, como OAuth.",
|
||||
"title": "Autentificación"
|
||||
},
|
||||
"adv_connect_opts": {
|
||||
"data": {
|
||||
"accept_header": "Encabezado Accept personalizado para servidores rotos",
|
||||
"user_agent": "Encabezado de agente de usuario personalizado",
|
||||
"set_connection_timeout": "¿Cambiar el tiempo de espera de la conexión?"
|
||||
},
|
||||
"title": "Opciones avanzadas de conexión"
|
||||
},
|
||||
"timeout_opts": {
|
||||
"data": {
|
||||
"connection_timeout": "Tiempo de espera de la conexión en segundos"
|
||||
},
|
||||
"title": "Opciones de tiempo de espera de la conexión"
|
||||
},
|
||||
"reauth_confirm": {
|
||||
"description": "Error de autorización para el calendario. Vuelva a configurar la URL del calendario y/o los ajustes de autenticación.",
|
||||
"title": "Fallo de autorización para ICS Calendar"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"empty_name": "El nombre del calendario no debe estar vacío.",
|
||||
"empty_url": "La url no debe estar vacía.",
|
||||
"download_interval_too_small": "El intervalo de descarga debe ser de al menos 15.",
|
||||
"exclude_include_cannot_be_the_same": "Las cadenas de exclusión e inclusión no deben ser las mismas",
|
||||
"exclude_must_be_array": "La opción de exclusión debe ser una matriz de cadenas o expresiones regulares. Consulte https://github.com/franc6/ics_calendar/blob/releases/README.md#filters para obtener más información.",
|
||||
"include_must_be_array": "La opción de inclusión debe ser un array de cadenas o expresiones regulares. Consulte https://github.com/franc6/ics_calendar/blob/releases/README.md#filters para obtener más información."
|
||||
},
|
||||
"abort": {
|
||||
}
|
||||
}
|
||||
}
|
76
custom_components/ics_calendar/translations/fr.json
Normal file
76
custom_components/ics_calendar/translations/fr.json
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"issues": {
|
||||
"YAML_Warning": {
|
||||
"title": "La configuration YAML pour ICS Calendar est obsolète",
|
||||
"description": "La configuration YAML d'ICS Calendar est obsolète et sera supprimée dans la version 5.0.0 d'ics_calendar. Les éléments de votre configuration ont été importés. Veuillez les supprimer de votre fichier configuration.yaml."
|
||||
}
|
||||
},
|
||||
"title": "ICS Calendar",
|
||||
"config": {
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"name": "Nom",
|
||||
"days": "Jours",
|
||||
"include_all_day": "Inclure les événements à la journée ?"
|
||||
},
|
||||
"title": "Ajouter un calendrier"
|
||||
},
|
||||
"calendar_opts": {
|
||||
"data": {
|
||||
"exclude": "Exclure les événements contenant",
|
||||
"include": "Inclure les événements contenant",
|
||||
"prefix": "Préfixer tous les résumés d'événements avec",
|
||||
"download_interval": "Intervalle de téléchargement (minutes)",
|
||||
"offset_hours": "Décalage à appliquer aux horaires des événements (heures)",
|
||||
"parser": "Parseur (rie ou ics)"
|
||||
},
|
||||
"title": "Options du calendrier"
|
||||
},
|
||||
"connect_opts": {
|
||||
"data": {
|
||||
"url": "URL du fichier ICS",
|
||||
"requires_auth": "Authentification requise ?",
|
||||
"advanced_connection_options": "Définir les options avancées de la connexion ?"
|
||||
},
|
||||
"title": "Options de connexion"
|
||||
},
|
||||
"auth_opts": {
|
||||
"data": {
|
||||
"username": "Utilisateur",
|
||||
"password": "Mot de passe"
|
||||
},
|
||||
"description": "Veuillez noter que cette intégration ne supporte que les modes d'authentification HTTP Basic et HTTP Digest. Les méthodes d'authentification plus avancées, telles que OAuth, ne sont pas supportées actuellement.",
|
||||
"title": "Authentification"
|
||||
},
|
||||
"adv_connect_opts": {
|
||||
"data": {
|
||||
"accept_header": "Entête 'Accept' personnalisée pour les serveurs injoignables",
|
||||
"user_agent": "Entête 'User-agent' personnalisée",
|
||||
"set_connection_timeout": "Modifier le délai maximum autorisé pour la connexion ?"
|
||||
},
|
||||
"title": "Options avancées de connexion"
|
||||
},
|
||||
"timeout_opts": {
|
||||
"data": {
|
||||
"connection_timeout": "Délai maximum autorisé pour la connexion (secondes)"
|
||||
},
|
||||
"title": "Options de délai de connexion"
|
||||
},
|
||||
"reauth_confirm": {
|
||||
"description": "L'autorisation a échoué pour le calendrier. Veuillez vérifier l'URL du calendrier et/ou les paramètres d'authentification.",
|
||||
"title": "Échec d'autorisation pour ICS Calendar"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"empty_name": "Le nom du calendrier doit être renseigné.",
|
||||
"empty_url": "L'URL du calendrier doit être renseignée.",
|
||||
"download_interval_too_small": "L'intervalle de téléchargement ne peut pas être inférieur à 15 minutes.",
|
||||
"exclude_include_cannot_be_the_same": "Les valeurs d'exclusion et d'inclusion ne peuvent pas être identiques.",
|
||||
"exclude_must_be_array": "The exclude option must be an array of strings or regular expressions. See https://github.com/franc6/ics_calendar/blob/releases/README.md#filters for more information.",
|
||||
"include_must_be_array": "The include option must be an array of strings or regular expressions. See https://github.com/franc6/ics_calendar/blob/releases/README.md#filters for more information."
|
||||
},
|
||||
"abort": {
|
||||
}
|
||||
}
|
||||
}
|
77
custom_components/ics_calendar/translations/pt-br.json
Normal file
77
custom_components/ics_calendar/translations/pt-br.json
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"issues": {
|
||||
"YAML_Warning": {
|
||||
"title": "A configuração YAML está obsoleta para o ICS Calendar",
|
||||
"description": "A configuração YAML do ics_calendar está obsoleta e será removida na versão 5.0.0 do ics_calendar. Seus itens de configuração foram importados. Por favor, remova-os do seu arquivo configuration.yaml."
|
||||
}
|
||||
},
|
||||
"title": "ICS Calendar",
|
||||
"config": {
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"name": "Nome",
|
||||
"days": "Dias",
|
||||
"include_all_day": "Incluir eventos de dia inteiro?"
|
||||
},
|
||||
"title": "Adicionar Calendário"
|
||||
},
|
||||
"calendar_opts": {
|
||||
"data": {
|
||||
"exclude": "Filtro de exclusão",
|
||||
"include": "Filtro de inclusão",
|
||||
"prefix": "Texto para prefixar todos os resumos de eventos",
|
||||
"download_interval": "Intervalo de download (minutos)",
|
||||
"offset_hours": "Número de horas para ajustar os horários dos eventos",
|
||||
"parser": "Parser (rie ou ics)",
|
||||
"summary_default": "Resumo padrão se o evento não tiver um"
|
||||
},
|
||||
"title": "Opções do Calendário"
|
||||
},
|
||||
"connect_opts": {
|
||||
"data": {
|
||||
"url": "URL do arquivo ICS",
|
||||
"requires_auth": "Requer autenticação?",
|
||||
"advanced_connection_options": "Definir opções de conexão avançadas?"
|
||||
},
|
||||
"title": "Opções de Conexão"
|
||||
},
|
||||
"auth_opts": {
|
||||
"data": {
|
||||
"username": "Usuário",
|
||||
"password": "Senha"
|
||||
},
|
||||
"description": "Este componente oferece suporte apenas para HTTP Basic Auth e HTTP Digest Auth. Métodos de autenticação mais avançados, como OAuth, ainda não são suportados.",
|
||||
"title": "Autenticação"
|
||||
},
|
||||
"adv_connect_opts": {
|
||||
"data": {
|
||||
"accept_header": "Cabeçalho Accept personalizado para servidores com problemas",
|
||||
"user_agent": "Cabeçalho User-agent personalizado",
|
||||
"set_connection_timeout": "Alterar tempo limite de conexão?"
|
||||
},
|
||||
"title": "Opções Avançadas de Conexão"
|
||||
},
|
||||
"timeout_opts": {
|
||||
"data": {
|
||||
"connection_timeout": "Tempo limite de conexão em segundos"
|
||||
},
|
||||
"title": "Opções de Tempo Limite de Conexão"
|
||||
},
|
||||
"reauth_confirm": {
|
||||
"description": "A autorização falhou para o calendário. Por favor, reconfigure a URL do calendário e/ou as configurações de autenticação.",
|
||||
"title": "Falha de Autorização para o ICS Calendar"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"empty_name": "O nome do calendário não pode estar vazio.",
|
||||
"empty_url": "A URL não pode estar vazia.",
|
||||
"download_interval_too_small": "O intervalo de download deve ser de pelo menos 15.",
|
||||
"exclude_include_cannot_be_the_same": "As strings de exclusão e inclusão não podem ser as mesmas.",
|
||||
"exclude_must_be_array": "A opção de exclusão deve ser um array de strings ou expressões regulares. Veja https://github.com/franc6/ics_calendar/blob/releases/README.md#filters para mais informações.",
|
||||
"include_must_be_array": "A opção de inclusão deve ser um array de strings ou expressões regulares. Veja https://github.com/franc6/ics_calendar/blob/releases/README.md#filters para mais informações."
|
||||
},
|
||||
"abort": {
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
"""Utility methods."""
|
||||
|
||||
from datetime import date, datetime
|
||||
|
||||
|
||||
@@ -9,7 +10,7 @@ def make_datetime(val):
|
||||
return val
|
||||
|
||||
|
||||
def compare_event_dates( # pylint: disable=R0913
|
||||
def compare_event_dates( # pylint: disable=R0913,R0917
|
||||
now, end2, start2, all_day2, end, start, all_day
|
||||
) -> bool:
|
||||
"""Determine if end2 and start2 are newer than end and start."""
|
||||
|
BIN
custom_components/ics_calendar_old.tar.bz2
Normal file
BIN
custom_components/ics_calendar_old.tar.bz2
Normal file
Binary file not shown.
@@ -41,7 +41,7 @@ ota:
|
||||
wifi:
|
||||
ssid: "Voltage-legacy"
|
||||
password: !secret voltage_legacy_psk
|
||||
use_address: ${name}.home
|
||||
use_address: atorch-dc-load.home
|
||||
power_save_mode: high
|
||||
fast_connect: on
|
||||
|
||||
|
@@ -49,7 +49,7 @@ i2c:
|
||||
scl: 7
|
||||
scan: true
|
||||
|
||||
# DHT22 sensor
|
||||
# Temp/humidity sensors
|
||||
sensor:
|
||||
- platform: dht
|
||||
model: dht22
|
||||
|
@@ -197,12 +197,14 @@ sensor:
|
||||
text_sensor:
|
||||
- platform: homeassistant
|
||||
name: "Sun Rising ESP"
|
||||
#entity_id: sensor.sun_next_rising
|
||||
entity_id: sensor.sun_rising_template
|
||||
id: sun_rising
|
||||
internal: true
|
||||
|
||||
- platform: homeassistant
|
||||
name: "Sun Setting ESP"
|
||||
#entity_id: sensor.sun_next_setting
|
||||
entity_id: sensor.sun_setting_template
|
||||
id: sun_setting
|
||||
internal: true
|
||||
|
31
esphome/home-assistant-voice-09c0e7.yaml
Normal file
31
esphome/home-assistant-voice-09c0e7.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
substitutions:
|
||||
name: home-assistant-voice-09c0e7
|
||||
friendly_name: Home Assistant Voice 09c0e7
|
||||
packages:
|
||||
Nabu Casa.Home Assistant Voice PE: github://esphome/home-assistant-voice-pe/home-assistant-voice.yaml
|
||||
esphome:
|
||||
name: ${name}
|
||||
name_add_mac_suffix: false
|
||||
friendly_name: ${friendly_name}
|
||||
|
||||
wifi:
|
||||
ssid: "Voltage-legacy"
|
||||
password: !secret voltage_legacy_psk
|
||||
#use_address: ${name}.home
|
||||
#power_save_mode: high
|
||||
#fast_connect: on
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "HA Voice Fallback Hotspot"
|
||||
password: !secret fallback_psk
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: !secret apikey
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
password: !secret ota
|
||||
|
114
esphome/kamera-balkon.yaml
Normal file
114
esphome/kamera-balkon.yaml
Normal file
@@ -0,0 +1,114 @@
|
||||
substitutions:
|
||||
name: kamera-balkon
|
||||
friendly_name: Kamera Balkon
|
||||
|
||||
esphome:
|
||||
name: ${name}
|
||||
friendly_name: ${friendly_name}
|
||||
name_add_mac_suffix: false
|
||||
project:
|
||||
name: sensor.camera
|
||||
version: "1.0"
|
||||
min_version: 2022.1.0
|
||||
|
||||
esp32:
|
||||
board: esp32cam
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
wifi:
|
||||
ssid: "Voltage-legacy"
|
||||
password: !secret voltage_legacy_psk
|
||||
# use_address: cam-balcony.home
|
||||
power_save_mode: high
|
||||
fast_connect: on
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Cam Balkon Fallback Hotspot"
|
||||
password: !secret fallback_psk
|
||||
|
||||
captive_portal:
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: !secret apikey
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
password: !secret ota
|
||||
|
||||
# Initialize I²C
|
||||
i2c:
|
||||
- id: bus_a
|
||||
sda: GPIO13
|
||||
scl: GPIO14
|
||||
scan: true
|
||||
- id: bus_c
|
||||
sda: GPIO26
|
||||
scl: GPIO27
|
||||
|
||||
# Camera
|
||||
esp32_camera:
|
||||
name: ${friendly_name}
|
||||
external_clock:
|
||||
pin: GPIO0
|
||||
frequency: 20MHz
|
||||
i2c_id:
|
||||
bus_c
|
||||
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
|
||||
vsync_pin: GPIO25
|
||||
href_pin: GPIO23
|
||||
pixel_clock_pin: GPIO22
|
||||
power_down_pin: GPIO32
|
||||
resolution: SVGA
|
||||
max_framerate: 24 fps
|
||||
idle_framerate: 0.2 fps
|
||||
jpeg_quality: 30
|
||||
agc_mode: auto
|
||||
agc_gain_ceiling: 4x
|
||||
wb_mode: auto
|
||||
vertical_flip: true
|
||||
horizontal_mirror: true
|
||||
|
||||
esp32_camera_web_server:
|
||||
- port: 8080
|
||||
mode: stream
|
||||
- port: 8081
|
||||
mode: snapshot
|
||||
|
||||
# Temp/humidity sensors
|
||||
sensor:
|
||||
- platform: wifi_signal
|
||||
name: "WiFi Signalstärke"
|
||||
update_interval: 60s
|
||||
- platform: sht3xd
|
||||
i2c_id:
|
||||
bus_a
|
||||
temperature:
|
||||
name: "Balkon Temperatur"
|
||||
filters:
|
||||
- offset: -4.4
|
||||
humidity:
|
||||
name: "Balkon Luftfeuchtigkeit"
|
||||
address: 0x44
|
||||
heater_enabled: True
|
||||
update_interval: 60s
|
||||
|
||||
# Flash LED
|
||||
output:
|
||||
- platform: ledc
|
||||
pin: GPIO4
|
||||
id: flash
|
||||
channel: 2
|
||||
|
||||
# Define RGB mode for LED
|
||||
light:
|
||||
- platform: monochromatic
|
||||
id: flashlight
|
||||
name: "Blitzlicht"
|
||||
output: flash
|
@@ -19,7 +19,7 @@ esp32:
|
||||
wifi:
|
||||
ssid: "Voltage-legacy"
|
||||
password: !secret voltage_legacy_psk
|
||||
use_address: ${name}.home
|
||||
use_address: cam-livingroom.home
|
||||
power_save_mode: high
|
||||
fast_connect: on
|
||||
|
||||
@@ -60,9 +60,23 @@ esp32_camera:
|
||||
max_framerate: 24 fps
|
||||
idle_framerate: 0.2 fps
|
||||
jpeg_quality: 30
|
||||
agc_mode: auto
|
||||
agc_gain_ceiling: 4x
|
||||
wb_mode: auto
|
||||
vertical_flip: true
|
||||
horizontal_mirror: true
|
||||
|
||||
esp32_camera_web_server:
|
||||
- port: 8080
|
||||
mode: stream
|
||||
- port: 8081
|
||||
mode: snapshot
|
||||
|
||||
sensor:
|
||||
- platform: wifi_signal
|
||||
name: "WiFi Signalstärke"
|
||||
update_interval: 60s
|
||||
|
||||
# Flash LED
|
||||
output:
|
||||
- platform: ledc
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# Source: https://github.com/esphome/wake-word-voice-assistants/blob/main/m5stack-atom-echo/m5stack-atom-echo.yaml
|
||||
|
||||
substitutions:
|
||||
name: m5stack-atom-echo
|
||||
friendly_name: M5Stack Atom Echo
|
||||
@@ -13,8 +15,6 @@ esp32:
|
||||
board: m5stack-atom
|
||||
framework:
|
||||
type: esp-idf
|
||||
version: 4.4.8
|
||||
platform_version: 5.4.0
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
@@ -78,6 +78,7 @@ media_player:
|
||||
format: WAV
|
||||
codec_support_enabled: false
|
||||
buffer_size: 6000
|
||||
volume_min: 0.4
|
||||
files:
|
||||
- id: timer_finished_wave_file
|
||||
file: https://github.com/esphome/wake-word-voice-assistants/raw/main/sounds/timer_finished.wav
|
||||
@@ -211,7 +212,6 @@ light:
|
||||
chipset: SK6812
|
||||
num_leds: 1
|
||||
rgb_order: grb
|
||||
rmt_channel: 0
|
||||
effects:
|
||||
- pulse:
|
||||
name: "Slow Pulse"
|
||||
|
@@ -1,6 +1,14 @@
|
||||
# Source: https://github.com/RASPIAUDIO/esphomeLuxe/blob/main/luxe_microWW.yaml
|
||||
|
||||
substitutions:
|
||||
name: "raspiaudio-muse-luxe"
|
||||
friendly_name: "RaspiAudio Muse Luxe"
|
||||
#States
|
||||
P_starting: "0"
|
||||
P_waiting: "1"
|
||||
P_playing: "2"
|
||||
P_listening: "3"
|
||||
P_answering: "4"
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
@@ -12,6 +20,14 @@ ota:
|
||||
id: ota_esphome
|
||||
password: !secret ota
|
||||
|
||||
external_components:
|
||||
- source: github://RASPIAUDIO/esphomeLuxe@main
|
||||
# - source:
|
||||
# type: local
|
||||
# path: components
|
||||
components: [es8388]
|
||||
refresh: 0s
|
||||
|
||||
wifi:
|
||||
ssid: Voltage-legacy
|
||||
password: !secret voltage_legacy_psk
|
||||
@@ -26,125 +42,175 @@ wifi:
|
||||
esphome:
|
||||
name: ${name}
|
||||
friendly_name: ${friendly_name}
|
||||
min_version: 2025.2.0
|
||||
name_add_mac_suffix: false
|
||||
project:
|
||||
name: raspiaudio.muse-luxe
|
||||
version: "1.0"
|
||||
min_version: 2024.6.0
|
||||
platformio_options:
|
||||
board_build.flash_mode: dio
|
||||
board_build.arduino.memory_type: qio_opi
|
||||
on_boot:
|
||||
priority: -100.0
|
||||
then:
|
||||
- media_player.volume_set:
|
||||
id: luxe_out
|
||||
volume: 50%
|
||||
- lambda: id(phase) = 0;
|
||||
- script.execute: update_led
|
||||
|
||||
esp32:
|
||||
board: esp-wrover-kit
|
||||
board: esp-wrover-kit
|
||||
flash_size: 4MB
|
||||
framework:
|
||||
type: arduino
|
||||
type: esp-idf
|
||||
version: recommended
|
||||
sdkconfig_options:
|
||||
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
|
||||
CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
|
||||
CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
|
||||
|
||||
micro_wake_word:
|
||||
id: mww
|
||||
models:
|
||||
- model: https://github.com/kahrendt/microWakeWord/releases/download/okay_nabu_20241226.3/okay_nabu.json
|
||||
# - model: hey_jarvis
|
||||
# - model: hey_mycroft
|
||||
# - model: alexa
|
||||
# vad:
|
||||
microphone: luxe_mic
|
||||
on_wake_word_detected:
|
||||
- voice_assistant.start:
|
||||
wake_word: !lambda return wake_word;
|
||||
|
||||
logger:
|
||||
|
||||
i2c:
|
||||
- id: i2c_bus
|
||||
sda: GPIO18
|
||||
scl: GPIO23
|
||||
|
||||
dashboard_import:
|
||||
package_import_url: github://esphome/media-players/raspiaudio-muse-luxe.yaml@main
|
||||
level: DEBUG
|
||||
|
||||
captive_portal:
|
||||
|
||||
external_components:
|
||||
- source: github://pr#3552 # DAC support https://github.com/esphome/esphome/pull/3552
|
||||
components: [es8388]
|
||||
refresh: 0s
|
||||
improv_serial:
|
||||
|
||||
##########
|
||||
# Hardware Configuration
|
||||
es8388:
|
||||
id: my_es8388
|
||||
|
||||
i2s_audio:
|
||||
- id: i2s_audio_bus
|
||||
i2s_lrclk_pin: GPIO25
|
||||
i2s_bclk_pin: GPIO5
|
||||
psram:
|
||||
mode: quad
|
||||
speed: 80MHz
|
||||
|
||||
media_player:
|
||||
- platform: i2s_audio
|
||||
name: None
|
||||
id: luxe_out
|
||||
dac_type: external
|
||||
i2s_dout_pin: GPIO26
|
||||
mode: stereo
|
||||
mute_pin:
|
||||
#######
|
||||
# Buses Configuration
|
||||
i2c:
|
||||
sda: GPIO18
|
||||
scl: GPIO23
|
||||
|
||||
#####################
|
||||
# Internal Components
|
||||
output:
|
||||
- platform: gpio
|
||||
id: dac_mute
|
||||
pin:
|
||||
number: GPIO21
|
||||
inverted: true
|
||||
mode:
|
||||
output: true
|
||||
|
||||
microphone:
|
||||
- platform: i2s_audio
|
||||
id: luxe_microphone
|
||||
i2s_din_pin: GPIO35
|
||||
adc_type: external
|
||||
pdm: false
|
||||
globals:
|
||||
- id: Vol
|
||||
type: float
|
||||
initial_value: '0.6'
|
||||
- id: phase
|
||||
type: int
|
||||
initial_value: '0'
|
||||
- id: mute
|
||||
type: bool
|
||||
initial_value: 'false'
|
||||
- id: muteH
|
||||
type: bool
|
||||
initial_value: 'false'
|
||||
|
||||
voice_assistant:
|
||||
microphone: luxe_microphone
|
||||
on_start:
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
blue: 100%
|
||||
red: 0%
|
||||
green: 0%
|
||||
effect: none
|
||||
on_tts_start:
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
blue: 60%
|
||||
red: 20%
|
||||
green: 20%
|
||||
effect: none
|
||||
on_tts_end:
|
||||
- media_player.play_media: !lambda return x;
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
blue: 60%
|
||||
red: 20%
|
||||
green: 20%
|
||||
effect: pulse
|
||||
on_end:
|
||||
- delay: 1s
|
||||
- wait_until:
|
||||
not:
|
||||
media_player.is_playing: luxe_out
|
||||
- light.turn_off: top_led
|
||||
on_error:
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
blue: 0%
|
||||
red: 100%
|
||||
green: 0%
|
||||
effect: none
|
||||
- delay: 1s
|
||||
- light.turn_off: top_led
|
||||
interval:
|
||||
- interval: 0.1sec
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
- speaker.is_stopped:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
- not:
|
||||
- lambda: 'return(id(muteH));'
|
||||
then:
|
||||
- output.turn_on: dac_mute
|
||||
- lambda: id(muteH) = true;
|
||||
- logger.log: "====> hardware mute"
|
||||
|
||||
- if:
|
||||
condition:
|
||||
- speaker.is_playing:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
- lambda: 'return(id(muteH));'
|
||||
then:
|
||||
- output.turn_off: dac_mute
|
||||
- lambda: id(muteH) = false;
|
||||
- logger.log: "====> hardware unmute"
|
||||
|
||||
sensor:
|
||||
- platform: adc
|
||||
id: battery_sensor
|
||||
pin: GPIO33
|
||||
name: Battery
|
||||
icon: "mdi:battery-outline"
|
||||
name: Battery voltage
|
||||
device_class: voltage
|
||||
unit_of_measurement: "V"
|
||||
accuracy_decimals: 2
|
||||
state_class: measurement
|
||||
entity_category: diagnostic
|
||||
unit_of_measurement: V
|
||||
update_interval: 15s
|
||||
accuracy_decimals: 3
|
||||
attenuation: 12db
|
||||
raw: true
|
||||
attenuation: auto
|
||||
filters:
|
||||
- multiply: 0.00173913 # 2300 -> 4, for attenuation 11db, based on Olivier's code
|
||||
- multiply: 2 # https://forum.raspiaudio.com/t/esp-muse-luxe-bluetooth-speaker/294/12
|
||||
- exponential_moving_average:
|
||||
alpha: 0.2
|
||||
send_every: 2
|
||||
- delta: 0.002
|
||||
on_value:
|
||||
then:
|
||||
- sensor.template.publish:
|
||||
id: battery_percent
|
||||
state: !lambda "return x;"
|
||||
|
||||
- platform: template
|
||||
name: Battery
|
||||
id: battery_percent
|
||||
device_class: battery
|
||||
unit_of_measurement: "%"
|
||||
accuracy_decimals: 0
|
||||
state_class: measurement
|
||||
entity_category: diagnostic
|
||||
update_interval: 15s
|
||||
filters:
|
||||
- calibrate_polynomial:
|
||||
degree: 3
|
||||
datapoints:
|
||||
- 4.58 -> 100.0
|
||||
- 4.5 -> 97.1
|
||||
- 4.47 -> 94.2
|
||||
- 4.44 -> 88.4
|
||||
- 4.42 -> 82.7
|
||||
- 4.41 -> 76.9
|
||||
- 4.41 -> 71.1
|
||||
- 4.37 -> 65.3
|
||||
- 4.35 -> 59.5
|
||||
- 4.31 -> 53.8
|
||||
- 4.28 -> 48.0
|
||||
- 4.26 -> 42.2
|
||||
- 4.23 -> 36.4
|
||||
- 4.21 -> 30.6
|
||||
- 4.19 -> 24.9
|
||||
- 4.16 -> 19.1
|
||||
- 4.1 -> 13.3
|
||||
- 4.07 -> 10.4
|
||||
- 4.03 -> 7.5
|
||||
- 3.97 -> 4.6
|
||||
- 3.82 -> 1.7
|
||||
- 3.27 -> 0.0
|
||||
- lambda: return clamp(x, 0.0f, 100.0f);
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
@@ -155,10 +221,14 @@ binary_sensor:
|
||||
input: true
|
||||
pullup: true
|
||||
name: Volume Up
|
||||
id: volume_up
|
||||
on_click:
|
||||
- media_player.volume_up:
|
||||
id: luxe_out
|
||||
- lambda: |-
|
||||
id(Vol) += 0.05;
|
||||
if(id(Vol) > 1) id(Vol) = 1;
|
||||
- media_player.volume_set:
|
||||
id: luxe_media_player
|
||||
volume: !lambda return id(Vol);
|
||||
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO32
|
||||
@@ -167,55 +237,251 @@ binary_sensor:
|
||||
input: true
|
||||
pullup: true
|
||||
name: Volume Down
|
||||
id: volume_down
|
||||
on_click:
|
||||
- media_player.volume_down:
|
||||
id: luxe_out
|
||||
- lambda: |-
|
||||
id(Vol) -= 0.05;
|
||||
if(id(Vol) < 0) id(Vol) = 0;
|
||||
- media_player.volume_set:
|
||||
id: luxe_media_player
|
||||
volume: !lambda return id(Vol);
|
||||
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO12
|
||||
inverted: true
|
||||
mode:
|
||||
input: true
|
||||
pullup: true
|
||||
name: Action
|
||||
id: action_button
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON FOR AT MOST 350ms
|
||||
- OFF FOR AT LEAST 10ms
|
||||
then:
|
||||
- media_player.toggle:
|
||||
id: luxe_out
|
||||
- timing:
|
||||
- ON FOR AT LEAST 350ms
|
||||
then:
|
||||
- voice_assistant.start:
|
||||
- timing:
|
||||
- ON FOR AT LEAST 350ms
|
||||
- OFF FOR AT LEAST 10ms
|
||||
then:
|
||||
- voice_assistant.stop:
|
||||
pullup: true
|
||||
name: Mute
|
||||
on_click:
|
||||
- if:
|
||||
condition:
|
||||
- lambda: 'return(id(mute));'
|
||||
then:
|
||||
- script.execute: mute_off
|
||||
- lambda: id(mute) = false;
|
||||
else:
|
||||
- script.execute: mute_on
|
||||
- lambda: id(mute) = true;
|
||||
on_double_click:
|
||||
- if:
|
||||
condition:
|
||||
- lambda: 'return(id(phase) == 2);'
|
||||
then:
|
||||
- media_player.stop:
|
||||
|
||||
light:
|
||||
- platform: fastled_clockless
|
||||
- platform: esp32_rmt_led_strip
|
||||
name: None
|
||||
id: top_led
|
||||
pin: GPIO22
|
||||
chipset: SK6812
|
||||
chipset: WS2812
|
||||
num_leds: 1
|
||||
rgb_order: grb
|
||||
# rmt_channel: 0
|
||||
default_transition_length: 0s
|
||||
gamma_correct: 2.8
|
||||
effects:
|
||||
- pulse:
|
||||
name: pulse
|
||||
transition_length: 250ms
|
||||
update_interval: 250ms
|
||||
- pulse:
|
||||
name: slow_pulse
|
||||
transition_length: 1s
|
||||
update_interval: 2s
|
||||
|
||||
button:
|
||||
- platform: safe_mode
|
||||
id: button_safe_mode
|
||||
name: Safe Mode Boot
|
||||
i2s_audio:
|
||||
i2s_lrclk_pin: GPIO25
|
||||
i2s_bclk_pin: GPIO5
|
||||
i2s_mclk_pin: GPIO0
|
||||
|
||||
- platform: factory_reset
|
||||
id: factory_reset_btn
|
||||
name: Factory reset
|
||||
microphone:
|
||||
- platform: i2s_audio
|
||||
id: luxe_mic
|
||||
sample_rate: 16000
|
||||
i2s_din_pin: GPIO35
|
||||
bits_per_sample: 16bit
|
||||
channel: stereo
|
||||
adc_type: external
|
||||
|
||||
speaker:
|
||||
- platform: i2s_audio
|
||||
id: luxe_speaker
|
||||
i2s_dout_pin: GPIO26
|
||||
dac_type: external
|
||||
sample_rate: 48000
|
||||
bits_per_sample: 16bit
|
||||
channel: stereo
|
||||
buffer_duration: 100ms
|
||||
|
||||
media_player:
|
||||
- platform: speaker
|
||||
name: None
|
||||
id: luxe_media_player
|
||||
# volume_min: 0.5
|
||||
# volume_max: 0.8
|
||||
announcement_pipeline:
|
||||
speaker: luxe_speaker
|
||||
format: FLAC
|
||||
sample_rate: 48000
|
||||
num_channels: 2
|
||||
files:
|
||||
- id: little_sound
|
||||
file: https://github.com/esphome/home-assistant-voice-pe/raw/dev/sounds/timer_finished.flac
|
||||
on_announcement:
|
||||
- micro_wake_word.stop:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return(id(phase) != 2);'
|
||||
then:
|
||||
- lambda: |-
|
||||
if(id(phase) == 1) id(phase) = 2;
|
||||
- script.execute: mute_off
|
||||
- script.execute: update_led
|
||||
|
||||
on_idle:
|
||||
- wait_until:
|
||||
and:
|
||||
- not:
|
||||
media_player.is_announcing:
|
||||
- not:
|
||||
voice_assistant.is_running:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return((id(phase) == 4) || (id(phase) == 2));'
|
||||
then:
|
||||
- lambda: |-
|
||||
id(phase) = 1;
|
||||
- micro_wake_word.start:
|
||||
- script.execute: update_led
|
||||
|
||||
voice_assistant:
|
||||
id: va
|
||||
microphone: luxe_mic
|
||||
media_player: luxe_media_player
|
||||
use_wake_word: false
|
||||
noise_suppression_level: 2
|
||||
auto_gain: 31dBFS
|
||||
volume_multiplier: 2.0
|
||||
|
||||
on_listening:
|
||||
- logger.log: "listening 3 => phase"
|
||||
- micro_wake_word.stop:
|
||||
- lambda: |-
|
||||
id(phase) = 3;
|
||||
- script.execute: update_led
|
||||
|
||||
on_stt_end:
|
||||
- media_player.play_media: !lambda return x;
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
blue: 60%
|
||||
red: 20%
|
||||
green: 20%
|
||||
effect: pulse
|
||||
|
||||
|
||||
on_tts_start:
|
||||
- logger.log: "answering 4 => phase"
|
||||
- lambda: |-
|
||||
id(phase) = 4;
|
||||
- script.execute: update_led
|
||||
|
||||
on_error:
|
||||
- logger.log: "ERROR!!!!!!!!!!!!!!!!"
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
blue: 0%
|
||||
red: 100%
|
||||
green: 0%
|
||||
effect: pulse
|
||||
- delay: 3s
|
||||
- lambda: id(phase) = 1;
|
||||
- script.execute: update_led
|
||||
|
||||
|
||||
#########
|
||||
# Scripts
|
||||
|
||||
script:
|
||||
- id: update_led
|
||||
then:
|
||||
- logger.log: "==>>>update_led"
|
||||
- lambda: |-
|
||||
if(id(phase) == 0)id(start).execute();
|
||||
if(id(phase) == 1)id(waiting).execute();
|
||||
if(id(phase) == 2)id(external_player).execute();
|
||||
if(id(phase) == 3)id(listening).execute();
|
||||
if(id(phase) == 4)id(answering).execute();
|
||||
|
||||
- id: start
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
effect: slow_pulse
|
||||
red: 80%
|
||||
green: 0%
|
||||
blue: 80%
|
||||
- delay: 5sec
|
||||
- lambda: id(my_es8388).setup();
|
||||
- output.turn_off: dac_mute
|
||||
- lambda: id(phase) = 1;
|
||||
- media_player.speaker.play_on_device_media_file:
|
||||
media_file: little_sound
|
||||
announcement: true
|
||||
- script.execute: update_led
|
||||
|
||||
- id: waiting
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
effect: pulse
|
||||
red: 0%
|
||||
green: 0%
|
||||
blue: 100%
|
||||
brightness: 100%
|
||||
- voice_assistant.stop:
|
||||
- micro_wake_word.start:
|
||||
|
||||
|
||||
- id: listening
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
effect: pulse
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
brightness: 100%
|
||||
|
||||
- id: answering
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
effect: none
|
||||
red: 100%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
brightness: 100%
|
||||
|
||||
- id: external_player
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: top_led
|
||||
effect: none
|
||||
red: 80%
|
||||
green: 40%
|
||||
blue: 0%
|
||||
|
||||
- id: mute_on
|
||||
then:
|
||||
- media_player.volume_set:
|
||||
volume: '0'
|
||||
- lambda: id(mute) = true;
|
||||
|
||||
- id: mute_off
|
||||
then:
|
||||
- media_player.volume_set:
|
||||
volume: !lambda return(id(Vol));
|
||||
- lambda: id(mute) = false;
|
||||
|
BIN
image/681fb9bf3fd83a14a1ec95b48169723c/256x256
Normal file
BIN
image/681fb9bf3fd83a14a1ec95b48169723c/256x256
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
BIN
image/681fb9bf3fd83a14a1ec95b48169723c/512x512
Normal file
BIN
image/681fb9bf3fd83a14a1ec95b48169723c/512x512
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
image/681fb9bf3fd83a14a1ec95b48169723c/original
Normal file
BIN
image/681fb9bf3fd83a14a1ec95b48169723c/original
Normal file
Binary file not shown.
After Width: | Height: | Size: 685 KiB |
@@ -1,6 +0,0 @@
|
||||
bdm:
|
||||
name: BDM
|
||||
mac: BLE_34:14:B5:A0:99:BD
|
||||
icon:
|
||||
picture:
|
||||
track: true
|
162
mqtt.yaml
162
mqtt.yaml
@@ -7,7 +7,7 @@
|
||||
value_template: '{{ float(value) * 99 + 1 }}'
|
||||
state_class: measurement
|
||||
entity_category: diagnostic
|
||||
state_topic: rtl_433/sdr/devices/Auriol-AHFL/1/244/battery_ok
|
||||
state_topic: rtl_433/sdr/devices/Auriol-AHFL/1/216/battery_ok
|
||||
unique_id: Auriol-AHFL-1-106-B
|
||||
device:
|
||||
identifiers: Auriol-AHFL-1-106
|
||||
@@ -20,7 +20,7 @@
|
||||
unit_of_measurement: °C
|
||||
value_template: '{{ value|float }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Auriol-AHFL/1/244/temperature_C
|
||||
state_topic: rtl_433/sdr/devices/Auriol-AHFL/1/216/temperature_C
|
||||
unique_id: Auriol-AHFL-1-106-T
|
||||
device:
|
||||
identifiers: Auriol-AHFL-1-106
|
||||
@@ -33,7 +33,7 @@
|
||||
unit_of_measurement: '%'
|
||||
value_template: '{{ value|float }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Auriol-AHFL/1/244/humidity
|
||||
state_topic: rtl_433/sdr/devices/Auriol-AHFL/1/216/humidity
|
||||
unique_id: Auriol-AHFL-1-106-H
|
||||
device:
|
||||
identifiers: Auriol-AHFL-1-106
|
||||
@@ -47,7 +47,7 @@
|
||||
value_template: '{{ float(value) * 99 + 1 }}'
|
||||
state_class: measurement
|
||||
entity_category: diagnostic
|
||||
state_topic: rtl_433/sdr/devices/Vauno-EN8822C/1/244/battery_ok
|
||||
state_topic: rtl_433/sdr/devices/Vauno-EN8822C/1/216/battery_ok
|
||||
unique_id: Vauno-EN8822C-1-244-B
|
||||
device:
|
||||
identifiers: Vauno-EN8822C-1-244
|
||||
@@ -81,3 +81,157 @@
|
||||
model: Vauno-EN8822C
|
||||
manufacturer: rtl_433
|
||||
|
||||
- device_class: humidity
|
||||
unit_of_measurement: '%'
|
||||
value_template: '{{ value|float }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Nexus-TH/1/238/humidity
|
||||
unique_id: Nexus-TH-1-238-H
|
||||
device:
|
||||
identifiers:
|
||||
- Nexus-TH-1-238
|
||||
model: Nexus-TH
|
||||
manufacturer: rtl_433
|
||||
name: Nexus-TH-1-238
|
||||
name: Humidity
|
||||
|
||||
- device_class: humidity
|
||||
unit_of_measurement: '%'
|
||||
value_template: '{{ value|float }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Nexus-TH/1/238/humidity
|
||||
unique_id: Nexus-TH-1-238-H
|
||||
device:
|
||||
identifiers:
|
||||
- Nexus-TH-1-238
|
||||
model: Nexus-TH
|
||||
manufacturer: rtl_433
|
||||
name: Nexus-TH-1-238
|
||||
name: Humidity
|
||||
|
||||
# Cotech-367959
|
||||
|
||||
- device_class: battery
|
||||
unit_of_measurement: '%'
|
||||
value_template: '{{ ((float(value) * 99)|round(0)) + 1 }}'
|
||||
state_class: measurement
|
||||
entity_category: diagnostic
|
||||
state_topic: rtl_433/sdr/devices/Cotech-367959/130/battery_ok
|
||||
unique_id: Cotech-367959-130-B
|
||||
device:
|
||||
identifiers:
|
||||
- Cotech-367959-130
|
||||
model: Cotech-367959
|
||||
manufacturer: rtl_433
|
||||
name: Cotech-367959-130
|
||||
name: Battery
|
||||
|
||||
- device_class: temperature
|
||||
unit_of_measurement: °F
|
||||
value_template: '{{ value|float|round(1) }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Cotech-367959/130/temperature_F
|
||||
unique_id: Cotech-367959-130-F
|
||||
device:
|
||||
identifiers:
|
||||
- Cotech-367959-130
|
||||
model: Cotech-367959
|
||||
manufacturer: rtl_433
|
||||
name: Cotech-367959-130
|
||||
name: Temperature
|
||||
|
||||
- device_class: humidity
|
||||
unit_of_measurement: '%'
|
||||
value_template: '{{ value|float }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Cotech-367959/130/humidity
|
||||
unique_id: Cotech-367959-130-H
|
||||
device:
|
||||
identifiers:
|
||||
- Cotech-367959-130
|
||||
model: Cotech-367959
|
||||
manufacturer: rtl_433
|
||||
name: Cotech-367959-130
|
||||
name: Humidity
|
||||
|
||||
- device_class: precipitation
|
||||
unit_of_measurement: mm
|
||||
value_template: '{{ value|float|round(2) }}'
|
||||
state_class: total_increasing
|
||||
state_topic: rtl_433/sdr/devices/Cotech-367959/130/rain_mm
|
||||
unique_id: Cotech-367959-130-RT
|
||||
device:
|
||||
identifiers:
|
||||
- Cotech-367959-130
|
||||
model: Cotech-367959
|
||||
manufacturer: rtl_433
|
||||
name: Cotech-367959-130
|
||||
name: Rain Total
|
||||
|
||||
- unit_of_measurement: °
|
||||
value_template: '{{ value|float }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Cotech-367959/130/wind_dir_deg
|
||||
unique_id: Cotech-367959-130-WD
|
||||
device:
|
||||
identifiers:
|
||||
- Cotech-367959-130
|
||||
model: Cotech-367959
|
||||
manufacturer: rtl_433
|
||||
name: Cotech-367959-130
|
||||
name: Wind Direction
|
||||
|
||||
- device_class: wind_speed
|
||||
unit_of_measurement: km/h
|
||||
value_template: '{{ (float(value|float) * 3.6) | round(2) }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Cotech-367959/130/wind_avg_m_s
|
||||
unique_id: Cotech-367959-130-WS
|
||||
device:
|
||||
identifiers:
|
||||
- Cotech-367959-130
|
||||
model: Cotech-367959
|
||||
manufacturer: rtl_433
|
||||
name: Cotech-367959-130
|
||||
name: Wind Average
|
||||
|
||||
- device_class: wind_speed
|
||||
unit_of_measurement: km/h
|
||||
value_template: '{{ (float(value|float) * 3.6) | round(2) }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Cotech-367959/130/wind_max_m_s
|
||||
unique_id: Cotech-367959-130-GS
|
||||
device:
|
||||
identifiers:
|
||||
- Cotech-367959-130
|
||||
model: Cotech-367959
|
||||
manufacturer: rtl_433
|
||||
name: Cotech-367959-130
|
||||
name: Wind max
|
||||
|
||||
- device_class: illuminance
|
||||
unit_of_measurement: lx
|
||||
value_template: '{{ value|int }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Cotech-367959/130/light_lux
|
||||
unique_id: Cotech-367959-130-lux
|
||||
device:
|
||||
identifiers:
|
||||
- Cotech-367959-130
|
||||
model: Cotech-367959
|
||||
manufacturer: rtl_433
|
||||
name: Cotech-367959-130
|
||||
name: Outside Luminance
|
||||
|
||||
- unit_of_measurement: UV Index
|
||||
value_template: '{{ value|float|round(1) }}'
|
||||
state_class: measurement
|
||||
state_topic: rtl_433/sdr/devices/Cotech-367959/130/uv
|
||||
unique_id: Cotech-367959-130-uv
|
||||
device:
|
||||
identifiers:
|
||||
- Cotech-367959-130
|
||||
model: Cotech-367959
|
||||
manufacturer: rtl_433
|
||||
name: Cotech-367959-130
|
||||
name: UV Index
|
||||
|
8
mqtt_statestream.yaml
Normal file
8
mqtt_statestream.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
base_topic: homeassistant
|
||||
publish_attributes: true
|
||||
publish_timestamps: true
|
||||
# include:
|
||||
# entities:
|
||||
# - sensor.Netzleistung
|
||||
|
||||
|
8
notify.yaml
Normal file
8
notify.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
#All Mobile Phones
|
||||
- platform: group
|
||||
name: "Alle mobilen Geräte"
|
||||
services:
|
||||
- service: mobile_app_le2123
|
||||
- service: mobile_app_apollo
|
||||
- service: mobile_app_xt2125_4
|
||||
|
@@ -29,6 +29,7 @@
|
||||
- sensor.*_wi_fi_signal
|
||||
- sensor.*_wifi_strenght
|
||||
- sensor.*_uptime
|
||||
- sensor.sun*
|
||||
entities:
|
||||
- sun.sun # Don't record sun data
|
||||
- sensor.fritzbox_device_uptime
|
||||
|
@@ -61,7 +61,8 @@
|
||||
{% set kaffeemaschine = states('sensor.kaffeemaschine_leistung_2') | float %}
|
||||
{% set waeschetrockner = states('sensor.waschetrockner_leistung') | float %}
|
||||
{% set waschmaschine = states('sensor.waschmaschine_leistung') | float %}
|
||||
{{ (total + solar - raumduft - keller - musik - bett - heimkino_sz - deko - schreibtisch - serverraum - heimkino_wz - spieleschrank - kuehlschrank - kaffeemaschine - waeschetrockner - waschmaschine) | round(1) }}
|
||||
{% set arcade = states('sensor.arcade_automat_leistung') | float %}
|
||||
{{ (total + solar - raumduft - keller - musik - bett - heimkino_sz - deko - schreibtisch - serverraum - heimkino_wz - spieleschrank - kuehlschrank - kaffeemaschine - waeschetrockner - waschmaschine - arcade) | round(1) }}
|
||||
device_class: power
|
||||
state_class: measurement
|
||||
attributes:
|
||||
|
Reference in New Issue
Block a user