diff --git a/include/automations/der_er_nogen_i_indkorslen.yaml b/include/automations/der_er_nogen_i_indkorslen.yaml new file mode 100644 index 0000000..1e3ba62 --- /dev/null +++ b/include/automations/der_er_nogen_i_indkorslen.yaml @@ -0,0 +1,38 @@ + - alias: 'Der er nogen i indkørslen' + trigger: + platform: state + entity_id: binary_sensor.indkorsel_sensor_motion + to: 'on' + action: + - service: notify.mobile_app_claus_iphone8 + data: + message: "Der er nogen i indkørslen" +# - service: script.sonos_say +# data: +# sonos_entity: media_player.alrum +# volume: 0.4 +# delay: '00:00:05' +# message: 'Der er nogen i indkørslen' + - service: scene.create + data: + scene_id: before + snapshot_entities: + - light.stol + - service: light.turn_on + data: + entity_id: light.stol + brightness: 255 + rgb_color: [255, 0, 0] + flash: long + - delay: 2 + - service: scene.turn_on + entity_id: scene.before + + + +# - service: script.sonos_say +# data: +# sonos_entity: media_player.kontor +# volume: 0.7 +# message: 'Hej Claus er det dig der går i gangen?' +# delay: '00:00:05' diff --git a/include/automations/good_morning.yaml b/include/automations/good_morning.yaml new file mode 100644 index 0000000..dfe33ca --- /dev/null +++ b/include/automations/good_morning.yaml @@ -0,0 +1,57 @@ +###################################################################### +## Weekday Morning Routines for the Wife and Kiddos. +###################################################################### + + - alias: 'Godmorgen start igen' + trigger: + platform: sun + event: sunset + action: + - service: input_boolean.turn_off + data: + entity_id: input_boolean.first_run + + - alias: 'Godmorgen' + trigger: + platform: state + entity_id: binary_sensor.stue_motion_sensor + to: 'on' + condition: + - condition: time + after: '06:00:00' + before: '10:00:00' + - condition: state + entity_id: input_boolean.first_run + state: 'off' + action: +# - service: scene.turn_on +# entity_id: scene.34900 + - service: input_boolean.turn_on + data: + entity_id: input_boolean.first_run + - service: script.monthly_color_scene + + - alias: 'Godmorgen Children arbejdsdag' + trigger: + platform: time + at: '06:00:00' + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'on' + action: + - service: script.andreas_color_scene + - service: script.daniel_color_scene + + - alias: 'Godmorgen Children ikke arbejdsdag' + trigger: + platform: time + at: '08:00:00' + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'off' + action: + - service: script.andreas_color_scene + - service: script.daniel_color_scene + diff --git a/include/automations/good_night.yaml b/include/automations/good_night.yaml new file mode 100644 index 0000000..854318e --- /dev/null +++ b/include/automations/good_night.yaml @@ -0,0 +1,34 @@ +###################################################################### +## Good night Routine +###################################################################### + + - alias: 'Godnat start igen' + trigger: + platform: sun + event: sunrise + action: + - service: input_boolean.turn_off + data: + entity_id: input_boolean.first_run_eve + + - alias: 'Godnat' + trigger: + platform: state + entity_id: binary_sensor.gang_sensor_motion + to: 'on' + condition: + - condition: time + after: '19:00:00' + before: '19:40:00' + - condition: state + entity_id: input_boolean.first_run_eve + state: 'off' + action: +# - service: scene.turn_on +# entity_id: scene.34900 + - service: input_boolean.turn_on + data: + entity_id: input_boolean.first_run_eve +# - service: script.bed_color_scene +# - service: script.monthly_color_scene + diff --git a/include/automations/groupsonos.yaml b/include/automations/groupsonos.yaml new file mode 100644 index 0000000..30c94e5 --- /dev/null +++ b/include/automations/groupsonos.yaml @@ -0,0 +1,20 @@ +# on "workdays" and "no guests" + - alias: 'Gruppe køkken, stue, alrum, bad' + trigger: + - platform: time + at: "00:05:30" + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'on' + action: + - service: sonos.join + data: + master: media_player.kokken + entity_id: + - media_player.badevaerelse +# - media_player.sovevaerelse + - media_player.stue + - media_player.alrum + + diff --git a/include/automations/julelys.yaml b/include/automations/julelys.yaml new file mode 100644 index 0000000..b29fc49 --- /dev/null +++ b/include/automations/julelys.yaml @@ -0,0 +1,84 @@ +## Skal være tændt fra solnedgang og til kl 22 +## og fra 6-solopgang +## derudover: hvis solen er under horisonten, så tænd i 5 minutter ved bevægelse + - alias: 'Julelys tænd morgen' + trigger: + platform: time + at: "06:00:00" + condition: + - condition: state # from sunset until sunrise + entity_id: sun.sun + state: 'below_horizon' + action: + - service: light.turn_on + data: + entity_id: light.julelys + + - alias: 'Julelys sluk morgen' + trigger: + platform: sun + event: sunrise + action: + - service: light.turn_off + data: + entity_id: light.julelys + + - alias: 'Julelys tænd aften' + trigger: + platform: sun + event: sunset + condition: + - condition: time + before: '22:00:00' + action: + - service: light.turn_on + data: + entity_id: light.julelys + + - alias: 'Julelys sluk aften' + trigger: + platform: time + at: "21:00:00" + action: + - service: light.turn_off + data: + entity_id: light.julelys + + +# - alias: 'Julelys tænd ved bevægelse' +# trigger: +# platform: state +# entity_id: binary_sensor.indkorsel_sensor_motion +# to: 'on' +# condition: +# - condition: time +# after: '22:00:10' +# before: '05:54:00' +# - condition: state +# entity_id: sun.sun +# state: below_horizon +# action: +# - service: light.turn_on +# data: +# entity_id: light.julelys + +# - alias: 'Julelys sluk 15 min efter bevægelse' +# trigger: +# platform: state +# entity_id: binary_sensor.indkorsel_sensor_motion +# to: 'off' +# for: +# minutes: 15 +# condition: +# - condition: time +# after: '22:00:10' +# before: '05:54:00' +# - condition: state +# entity_id: sun.sun +# state: below_horizon +# action: +# service: light.turn_off +# data: +# entity_id: light.julelys + + diff --git a/include/automations/kommerhjem.yaml b/include/automations/kommerhjem.yaml new file mode 100644 index 0000000..d50cae0 --- /dev/null +++ b/include/automations/kommerhjem.yaml @@ -0,0 +1,127 @@ + - alias: 'Mor kommer hjem' + trigger: + platform: state + entity_id: device_tracker.annes_iphone_xs + to: 'home' + + action: + service: notify.mobile_app_claus_iphone8 + data: + message: 'Mor kommer hjem' + + - alias: 'Daniel kommer hjem (mor)' + trigger: + platform: state + entity_id: device_tracker.daniels_iphone_7 + to: 'home' + + action: + service: notify.mobile_app_annes_iphone_xs + data: + message: 'Daniel kommer hjem' + + - alias: 'Daniel kommer hjem' + trigger: + platform: state + entity_id: device_tracker.daniels_iphone_7 + to: 'home' + + action: + service: notify.mobile_app_claus_iphone8 + data: + message: 'Daniel kommer hjem' + + - alias: 'Andreas kommer hjem (mor)' + trigger: + platform: state + entity_id: device_tracker.andreas_iphone_12 + to: 'home' + + action: + service: notify.mobile_app_annes_iphone_xs + data: + message: 'Andreas kommer hjem' + + + - alias: 'Andreas kommer hjem' + trigger: + platform: state + entity_id: device_tracker.andreas_iphone_12 + to: 'home' + + action: + service: notify.mobile_app_claus_iphone8 + data: + message: 'Andreas kommer hjem' + + + + - alias: 'Andreas ankommer til skole (mor)' + trigger: + platform: state + entity_id: device_tracker.andreas_iphone_12 + to: 'Skole' + + action: + service: notify.mobile_app_annes_iphone_xs + data: + message: 'Andreas ankommer til skole' + + - alias: 'Andreas ankommer til skole' + trigger: + platform: state + entity_id: device_tracker.andreas_iphone_12 + to: 'Skole' + + action: + service: notify.mobile_app_claus_iphone8 + data: + message: 'Andreas ankommer til skole' + + - alias: 'Andreas tager fra skole' + trigger: + platform: state + entity_id: device_tracker.andreas_iphone_12 + from: 'Skole' + + action: + service: notify.mobile_app_claus_iphone8 + data: + message: 'Andreas tager fra skole' + + + + - alias: 'Daniel ankommer til skole (mor)' + trigger: + platform: state + entity_id: device_tracker.daniels_iphone_7 + to: 'Skole' + + action: + service: notify.mobile_app_annes_iphone_xs + data: + message: 'Daniel ankommer til skole' + + + - alias: 'Daniel ankommer til skole' + trigger: + platform: state + entity_id: device_tracker.daniels_iphone_7 + to: 'Skole' + + action: + service: notify.mobile_app_claus_iphone8 + data: + message: 'Daniel ankommer til skole' + + - alias: 'Daniel tager fra skole' + trigger: + platform: state + entity_id: device_tracker.daniels_iphone_7 + from: 'Skole' + + action: + service: notify.mobile_app_claus_iphone8 + data: + message: 'Daniel tager fra skole' + diff --git a/include/automations/lys_forgang.yaml b/include/automations/lys_forgang.yaml new file mode 100644 index 0000000..562e65f --- /dev/null +++ b/include/automations/lys_forgang.yaml @@ -0,0 +1,43 @@ +# Turns on lights at sunset + - alias: 'Lys i glasskab i forgang' + trigger: + - platform: sun + event: sunset + condition: + - condition: time + before: '21:30:00' + action: + service: homeassistant.turn_on + entity_id: light.sonoff_100069a6cc + +# Turns off lights + - alias: 'Sluk lys i glasskab i forgang' + trigger: + - platform: time + at: '22:00:00' + action: + service: homeassistant.turn_off + entity_id: light.sonoff_100069a6cc + +# Turns on lights at 06:00 + - alias: 'Lys i glasskab i forgang morgen' + trigger: + - platform: time + at: '06:00:00' + condition: + - condition: state # from sunset until sunrise + entity_id: sun.sun + state: 'below_horizon' + action: + service: homeassistant.turn_on + entity_id: light.sonoff_100069a6cc + +# Turns off lights at sunrise + - alias: 'Sluk lys i glasskab i forgang morgen' + trigger: + - platform: sun + event: sunrise + action: + service: homeassistant.turn_off + entity_id: light.sonoff_100069a6cc + diff --git a/include/automations/lys_gang.yaml b/include/automations/lys_gang.yaml new file mode 100644 index 0000000..8c2c4ff --- /dev/null +++ b/include/automations/lys_gang.yaml @@ -0,0 +1,171 @@ + - alias: 'Lys i gang - arbejdsdag - dag' + trigger: + platform: state + entity_id: binary_sensor.gang_sensor_motion + to: 'on' + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'on' + - condition: numeric_state + entity_id: sensor.gang_sensor_light_level + below: '70' + - condition: time + before: '19:30:00' + - condition: time + after: '06:15:00' + action: + - service: light.turn_on + data: + entity_id: light.gang + brightness: 255 + color_temp: 396 + + - alias: 'Sluk Lys i gang - arbejdsdag - dag' + trigger: + platform: state + entity_id: binary_sensor.gang_sensor_motion + to: 'off' + for: + minutes: 2 + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'on' + - condition: time + after: '06:15:10' + - condition: time + before: '19:30:00' + action: + service: light.turn_off + data: + entity_id: light.gang + + - alias: 'Lys i gang - ikke arbejdsdag - dag' + trigger: + platform: state + entity_id: binary_sensor.gang_sensor_motion + to: 'on' + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'off' + - condition: numeric_state + entity_id: sensor.gang_sensor_light_level + below: 70 + - condition: time + after: '08:00:00' + - condition: time + before: '20:30:00' + action: + - service: light.turn_on + data: + entity_id: light.gang + brightness: 255 + color_temp: 396 + + - alias: 'Sluk Lys i gang - ikke arbejdsdag - dag' + trigger: + platform: state + entity_id: binary_sensor.gang_sensor_motion + to: 'off' + for: + minutes: 2 + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'off' + - condition: time + after: '08:00:10' + - condition: time + before: '20:30:00' + action: + service: light.turn_off + data: + entity_id: light.gang + +########## NIGHT + + - alias: 'Lys i gang - arbejdsdag - nat' + trigger: + platform: state + entity_id: binary_sensor.gang_sensor_motion + to: 'on' + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'on' + - condition: numeric_state + entity_id: sensor.gang_sensor_light_level + below: '70' + - condition: time + before: '06:15:00' + after: '19:30:00' + action: + - service: light.turn_on + data: + entity_id: light.gang_syd + brightness_pct: 1 + color_temp: 396 + + - alias: 'Sluk Lys i gang - arbejdsdag - nat' + trigger: + platform: state + entity_id: binary_sensor.gang_sensor_motion + to: 'off' + for: + minutes: 1 + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'on' + - condition: time + after: '19:30:10' + before: '06:15:00' + action: + service: light.turn_off + data: + entity_id: light.gang_syd + + - alias: 'Lys i gang - ikke arbejdsdag - nat' + trigger: + platform: state + entity_id: binary_sensor.gang_sensor_motion + to: 'on' + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'off' + # - condition: numeric_state + # entity_id: sensor.gang_sensor_light_level + # below: '70' + - condition: time + after: '20:30:00' + before: '08:00:00' + action: + - service: light.turn_on + data: + entity_id: light.gang_syd + brightness_pct: 1 + color_temp: 396 + + + - alias: 'Sluk Lys i gang - ikke arbejdsdag - nat' + trigger: + platform: state + entity_id: binary_sensor.gang_sensor_motion + to: 'off' + for: + minutes: 1 + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'off' + - condition: time + after: '20:30:10' + before: '08:00:00' + action: + - service: light.turn_off + data: + entity_id: light.gang_syd + diff --git a/include/automations/lys_have.yaml b/include/automations/lys_have.yaml new file mode 100644 index 0000000..fe917ae --- /dev/null +++ b/include/automations/lys_have.yaml @@ -0,0 +1,22 @@ +################################### +## Turn on garden lights +# +# +################################### + +- alias: 'Lys have, aften' + trigger: + - platform: sun + event: sunset +# offset: "00:10:00" + condition: + - condition: time + before: '22:00:00' + action: +# - delay: '00:{{ (range(1, 20)|random|int) }}:00' + - service: script.have_color_scene +# - service: light.turn_on +# entity_id: +# - light.havelys + + diff --git a/include/automations/lysindkorsel.yaml b/include/automations/lysindkorsel.yaml new file mode 100644 index 0000000..80a01a6 --- /dev/null +++ b/include/automations/lysindkorsel.yaml @@ -0,0 +1,84 @@ +## Skal være tændt fra solnedgang og til kl 22 +## og fra 6-solopgang +## derudover: hvis solen er under horisonten, så tænd i 5 minutter ved bevægelse + - alias: 'Tænd lys indkørsel morgen' + trigger: + platform: time + at: "06:00:00" + condition: + - condition: state # from sunset until sunrise + entity_id: sun.sun + state: 'below_horizon' + action: + - service: light.turn_on + data: + entity_id: light.indkorsel + + - alias: 'Sluk lys indkørsel morgen' + trigger: + platform: sun + event: sunrise + action: + - service: light.turn_off + data: + entity_id: light.indkorsel + + - alias: 'Tænd lys indkørsel aften' + trigger: + platform: sun + event: sunset + condition: + - condition: time + before: '22:00:00' + action: + - service: light.turn_on + data: + entity_id: light.indkorsel + + - alias: 'Sluk lys indkørsel aften' + trigger: + platform: time + at: "22:00:00" + action: + - service: light.turn_off + data: + entity_id: light.indkorsel + + + - alias: 'Tænd lys indkørsel ved bevægelse' + trigger: + platform: state + entity_id: binary_sensor.indkorsel_sensor_motion + to: 'on' + condition: + - condition: time + after: '22:00:10' + before: '05:54:00' + - condition: state + entity_id: sun.sun + state: below_horizon + action: + - service: light.turn_on + data: + entity_id: light.indkorsel + + - alias: 'Sluk lys indkørsel 15 min efter bevægelse' + trigger: + platform: state + entity_id: binary_sensor.indkorsel_sensor_motion + to: 'off' + for: + minutes: 15 + condition: + - condition: time + after: '22:00:10' + before: '05:54:00' + - condition: state + entity_id: sun.sun + state: below_horizon + action: + service: light.turn_off + data: + entity_id: light.indkorsel + + diff --git a/include/automations/lysvedgarage.yaml b/include/automations/lysvedgarage.yaml new file mode 100644 index 0000000..cb0d727 --- /dev/null +++ b/include/automations/lysvedgarage.yaml @@ -0,0 +1,28 @@ + - alias: 'Lys ved garage' + trigger: + platform: state + entity_id: binary_sensor.indkorsel_sensor_motion + to: 'on' + condition: + - condition: time + before: '23:00:00' +# - condition: state +# entity_id: sun.sun +# state: below_horizon + action: + - service: homeassistant.turn_on + entity_id: light.drivhus + + - alias: 'Sluk lys ved garage' + trigger: + platform: state + entity_id: binary_sensor.indkorsel_sensor_motion + to: 'off' + for: + minutes: 10 + action: + service: homeassistant.turn_off + data: + entity_id: light.drivhus + + diff --git a/include/automations/restart.yaml b/include/automations/restart.yaml new file mode 100644 index 0000000..1901a85 --- /dev/null +++ b/include/automations/restart.yaml @@ -0,0 +1,17 @@ +# restart HA to keep it fresh +- alias: Restart HA + trigger: + platform: time + at: "02:00:00" + condition: + condition: time + weekday: + - sun + - mon + - tue + - wed + - thu + - fri + - sat + action: + - service: homeassistant.restart diff --git a/include/automations/sunset_turn_on.yaml b/include/automations/sunset_turn_on.yaml new file mode 100644 index 0000000..88eb0c3 --- /dev/null +++ b/include/automations/sunset_turn_on.yaml @@ -0,0 +1,23 @@ +################################### +## Sunrise and Sunset stuff +# @CCOSTAN +# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig +################################### + +- alias: 'Sunset Stuff on' + trigger: + - platform: sun + event: sunset +# offset: "-00:20:00" + condition: + - condition: time + before: '22:00:00' + action: +# - delay: '00:{{ (range(1, 20)|random|int) }}:00' + - service: script.monthly_color_scene + - service: light.turn_on + entity_id: + - light.stue + - light.raket + - light.stol + diff --git a/include/automations/ungroupsonos.yaml b/include/automations/ungroupsonos.yaml new file mode 100644 index 0000000..d4c0d0e --- /dev/null +++ b/include/automations/ungroupsonos.yaml @@ -0,0 +1,29 @@ +# on "workdays" and "no guests" + - alias: 'Gruppe køkken, stue, alrum' + trigger: + - platform: time + at: "08:30:00" + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'on' + action: + - service: sonos.unjoin + entity_id: media_player.badevaerelse + - service: sonos.unjoin + entity_id: media_player.sovevaerelse + + - alias: 'Gruppe køkken uden stue, alrum' + trigger: + - platform: time + at: "17:00:00" + condition: + - condition: state + entity_id: binary_sensor.arbejdsdag + state: 'on' + action: + - service: sonos.unjoin + entity_id: media_player.kokken + + + diff --git a/include/device_trackers.yaml b/include/device_trackers.yaml new file mode 100644 index 0000000..b6cf68e --- /dev/null +++ b/include/device_trackers.yaml @@ -0,0 +1,5 @@ +# - platform: tile +# username: !secret tile_username +# password: !secret tile_password + +# - platform: huesensor diff --git a/python_scripts/date_countdown.py b/python_scripts/date_countdown.py new file mode 100644 index 0000000..6f496f8 --- /dev/null +++ b/python_scripts/date_countdown.py @@ -0,0 +1,49 @@ +today = datetime.datetime.now().date() + +name = data.get('name') +type = data.get('type') +sensorName = "sensor.{}_{}".format(type , name.replace(" " , "_")) + +dateStr = data.get('date') +dateSplit = dateStr.split("/") + +dateDay = int(dateSplit[0]) +dateMonth = int(dateSplit[1]) +dateYear = int(dateSplit[2]) +date = datetime.date(dateYear , dateMonth , dateDay) + +thisYear = today.year +nextOccur = datetime.date(thisYear , dateMonth , dateDay) + +numberOfDays = 0 +years = int(thisYear) - dateYear + +if today < nextOccur: + numberOfDays = (nextOccur - today).days + +elif today > nextOccur: + if thisYear > dateYear + 1: + nextOccur = datetime.date(thisYear + 1 , dateMonth , dateDay) + numberOfDays = (nextOccur - today).days + years = years + 1 + else: + nextOccur = datetime.date(dateYear , dateMonth , dateDay) + numberOfDays = (nextOccur - today).days + years = years + 1 + +friendly_name = '' + +if type.lower() == 'birthday': + friendly_name = "{}'s {}".format(name , type) +else: + friendly_name = "{} {}".format(name , type) + +hass.states.set(sensorName , numberOfDays , + { + "icon" : "mdi:calendar-star" , + "unit_of_measurement" : "days" , + "friendly_name" : friendly_name, + "nextoccur" : "{}/{}/{}".format(nextOccur.day , nextOccur.month , nextOccur.year) , + "years" : years + } +) diff --git a/scenes.yaml b/scenes.yaml deleted file mode 100755 index e69de29..0000000 diff --git a/scripts.yaml b/scripts.yaml deleted file mode 100755 index e69de29..0000000