├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── automations.yaml ├── blueprints ├── automation │ ├── automatic_hue_scene.yaml │ ├── homeassistant │ │ ├── motion_light.yaml │ │ └── notify_leaving_zone.yaml │ └── tesla_intelligent_charging.yaml └── script │ └── homeassistant │ └── confirmable_notification.yaml ├── configuration.yaml ├── configuration ├── assistant.yaml ├── climate │ └── genric_thermostat.yaml ├── input_boolean │ └── input_boolean.yaml ├── media_player │ └── media_player.yaml ├── nest.yaml ├── notify │ └── notify.yaml ├── package │ └── day_phase.yaml ├── sensor │ ├── away.yaml │ ├── history.yaml │ ├── system.yaml │ └── template.yaml └── switch │ └── template.yaml └── secrets.yaml.sample /.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | 3 | !blueprints 4 | !configuration 5 | !documentation 6 | 7 | !.gitignore 8 | !.gitpod* 9 | !.travis.yaml 10 | 11 | !automations.yaml 12 | !configuration.yaml 13 | !secrets.yaml.sample 14 | 15 | !LICENSE 16 | !Makefile -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | cache: pip 3 | python: 4 | - "3.5" 5 | install: 6 | - "pip3 install homeassistant" 7 | script: 8 | - "mv secrets.yaml.sample secrets.yaml" 9 | - "touch fullchain.pem" 10 | - "touch privkey.pem" 11 | - "hass --version" 12 | - "ls" 13 | - "hass -c $(pwd) --script check_config | tee check.output" 14 | - '! less check.output | grep -q "Failed config"' 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Home Assistant Config 2 | 3 | [![Build Status](https://travis-ci.org/danrspencer/hass-config.svg?branch=master)](https://travis-ci.org/danrspencer/hass-config) 4 | 5 | My Home Assistant (HA) Config, updated pretty regularly. 6 | 7 | ***-- this document is still very much work in progress --*** 8 | 9 | ## Interesting Bits 10 | - [Workflow / Build Pipeline](#workflow) 11 | - [Day Phase Sensor](#day-phase-sensor) 12 | 13 | ## Workflow / Build Pipeline 14 | 15 | My config is validated by [Travis CI](https://travis-ci.org/danrspencer/hass-config) using the latest version of Home Assistant after each push. HA uses a [sensor](https://github.com/danrspencer/hass-config/blob/master/sensor/misc.yaml) to monitor the Travis build state and sends me notifications of the outcome for each build. 16 | 17 | ![Notification Example](https://github.com/danrspencer/hass-config/blob/master/documentation/images/build-notifications.jpeg) 18 | 19 | After a successful build I use the [Makefile](https://github.com/danrspencer/hass-config/blob/master/Makefile) to push the update to Home Assistant and restart the service. 20 | 21 | *TODO: Create a Hassio addon which can automate updating the config. Then update the notifications for a successful build to provide an actionable "Update and Restart" prompt.* 22 | 23 | ## Day Phase Sensor 24 | 25 | The `Day Phase Sensor` is one of the lynch pins of my HA setup. It uses a combination of time and sun position to decide if the it's currently `Morning`, `Day`, `Evening` or `Night`. This allows me to easily keep automations that rely on the time of day in sync and removes a lot of duplication. 26 | 27 | ```yaml 28 | - platform: template 29 | sensors: 30 | day_phase: 31 | friendly_name: 'Day Phase' 32 | value_template: > 33 | {% if now() > now().replace(hour=5).replace(minute=0).replace(second=0) and 34 | now() < now().replace(hour=9).replace(minute=0).replace(second=0) %} 35 | Morning 36 | {% elif states.sun.sun.state == "above_horizon" %} 37 | Day 38 | {% elif now() < now().replace(hour=22).replace(minute=0).replace(second=0) and 39 | now() > now().replace(hour=9).replace(minute=0).replace(second=0) %} 40 | Evening 41 | {% else %} 42 | Night 43 | {% endif %} 44 | ``` 45 | 46 | [Actual sensor config](https://github.com/danrspencer/hass-config/blob/master/sensor/template.yaml) 47 | 48 | ## Lighting Automations (Philips Hue) 49 | 50 | The `Day Phase Sensor` allows me to keep my lighting automations very simple. For rooms with motion sensors I generally have three basic automations: 51 | 52 | ... 53 | -------------------------------------------------------------------------------- /automations.yaml: -------------------------------------------------------------------------------- 1 | - id: '1618087302165' 2 | alias: Living Room TV - Set to Soundbar 3 | description: '' 4 | trigger: 5 | - platform: state 6 | entity_id: media_player.living_room_tv 7 | attribute: sound_output 8 | for: 0:00:30 9 | - platform: state 10 | entity_id: media_player.living_room_tv 11 | to: 'on' 12 | condition: 13 | condition: not 14 | conditions: 15 | - condition: state 16 | entity_id: media_player.living_room_tv 17 | state: bt_soundbar 18 | attribute: sound_output 19 | action: 20 | - service: webostv.select_sound_output 21 | data: 22 | entity_id: media_player.living_room_tv 23 | sound_output: external_arc 24 | mode: single 25 | - id: '1618094589663' 26 | alias: "\U0001F6E0 Startup Notification" 27 | trigger: 28 | - platform: homeassistant 29 | event: start 30 | action: 31 | - service: notify.dans_devices 32 | data: 33 | message: "Home Assistant back online! \U0001F389\n" 34 | mode: single 35 | - id: '1618094617818' 36 | alias: "\U0001F6E0 Shutdown Notification" 37 | trigger: 38 | - platform: homeassistant 39 | event: shutdown 40 | action: 41 | - service: notify.dans_devices 42 | data: 43 | message: "Home Assistant is going down! \U0001F44B\n" 44 | mode: single 45 | - id: '1625482356250' 46 | alias: Away Mode - Presence Simulation 47 | description: '' 48 | trigger: 49 | - platform: state 50 | entity_id: 51 | - sensor.replay_bedroom 52 | - sensor.replay_dressing_room 53 | - sensor.replay_bedroom_ensuite 54 | - sensor.replay_garden 55 | - sensor.replay_guest_ensuite 56 | - sensor.replay_entrance_hall 57 | - sensor.replay_living_room 58 | condition: 59 | - condition: state 60 | entity_id: input_boolean.away_mode 61 | state: 'on' 62 | action: 63 | - choose: 64 | - conditions: 65 | - condition: template 66 | value_template: '{{ is_state("sun.sun", "below_horizon") }}' 67 | - condition: template 68 | value_template: '{{ trigger.to_state == "on" }} ' 69 | sequence: 70 | - service: hue.hue_activate_scene 71 | data: 72 | group_name: '{{ trigger.entity_id.replace("sensor.replay_","light.") }}' 73 | scene_name: '{{ states.sensor.day_phase.state }}' 74 | default: 75 | - service: light.turn_off 76 | data: 77 | entity_id: '{{ trigger.entity_id.replace("sensor.replay_","light.") }}' 78 | mode: single 79 | - id: '1628502137509' 80 | alias: "\U0001F3E0 Sleep Mode On" 81 | description: '' 82 | trigger: 83 | - platform: time 84 | at: '22:00' 85 | condition: [] 86 | action: 87 | - service: input_boolean.turn_on 88 | target: 89 | entity_id: input_boolean.sleep_mode 90 | data: {} 91 | mode: single 92 | - id: '1658090323476' 93 | alias: "\U0001F6E0 Run Watchman" 94 | description: '' 95 | trigger: 96 | - platform: homeassistant 97 | event: start 98 | condition: [] 99 | action: 100 | - service: watchman.report 101 | data: {} 102 | mode: single 103 | - id: '1676996174224' 104 | alias: "\U0001F697 Manage Intelligent Charging" 105 | description: '' 106 | trigger: 107 | - type: plugged_in 108 | platform: device 109 | device_id: cbc82858929f108b40302fcc67bcc77d 110 | entity_id: binary_sensor.tesla_charger 111 | domain: binary_sensor 112 | condition: 113 | - condition: zone 114 | entity_id: device_tracker.tesla_location_tracker 115 | zone: zone.home 116 | action: 117 | - if: 118 | - condition: template 119 | value_template: '{{ (now() - strptime(states.sensor.tesla_full_battery.state, 120 | ''%Y-%m-%d %H:%M:%S.%f%z'')).days >= 14 }}' 121 | then: 122 | - service: automation.turn_off 123 | data: 124 | stop_actions: true 125 | target: 126 | entity_id: automation.tesla_intelligent_charging 127 | - service: number.set_value 128 | data: 129 | value: '16' 130 | target: 131 | entity_id: number.tesla_charging_amps 132 | - service: number.set_value 133 | data: 134 | value: '100' 135 | target: 136 | entity_id: number.tesla_charge_limit 137 | else: 138 | - service: automation.turn_on 139 | data: {} 140 | target: 141 | entity_id: automation.tesla_intelligent_charging 142 | mode: single 143 | - id: '1676999116232' 144 | alias: "\U0001F419 Home Only Smart Charging" 145 | description: '' 146 | trigger: 147 | - platform: state 148 | entity_id: 149 | - device_tracker.tesla_location_tracker 150 | condition: 151 | - condition: not 152 | conditions: 153 | - condition: or 154 | conditions: 155 | - condition: state 156 | entity_id: device_tracker.tesla_location_tracker 157 | state: unavailable 158 | - condition: state 159 | entity_id: device_tracker.tesla_location_tracker 160 | state: unknown 161 | alias: State Unknown 162 | alias: Not State Unknown 163 | action: 164 | - if: 165 | - condition: zone 166 | entity_id: device_tracker.tesla_location_tracker 167 | zone: zone.home 168 | then: 169 | - service: switch.turn_on 170 | data: {} 171 | target: 172 | entity_id: switch.octopus_smart_charging 173 | else: 174 | - service: switch.turn_off 175 | data: {} 176 | target: 177 | entity_id: switch.octopus_smart_charging 178 | mode: single 179 | - id: '1677146988940' 180 | alias: "\U0001F419 Dehumidify Off Peak" 181 | description: '' 182 | trigger: 183 | - platform: state 184 | entity_id: 185 | - binary_sensor.octopus_intelligent_slot 186 | - platform: time_pattern 187 | minutes: '5' 188 | condition: [] 189 | action: 190 | - if: 191 | - condition: state 192 | entity_id: binary_sensor.octopus_intelligent_slot 193 | state: 'on' 194 | then: 195 | - type: turn_on 196 | device_id: 8cee0df6b6a02ba0be61b4e9058c7449 197 | entity_id: switch.dehumidifier 198 | domain: switch 199 | else: 200 | - type: turn_off 201 | device_id: 8cee0df6b6a02ba0be61b4e9058c7449 202 | entity_id: switch.dehumidifier 203 | domain: switch 204 | mode: single 205 | - id: '1678816456729' 206 | alias: "\U0001F4A1 Bathroom" 207 | description: '' 208 | use_blueprint: 209 | path: motion_dayphase.yaml 210 | input: 211 | motion_entity: binary_sensor.bathroom_sensor_motion 212 | light_target: 213 | entity_id: light.bathroom 214 | - id: '1679074324706' 215 | alias: "\U0001F518 Playroom Button" 216 | description: '' 217 | trigger: 218 | - device_id: a526c8841f0ddce4f0aa71ba6f81dbb7 219 | domain: zha 220 | platform: device 221 | type: remote_button_short_press 222 | subtype: turn_on 223 | - device_id: a526c8841f0ddce4f0aa71ba6f81dbb7 224 | domain: zha 225 | platform: device 226 | type: remote_button_long_release 227 | subtype: dim_up 228 | action: 229 | - if: 230 | - condition: template 231 | value_template: "{{ (states.counter.playroom_button_counter.state | int) > states.scene 232 | \n | map(attribute=\"entity_id\")\n | select(\"match\", \".*playroom.*\")\n 233 | | list | length - 1\n}}\n" 234 | then: 235 | - service: counter.reset 236 | data: {} 237 | target: 238 | entity_id: counter.playroom_button_counter 239 | else: 240 | - service: counter.increment 241 | data: {} 242 | target: 243 | entity_id: counter.playroom_button_counter 244 | - service: hue.activate_scene 245 | data: {} 246 | target: 247 | entity_id: "{{ (states.scene \n | map(attribute=\"entity_id\")\n | select(\"match\", 248 | \".*playroom.*\")\n | list)[(states.counter.playroom_button_counter.state 249 | | int) | int] }}\n" 250 | - delay: 251 | hours: 0 252 | minutes: 2 253 | seconds: 0 254 | milliseconds: 0 255 | - service: hue.activate_scene 256 | data: 257 | transition: 30 258 | target: 259 | entity_id: '{{ "scene.playroom_" ~ states.sensor.day_phase.state }} 260 | 261 | ' 262 | mode: restart 263 | - id: '1680104208576' 264 | alias: "\U0001F697 Tesla Intelligent Charging" 265 | description: '' 266 | use_blueprint: 267 | path: tesla_intelligent_charging.yaml 268 | input: 269 | limit_low: 70 270 | - id: '1680270439426' 271 | alias: "\U0001F419 Dishwasher Autostart" 272 | description: '' 273 | trigger: 274 | - platform: state 275 | entity_id: 276 | - binary_sensor.013030526524018532_bsh_common_status_doorstate 277 | from: 'on' 278 | to: 'off' 279 | - platform: state 280 | entity_id: 281 | - binary_sensor.octopus_intelligent_slot 282 | from: 'off' 283 | to: 'on' 284 | condition: 285 | - condition: state 286 | entity_id: binary_sensor.013030526524018532_bsh_common_status_doorstate 287 | state: 'off' 288 | - condition: state 289 | entity_id: binary_sensor.013030526524018532_bsh_common_status_remotecontrolstartallowed 290 | state: 'on' 291 | - condition: state 292 | entity_id: binary_sensor.octopus_intelligent_slot_next_3_hours 293 | state: 'on' 294 | action: 295 | - service: button.press 296 | data: {} 297 | target: 298 | entity_id: button.013030526524018532_start_pause 299 | mode: single 300 | - id: '1682784582585' 301 | alias: "\U0001F4A1 Toilet" 302 | description: '' 303 | use_blueprint: 304 | path: automatic_hue_scene.yaml 305 | input: 306 | scene_sensor: sensor.day_phase 307 | motion_sensor: binary_sensor.hue_motion_sensor_1_motion_2 308 | hue_group: light.toilet 309 | pre_motion_sensor: binary_sensor.entrance_hall_sensor_motion 310 | no_motion_wait: 2 311 | - id: '1682869286884' 312 | alias: "\U0001F4A1 Playroom" 313 | description: '' 314 | use_blueprint: 315 | path: automatic_hue_scene.yaml 316 | input: 317 | scene_sensor: sensor.day_phase 318 | motion_sensor: binary_sensor.hue_motion_sensor_1_motion 319 | hue_group: light.playroom 320 | pre_motion_sensor: binary_sensor.entrance_hall_sensor_motion 321 | illuminance_sensor: sensor.hue_motion_sensor_1_illuminance 322 | - id: '1682882397419' 323 | alias: "\U0001F4A1 Kitchen" 324 | description: '' 325 | use_blueprint: 326 | path: automatic_hue_scene.yaml 327 | input: 328 | scene_sensor: sensor.day_phase 329 | motion_sensor: binary_sensor.kitchen_composite_motion 330 | hue_group: light.kitchen 331 | no_motion_wait: 10 332 | pre_motion_sensor: binary_sensor.entrance_hall_sensor_motion 333 | - id: '1682882582736' 334 | alias: "\U0001F4A1 Bathroom" 335 | description: '' 336 | use_blueprint: 337 | path: automatic_hue_scene.yaml 338 | input: 339 | scene_sensor: sensor.top_floor_scene 340 | motion_sensor: binary_sensor.bathroom_sensor_motion 341 | pre_motion_sensor: binary_sensor.top_floor_landing_sensor_motion 342 | hue_group: light.bathroom 343 | - id: '1683131674250' 344 | alias: "\U0001F4A1 Top Floor Landing" 345 | description: '' 346 | use_blueprint: 347 | path: automatic_hue_scene.yaml 348 | input: 349 | scene_sensor: sensor.top_floor_scene 350 | motion_sensor: binary_sensor.top_floor_landing_sensor_motion 351 | hue_group: light.top_floor_landing 352 | pre_motion_sensor: binary_sensor.first_floor_landing_sensor_motion 353 | off_duration: 5 354 | - id: '1683146129107' 355 | alias: "\U0001F4A1 Living Room" 356 | description: '' 357 | use_blueprint: 358 | path: automatic_hue_scene.yaml 359 | input: 360 | scene_sensor: sensor.day_phase 361 | hue_group: light.living_room 362 | motion_sensor: binary_sensor.living_room_sensor_motion 363 | pre_motion_sensor: binary_sensor.first_floor_landing_sensor_motion 364 | no_motion_wait: 15 365 | - id: '1683448384347' 366 | alias: "\U0001F4A1 Guest Ensuite" 367 | description: '' 368 | use_blueprint: 369 | path: automatic_hue_scene.yaml 370 | input: 371 | scene_sensor: sensor.day_phase 372 | hue_group: light.guest_room_ensuite 373 | - id: '1683463835179' 374 | alias: "\U0001FAAB Roam Battery" 375 | description: '' 376 | trigger: 377 | - platform: state 378 | entity_id: 379 | - sensor.sonos_roam_battery 380 | condition: 381 | - condition: state 382 | entity_id: sensor.sonos_roam_battery 383 | state: '20' 384 | - condition: state 385 | entity_id: sensor.sonos_roam_battery 386 | state: '10' 387 | action: 388 | - service: notify.phones 389 | data: 390 | message: "Sonos Roam battery is {{ states.sensor.sonos_roam_battery.state }}% 391 | \U0001FAAB\n" 392 | mode: single 393 | - id: '1683464466681' 394 | alias: "\U0001F4A1 Bedroom Ensuite" 395 | description: '' 396 | use_blueprint: 397 | path: automatic_hue_scene.yaml 398 | input: 399 | scene_sensor: sensor.top_floor_scene 400 | hue_group: light.bedroom_ensuite 401 | - id: '1684426956639' 402 | alias: "\U0001F4A1 Harrison’s Room" 403 | description: '' 404 | use_blueprint: 405 | path: automatic_hue_scene.yaml 406 | input: 407 | scene_sensor: sensor.top_floor_scene 408 | hue_group: light.den 409 | off_duration: 10 410 | transition_duration: 60 411 | - id: '1685456564351' 412 | alias: "\U0001F4A1 Bedroom" 413 | description: '' 414 | use_blueprint: 415 | path: automatic_hue_scene.yaml 416 | input: 417 | scene_sensor: sensor.top_floor_scene 418 | hue_group: light.bedroom 419 | - id: '1685457118799' 420 | alias: "\U0001F518 Bedroom Lights On/Off" 421 | description: '' 422 | trigger: 423 | - device_id: 4419b2f4dd290d63dbf4e81500d99ecf 424 | domain: hue 425 | platform: device 426 | type: short_release 427 | subtype: 1 428 | unique_id: c95b29ea-bc1e-491b-9957-e0d8c11cd7b7 429 | condition: [] 430 | action: 431 | - service: automation.trigger 432 | data: 433 | skip_condition: true 434 | target: 435 | entity_id: automation.bedroom 436 | - if: 437 | - condition: state 438 | entity_id: light.bedroom 439 | state: 'off' 440 | then: 441 | - service: automation.trigger 442 | data: 443 | skip_condition: true 444 | target: 445 | entity_id: automation.bedroom 446 | else: 447 | - service: light.turn_off 448 | data: {} 449 | target: 450 | entity_id: light.bedroom 451 | mode: single 452 | - id: '1685724752054' 453 | alias: "\U0001F4A1 Dressing Room" 454 | description: '' 455 | use_blueprint: 456 | path: automatic_hue_scene.yaml 457 | input: 458 | scene_sensor: sensor.top_floor_scene 459 | hue_group: light.dressing_room 460 | no_motion_wait: 15 461 | pre_motion_illuminance_threshold: 1000 462 | - id: '1686061107325' 463 | alias: Test 464 | description: '' 465 | trigger: [] 466 | condition: [] 467 | action: 468 | - service: script.brown_noise_on_roam 469 | data: {} 470 | mode: single 471 | -------------------------------------------------------------------------------- /blueprints/automation/automatic_hue_scene.yaml: -------------------------------------------------------------------------------- 1 | blueprint: 2 | name: Automatic Hue Scenes 3 | description: | 4 | Turn on a light to a specific scene when motion is detected. 5 | 6 | When motion is detected the value of the scene sensor will be used to set the Hue scene in the room. 7 | 8 | e.g. If the scene sensor's value is "movie" and the Hue room is "Living Room" then the scene "scene.living_room_movie" will be applied. 9 | 10 | Trouble shooting: Ensure that your Hue entity names are lined up correctly. If your entity name for your hue group is "light.living_room" but your scenes are "scene.lightroom_scene" then this automation will not work. By default the names should line up but if you have renamed entities in the hue app they can become out of sync. 11 | domain: automation 12 | input: 13 | scene_sensor: 14 | name: Scene Sensor 15 | description: The sensor used to set the scene in the room. If this changes state and the room is on, the room's scene will be updated. 16 | selector: 17 | entity: 18 | domain: sensor 19 | hue_group: 20 | name: Hue Group 21 | description: The hue group entity that will be controlled by this automation. 22 | selector: 23 | entity: 24 | domain: light 25 | motion_sensor: 26 | name: Motion Sensor (Optional) 27 | description: A motion sensor that triggers the automation when motion is detected. If no motion sensor is selected then the automation will instead activate when the lights are turned on manually. 28 | default: null 29 | selector: 30 | entity: 31 | domain: binary_sensor 32 | device_class: motion 33 | no_motion_wait: 34 | name: Wait Time 35 | description: Time to leave the light on after the last motion is detected. If no motion sensor is selected the lights will not turn off automatically. 36 | default: 5 37 | selector: 38 | number: 39 | min: 1 40 | max: 60 41 | unit_of_measurement: minutes 42 | off_duration: 43 | name: Off Duration 44 | description: Time taken for the light to dim to off. A longer duration gives you chance to react if the light starts to turn off when not desired. 45 | default: 10 46 | selector: 47 | number: 48 | min: 1 49 | max: 60 50 | unit_of_measurement: seconds 51 | transition_duration: 52 | name: Transition Duration 53 | description: Time taken for the light to transition to a new scene if the scene changes while the light is on. 54 | default: 5 55 | selector: 56 | number: 57 | min: 1 58 | max: 60 59 | unit_of_measurement: seconds 60 | illuminance_sensor: 61 | name: Light Level Sensor (Optional) 62 | description: Sensor used to check illuminance threshholds 63 | default: null 64 | selector: 65 | entity: 66 | domain: sensor 67 | device_class: illuminance 68 | illuminance_threshold: 69 | name: Illuminance Threshold 70 | description: If the light level is already above this value, don't turn the light on (set to 0 to ignore the light level) 71 | default: 20000 72 | selector: 73 | number: 74 | min: 0 75 | max: 20000 76 | unit_of_measurement: lx 77 | pre_motion_sensor: 78 | name: Pre Lighting Motion Sensor (Optional) 79 | description: A motion sensor that causes the room to be lit dimly before being fully lit by the primary motion sensor. 80 | default: null 81 | selector: 82 | entity: 83 | domain: binary_sensor 84 | device_class: motion 85 | pre_motion_wait: 86 | name: Pre Lighting Wait 87 | description: How long to leave the light on in the pre-lighting state after the pre-lighting sensor detects motion. 88 | default: 30 89 | selector: 90 | number: 91 | min: 1 92 | max: 60 93 | unit_of_measurement: seconds 94 | pre_motion_illuminance_threshold: 95 | name: Pre Illuminance Threshold 96 | description: If the light level is already above this value, don't turn the light on (set to 0 to ignore the light level) 97 | default: 20 98 | selector: 99 | number: 100 | min: 0 101 | max: 2000 102 | unit_of_measurement: lx 103 | pre_motion_brightness: 104 | name: Pre Motion Brightness 105 | description: The brightness level for the pre-lighting state, from 1 (minimum) to 5 (maximum). 106 | default: 1 107 | selector: 108 | number: 109 | min: 1 110 | max: 5 111 | 112 | debug_notifications: 113 | name: Debug Notifications 114 | description: Select a notification service to receive debug messages. 115 | default: null 116 | selector: 117 | entity: 118 | domain: notify 119 | 120 | # If motion is detected within the delay, we restart the script. 121 | mode: restart 122 | max_exceeded: silent 123 | 124 | trigger_variables: 125 | hue_group: !input hue_group 126 | motion_sensor: !input motion_sensor 127 | pre_motion_sensor: !input pre_motion_sensor 128 | 129 | trigger: 130 | - id: motion 131 | platform: template 132 | value_template: "{{ motion_sensor != None and is_state(motion_sensor,'on') }}" 133 | - id: motion_off 134 | platform: template 135 | value_template: "{{ motion_sensor != None and is_state(motion_sensor,'off') }}" 136 | for: 137 | minutes: !input no_motion_wait 138 | - id: pre_motion 139 | platform: template 140 | value_template: "{{ pre_motion_sensor != None and is_state(pre_motion_sensor,'on') }}" 141 | - id: pre_motion_off 142 | platform: template 143 | value_template: "{{ pre_motion_sensor != None and is_state(pre_motion_sensor,'off') }}" 144 | for: 145 | seconds: !input no_motion_wait 146 | - id: scene 147 | platform: state 148 | entity_id: !input scene_sensor 149 | # Triggers when the lights are turned on manually 150 | - id: manual 151 | platform: template 152 | value_template: > 153 | {% set current_time = as_timestamp(now()) %} 154 | {% set recently = current_time - 60 %} 155 | {% set light_entity_ids = state_attr(hue_group, 'lights')  156 | | map('replace', ' ', '_') 157 | | map('lower') 158 | | map('replace', '', 'light.', 1) 159 | %} 160 | {% set lights = namespace(recently_changed=[]) %} 161 | {% for light_id in light_entity_ids %} 162 | {% set last_changed = as_timestamp(states[light_id].last_changed) %} 163 | {% if recently < last_changed %} 164 | {% set lights.recently_changed = lights.recently_changed + [light_id] %} 165 | {% endif %} 166 | {% endfor %} 167 | {{ lights.recently_changed 168 | | map('states') 169 | | select('eq', 'on') 170 | | list 171 | | length > 0 172 | }} 173 | 174 | variables: 175 | hue_group: !input hue_group 176 | scene_sensor: !input scene_sensor 177 | 178 | illuminance_sensor: !input illuminance_sensor 179 | illuminance_threshold: !input illuminance_threshold 180 | 181 | pre_motion_sensor: !input pre_motion_sensor 182 | pre_motion_brightness: !input pre_motion_brightness 183 | pre_motion_illuminance_threshold: !input pre_motion_illuminance_threshold 184 | 185 | scene_entity: > 186 | {{ hue_group | replace("light.", "scene.", 1) ~ "_" ~ states(scene_sensor) }} 187 | 188 | known_scene: > 189 | {{ states(scene_entity) != "unknown" }} 190 | 191 | above_illuminance_threshold: > 192 | {{ illuminance_sensor != None 193 | and illuminance_threshold != 0 194 | and states(illuminance_sensor) | int > illuminance_threshold }} 195 | 196 | above_pre_motion_illuminance_threshold: > 197 | {{ illuminance_sensor != None 198 | and illuminance_threshold != 0 199 | and states(illuminance_sensor) | int > pre_motion_illuminance_threshold }} 200 | 201 | above_pre_motion_brightness: > 202 | {{ state_attr(hue_group, "brightness") | default(0, true) > pre_motion_brightness }} 203 | 204 | condition: 205 | # Block if the trigger was manual and the previous state wasn't unavailable 206 | - not: 207 | - and: 208 | - id: manual 209 | condition: trigger 210 | - "{{ trigger.from_state.state != 'unavailable' }}" 211 | 212 | # Block if the trigger was motion and the lights are already on or above illuminance threshold 213 | - not: 214 | - and: 215 | - id: motion 216 | condition: trigger 217 | - or: 218 | - "{{ above_pre_motion_brightness }}" 219 | - "{{ above_illuminance_threshold }}" 220 | # Block if the trigger was pre_motion and the lights are already on, above illuminance threshold or above pre_motion brightness 221 | - not: 222 | - and: 223 | - id: pre_motion 224 | condition: trigger 225 | - or: 226 | - "{{ states(hue_group) == 'on' }}" 227 | - "{{ above_pre_motion_illuminance_threshold }}" 228 | # Block if the trigger was pre_motion_off and we're above the pre_motion_brightness (e.g. the pre_motion_sensor is no longer in control) 229 | - not: 230 | - and: 231 | - id: pre_motion_off 232 | condition: trigger 233 | - "{{ above_pre_motion_brightness }}" 234 | 235 | action: 236 | - choose: 237 | # Motion Trigger 238 | - conditions: 239 | - id: motion 240 | condition: trigger 241 | - "{{ known_scene }}" 242 | sequence: 243 | - service: hue.activate_scene 244 | target: 245 | entity_id: "{{ scene_entity }}" 246 | # Pre Motion Trigger 247 | - conditions: 248 | - id: pre_motion 249 | condition: trigger 250 | - "{{ known_scene }}" 251 | sequence: 252 | - service: hue.activate_scene 253 | data: 254 | brightness: !input pre_motion_brightness 255 | target: 256 | entity_id: "{{ scene_entity }}" 257 | # Scene 258 | - conditions: 259 | - id: scene 260 | condition: trigger 261 | - "{{ known_scene }}" 262 | sequence: 263 | - if: 264 | - "{{ above_pre_motion_brightness }}" 265 | then: 266 | - service: hue.activate_scene 267 | data: 268 | transition: !input transition_duration 269 | target: 270 | entity_id: "{{ scene_entity }}" 271 | else: 272 | - service: hue.activate_scene 273 | data: 274 | brightness: !input pre_motion_brightness 275 | transition: !input transition_duration 276 | target: 277 | entity_id: "{{ scene_entity }}" 278 | # Turn Off 279 | - conditions: 280 | - or: 281 | - id: motion_off 282 | condition: trigger 283 | - id: pre_motion_off 284 | condition: trigger 285 | - "{{ not known_scene }}" 286 | sequence: 287 | service: light.turn_off 288 | target: 289 | entity_id: !input hue_group 290 | data: 291 | transition: !input off_duration 292 | # Default behavior; for example when the light is turned on manually or the automation is manually triggered 293 | default: 294 | - service: hue.activate_scene 295 | target: 296 | entity_id: "{{ scene_entity }}" 297 | -------------------------------------------------------------------------------- /blueprints/automation/homeassistant/motion_light.yaml: -------------------------------------------------------------------------------- 1 | blueprint: 2 | name: Motion-activated Light 3 | description: Turn on a light when motion is detected. 4 | domain: automation 5 | source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml 6 | input: 7 | motion_entity: 8 | name: Motion Sensor 9 | selector: 10 | entity: 11 | domain: binary_sensor 12 | device_class: motion 13 | light_target: 14 | name: Light 15 | selector: 16 | target: 17 | entity: 18 | domain: light 19 | no_motion_wait: 20 | name: Wait time 21 | description: Time to leave the light on after last motion is detected. 22 | default: 120 23 | selector: 24 | number: 25 | min: 0 26 | max: 3600 27 | unit_of_measurement: seconds 28 | 29 | # If motion is detected within the delay, 30 | # we restart the script. 31 | mode: restart 32 | max_exceeded: silent 33 | 34 | trigger: 35 | platform: state 36 | entity_id: !input motion_entity 37 | from: "off" 38 | to: "on" 39 | 40 | action: 41 | - service: light.turn_on 42 | target: !input light_target 43 | - wait_for_trigger: 44 | platform: state 45 | entity_id: !input motion_entity 46 | from: "on" 47 | to: "off" 48 | - delay: !input no_motion_wait 49 | - service: light.turn_off 50 | target: !input light_target 51 | -------------------------------------------------------------------------------- /blueprints/automation/homeassistant/notify_leaving_zone.yaml: -------------------------------------------------------------------------------- 1 | blueprint: 2 | name: Zone Notification 3 | description: Send a notification to a device when a person leaves a specific zone. 4 | domain: automation 5 | source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml 6 | input: 7 | person_entity: 8 | name: Person 9 | selector: 10 | entity: 11 | domain: person 12 | zone_entity: 13 | name: Zone 14 | selector: 15 | entity: 16 | domain: zone 17 | notify_device: 18 | name: Device to notify 19 | description: Device needs to run the official Home Assistant app to receive notifications. 20 | selector: 21 | device: 22 | integration: mobile_app 23 | 24 | trigger: 25 | platform: state 26 | entity_id: !input person_entity 27 | 28 | variables: 29 | zone_entity: !input zone_entity 30 | # This is the state of the person when it's in this zone. 31 | zone_state: "{{ states[zone_entity].name }}" 32 | person_entity: !input person_entity 33 | person_name: "{{ states[person_entity].name }}" 34 | 35 | condition: 36 | condition: template 37 | value_template: "{{ trigger.from_state.state == zone_state and trigger.to_state.state != zone_state }}" 38 | 39 | action: 40 | domain: mobile_app 41 | type: notify 42 | device_id: !input notify_device 43 | message: "{{ person_name }} has left {{ zone_state }}" 44 | -------------------------------------------------------------------------------- /blueprints/automation/tesla_intelligent_charging.yaml: -------------------------------------------------------------------------------- 1 | blueprint: 2 | domain: automation 3 | name: Tesla Intelligent Charging 4 | description: | 5 | Automatic charging management for your Tesla on when on the Intelligent Octopus tarrif 6 | input: 7 | triggers: 8 | name: Triggers 9 | description: Additional triggers for the reconciliation. 10 | default: 11 | - binary_sensor.tesla_charger 12 | - binary_sensor.tesla_charging 13 | selector: 14 | entity: 15 | integration: tesla_custom 16 | multiple: true 17 | home: 18 | name: Home Location 19 | description: This automation will only run when your car is at home 20 | default: zone.home 21 | selector: 22 | entity: 23 | domain: zone 24 | tracker: 25 | name: Tesla Location Tracker 26 | description: The entity tracking your car's location so we know when it's home 27 | default: device_tracker.tesla_location_tracker 28 | selector: 29 | entity: 30 | domain: device_tracker 31 | integration: tesla_custom 32 | offpeak_start: 33 | name: Off-Peak Start 34 | description: When you are on the cheaper tarrif, even if the car isn't plugged in 35 | default: "23:30:00" 36 | selector: 37 | time: 38 | offpeak_end: 39 | name: Off-Peak End 40 | description: When the cheaper tarrif ends if the car isn't plugged in 41 | default: "05:30:00" 42 | selector: 43 | time: 44 | tesla_battery: 45 | name: Tesla Battery 46 | description: The entity which tracks your car's current battery level 47 | default: sensor.tesla_battery 48 | selector: 49 | entity: 50 | domain: sensor 51 | integration: tesla_custom 52 | tesla_charge_limit: 53 | name: Tesla Charge Limit 54 | description: The entity which tracks your car's current charge limit 55 | default: number.tesla_charge_limit 56 | selector: 57 | entity: 58 | domain: number 59 | integration: tesla_custom 60 | limit_high: 61 | name: Charge Limit High 62 | description: The top limit for charging the car's battery. Used outside of core off-peak hours. 63 | default: 100 64 | selector: 65 | number: 66 | min: 0 67 | max: 100 68 | limit_low: 69 | name: Charge Limit Low 70 | description: The lower limit for the car's battery. We won't charge past this during core off-peak hours. If the car does fall below this level then we will use the high charging amps to attempt to reach the low limit quickly. 71 | default: 60 72 | selector: 73 | number: 74 | min: 0 75 | max: 100 76 | tesla_charging_amps: 77 | name: Tesla Charging Amps 78 | description: The entity which tracks your car's current charging amps 79 | default: number.tesla_charging_amps 80 | selector: 81 | entity: 82 | domain: number 83 | integration: tesla_custom 84 | amps_high: 85 | name: Charging Amps High 86 | description: Used when the battery is below the "Charge Limit Low" to boost your car's battery up 87 | default: 10 88 | selector: 89 | number: 90 | min: 5 91 | max: 16 92 | amps_low: 93 | name: Charging Amps Low 94 | description: Used when the battery is above "Charge Limit Low" 95 | default: 5 96 | selector: 97 | number: 98 | min: 5 99 | max: 10 100 | 101 | variables: 102 | limit_high: !input limit_high 103 | limit_low: !input limit_low 104 | amps_high: !input amps_high 105 | amps_low: !input amps_low 106 | tesla_charge_limit: !input tesla_charge_limit 107 | tesla_charging_amps: !input tesla_charging_amps 108 | 109 | trigger: 110 | - platform: time_pattern 111 | minutes: "/5" 112 | - platform: state 113 | entity_id: !input triggers 114 | 115 | condition: 116 | - condition: zone 117 | entity_id: !input tracker 118 | zone: !input home 119 | 120 | action: 121 | # Set the charge limit 122 | - if: 123 | - condition: time 124 | after: !input offpeak_end 125 | before: !input offpeak_start 126 | then: 127 | - condition: template 128 | value_template: "{{ limit_high | string != states(tesla_charge_limit) }}" 129 | - service: number.set_value 130 | data: 131 | value: !input limit_high 132 | target: 133 | entity_id: !input tesla_charge_limit 134 | 135 | else: 136 | - condition: template 137 | value_template: "{{ limit_low | string != states(tesla_charge_limit) }}" 138 | - service: number.set_value 139 | data: 140 | value: !input limit_low 141 | target: 142 | entity_id: !input tesla_charge_limit 143 | 144 | # Set the charging amps 145 | - if: 146 | - condition: numeric_state 147 | entity_id: !input tesla_battery 148 | below: !input limit_low 149 | then: 150 | - condition: template 151 | value_template: "{{ amps_high | string != states(tesla_charging_amps) }}" 152 | - service: number.set_value 153 | data: 154 | value: !input amps_high 155 | target: 156 | entity_id: !input tesla_charging_amps 157 | else: 158 | - condition: template 159 | value_template: "{{ amps_low | string != states(tesla_charging_amps) }}" 160 | - service: number.set_value 161 | data: 162 | value: !input amps_low 163 | target: 164 | entity_id: !input tesla_charging_amps 165 | mode: single 166 | -------------------------------------------------------------------------------- /blueprints/script/homeassistant/confirmable_notification.yaml: -------------------------------------------------------------------------------- 1 | blueprint: 2 | name: Confirmable Notification 3 | description: >- 4 | A script that sends an actionable notification with a confirmation before 5 | running the specified action. 6 | domain: script 7 | source_url: https://github.com/home-assistant/core/blob/master/homeassistant/components/script/blueprints/confirmable_notification.yaml 8 | input: 9 | notify_device: 10 | name: Device to notify 11 | description: Device needs to run the official Home Assistant app to receive notifications. 12 | selector: 13 | device: 14 | integration: mobile_app 15 | title: 16 | name: "Title" 17 | description: "The title of the button shown in the notification." 18 | default: "" 19 | selector: 20 | text: 21 | message: 22 | name: "Message" 23 | description: "The message body" 24 | selector: 25 | text: 26 | confirm_text: 27 | name: "Confirmation Text" 28 | description: "Text to show on the confirmation button" 29 | default: "Confirm" 30 | selector: 31 | text: 32 | confirm_action: 33 | name: "Confirmation Action" 34 | description: "Action to run when notification is confirmed" 35 | default: [] 36 | selector: 37 | action: 38 | dismiss_text: 39 | name: "Dismiss Text" 40 | description: "Text to show on the dismiss button" 41 | default: "Dismiss" 42 | selector: 43 | text: 44 | dismiss_action: 45 | name: "Dismiss Action" 46 | description: "Action to run when notification is dismissed" 47 | default: [] 48 | selector: 49 | action: 50 | 51 | mode: restart 52 | 53 | sequence: 54 | - alias: "Send notification" 55 | domain: mobile_app 56 | type: notify 57 | device_id: !input notify_device 58 | title: !input title 59 | message: !input message 60 | data: 61 | actions: 62 | - action: "CONFIRM" 63 | title: !input confirm_text 64 | - action: "DISMISS" 65 | title: !input dismiss_text 66 | - alias: "Awaiting response" 67 | wait_for_trigger: 68 | - platform: event 69 | event_type: mobile_app_notification_action 70 | - choose: 71 | - conditions: "{{ wait.trigger.event.data.action == 'CONFIRM' }}" 72 | sequence: !input confirm_action 73 | - conditions: "{{ wait.trigger.event.data.action == 'DISMISS' }}" 74 | sequence: !input dismiss_action 75 | -------------------------------------------------------------------------------- /configuration.yaml: -------------------------------------------------------------------------------- 1 | default_config: 2 | 3 | homeassistant: 4 | packages: !include_dir_merge_named configuration/package 5 | 6 | # Enablers 7 | browser: 8 | cloud: 9 | google_actions: !include configuration/assistant.yaml 10 | alexa: !include configuration/assistant.yaml 11 | config: 12 | conversation: 13 | discovery: 14 | ios: 15 | map: 16 | mobile_app: 17 | homekit: !include configuration/assistant.yaml 18 | logger: 19 | default: info 20 | 21 | # History 22 | recorder: 23 | db_url: !secret db_url 24 | purge_keep_days: 30 25 | exclude: 26 | entities: 27 | - sensor.time 28 | history: 29 | logbook: 30 | exclude: 31 | domains: 32 | - group 33 | entities: 34 | - sensor.time 35 | - sensor.cpu_temp 36 | 37 | # Home Connect Alt 38 | home_connect_alt: 39 | client_id: !secret home_connect_id 40 | client_secret: !secret home_connect_secret 41 | 42 | system_health: 43 | 44 | # Components 45 | automation: !include automations.yaml 46 | binary_sensor: !include_dir_merge_list configuration/binary_sensor 47 | climate: !include_dir_merge_list configuration/climate 48 | input_boolean: !include_dir_merge_named configuration/input_boolean 49 | media_player: !include_dir_merge_list configuration/media_player 50 | nest: !include configuration/nest.yaml 51 | notify: !include_dir_merge_list configuration/notify 52 | scene: !include_dir_merge_list configuration/scene 53 | script: !include scripts.yaml 54 | sensor: !include_dir_merge_list configuration/sensor 55 | switch: !include_dir_merge_list configuration/switch 56 | template: !include_dir_merge_list configuration/template 57 | -------------------------------------------------------------------------------- /configuration/assistant.yaml: -------------------------------------------------------------------------------- 1 | filter: 2 | include_entities: 3 | - camera.back_door 4 | - camera.front_door 5 | - climate.playroom 6 | - climate.house 7 | - climate.tesla 8 | - cover.living_room_blinds 9 | - input_boolean.cinema_mode 10 | - input_boolean.day_phase_day 11 | - input_boolean.day_phase_evening 12 | - input_boolean.day_phase_morning 13 | - input_boolean.day_phase_night 14 | - input_boolean.holiday_mode 15 | - input_boolean.night_shift 16 | - input_boolean.sleep_mode 17 | - media_player.living_room_tv 18 | - media_player.playstation_4 19 | - switch.christmas_tree 20 | - switch.daylight_panel 21 | - switch.hair_straighteners 22 | - switch.living_room_fairy_lights 23 | - switch.oil_heater 24 | - switch.yankee_candle 25 | - switch.brown_noise_on_roam 26 | -------------------------------------------------------------------------------- /configuration/climate/genric_thermostat.yaml: -------------------------------------------------------------------------------- 1 | - platform: generic_thermostat 2 | name: Playroom 3 | heater: switch.fan_heater 4 | target_sensor: sensor.playroom_sensor_temperature 5 | cold_tolerance: 0 6 | hot_tolerance: 0 7 | -------------------------------------------------------------------------------- /configuration/input_boolean/input_boolean.yaml: -------------------------------------------------------------------------------- 1 | away_mode: 2 | name: Away Mode 3 | icon: mdi:exit-run 4 | 5 | sleep_mode: 6 | name: Sleep Mode 7 | icon: mdi:bed 8 | 9 | cinema_mode: 10 | name: Cinema Mode 11 | icon: mdi:video-vintage -------------------------------------------------------------------------------- /configuration/media_player/media_player.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danrspencer/hass-config/bf468e4801844982c00f565339d2adc7294ad3ca/configuration/media_player/media_player.yaml -------------------------------------------------------------------------------- /configuration/nest.yaml: -------------------------------------------------------------------------------- 1 | client_id: !secret nest_client_id 2 | client_secret: !secret nest_client_secret 3 | sensors: 4 | monitored_conditions: 5 | - temperature 6 | - humidity 7 | - target 8 | - operation_mode 9 | - co_status 10 | - smoke_status 11 | - battery_health 12 | binary_sensors: 13 | monitored_conditions: 14 | - online 15 | -------------------------------------------------------------------------------- /configuration/notify/notify.yaml: -------------------------------------------------------------------------------- 1 | - platform: webostv 2 | host: 192.168.0.68 3 | - platform: group 4 | name: "Dans Devices" 5 | services: 6 | - service: mobile_app_dphone 7 | - service: mobile_app_dpad 8 | - platform: group 9 | name: "Phones" 10 | services: 11 | - service: mobile_app_dphone 12 | - service: mobile_app_lphone -------------------------------------------------------------------------------- /configuration/package/day_phase.yaml: -------------------------------------------------------------------------------- 1 | day_phase: 2 | sensor: 3 | - platform: time_date 4 | display_options: 5 | - "time" 6 | - platform: template 7 | sensors: 8 | day_phase: 9 | friendly_name: "Day Phase" 10 | value_template: > 11 | {% if states.input_boolean.day_phase_morning.state == "on" %} 12 | Morning 13 | {% elif states.input_boolean.day_phase_day.state == "on" %} 14 | Day 15 | {% elif states.input_boolean.day_phase_evening.state == "on" %} 16 | Evening 17 | {% elif states.input_boolean.day_phase_night.state == "on" %} 18 | Night 19 | {% else %} 20 | {{ states.sensor.day_phase_real.state }} 21 | {% endif %} 22 | top_floor_scene: 23 | friendly_name: Top Floor Scene 24 | value_template: > 25 | {% set time = now() %} 26 | {% set t0000 = time.replace(hour=0).replace(minute=0).replace(second=0) %} 27 | {% set t1700 = t0000.replace(hour=17) %} 28 | 29 | {% if states.input_boolean.sleep_mode.state == "on" %} 30 | Night 31 | {% elif t1700 < time %} 32 | Evening 33 | {% else %} 34 | {{ states.sensor.day_phase.state }} 35 | {% endif %} 36 | day_phase_real: 37 | friendly_name: "Day Phase Real" 38 | value_template: > 39 | {% set time = now() %} 40 | {% set isDaylight = states.sun.sun.state == "above_horizon" %} 41 | {% set notHoliday = states.input_boolean.holiday_mode.state == "off" %} 42 | {% set isWeekday = time.isoweekday() <= 5 %} 43 | {% set t0000 = time.replace(hour=0).replace(minute=0).replace(second=0) %} 44 | {% set t0600 = t0000.replace(hour=6) %} 45 | {% set t0800 = t0000.replace(hour=8) %} 46 | {% set t1200 = t0000.replace(hour=12) %} 47 | {% set t1600 = t0000.replace(hour=16) %} 48 | {% set t1900 = t0000.replace(hour=19) %} 49 | {% set t2100 = t0000.replace(hour=21) %} 50 | {% set t2200 = t0000.replace(hour=22) %} 51 | 52 | {% if t0600 <= time and time < t0800 %} 53 | Morning 54 | {% elif (t0600 <= time and time < t1600) 55 | or (t0600 <= time and time < t1900 and isDaylight) 56 | %} 57 | Day 58 | {% elif t1600 <= time and time < t2100 %} 59 | Evening 60 | {% else %} 61 | Night 62 | {% endif %} 63 | 64 | input_boolean: 65 | day_phase_morning: 66 | name: Morning 67 | initial: off 68 | icon: mdi:weather-sunset-up 69 | 70 | day_phase_day: 71 | name: Day 72 | initial: off 73 | icon: mdi:weather-sunny 74 | 75 | day_phase_evening: 76 | name: Evening 77 | initial: off 78 | icon: mdi:theme-light-dark 79 | 80 | day_phase_night: 81 | name: Night 82 | initial: off 83 | icon: mdi:weather-night 84 | 85 | holiday_mode: 86 | name: Holiday Mode 87 | initial: off 88 | icon: mdi:human-handsup 89 | 90 | automation: 91 | - alias: Day Phase Overrride Update 92 | trigger: 93 | - entity_id: sensor.day_phase_real 94 | platform: state 95 | action: 96 | - service: input_boolean.turn_on 97 | data_template: 98 | entity_id: > 99 | input_boolean.day_phase_{{ states.sensor.day_phase_real.state | lower }} 100 | 101 | - alias: Day Phase Overrride Reset 102 | trigger: 103 | - entity_id: input_boolean.day_phase_morning 104 | platform: state 105 | to: "off" 106 | - entity_id: input_boolean.day_phase_day 107 | platform: state 108 | to: "off" 109 | - entity_id: input_boolean.day_phase_evening 110 | platform: state 111 | to: "off" 112 | - entity_id: input_boolean.day_phase_night 113 | platform: state 114 | to: "off" 115 | condition: 116 | - condition: state 117 | entity_id: input_boolean.day_phase_morning 118 | state: "off" 119 | - condition: state 120 | entity_id: input_boolean.day_phase_day 121 | state: "off" 122 | - condition: state 123 | entity_id: input_boolean.day_phase_evening 124 | state: "off" 125 | - condition: state 126 | entity_id: input_boolean.day_phase_night 127 | state: "off" 128 | action: 129 | - service: input_boolean.turn_on 130 | data_template: 131 | entity_id: > 132 | input_boolean.day_phase_{{ states.sensor.day_phase_real.state | lower }} 133 | 134 | - alias: Day Phase Override Morning 135 | trigger: 136 | - entity_id: input_boolean.day_phase_morning 137 | platform: state 138 | to: "on" 139 | action: 140 | - service: input_boolean.turn_off 141 | entity_id: input_boolean.day_phase_day 142 | - service: input_boolean.turn_off 143 | entity_id: input_boolean.day_phase_evening 144 | - service: input_boolean.turn_off 145 | entity_id: input_boolean.day_phase_night 146 | 147 | - alias: Day Phase Override Day 148 | trigger: 149 | - entity_id: input_boolean.day_phase_day 150 | platform: state 151 | to: "on" 152 | action: 153 | - service: input_boolean.turn_off 154 | entity_id: input_boolean.day_phase_morning 155 | - service: input_boolean.turn_off 156 | entity_id: input_boolean.day_phase_evening 157 | - service: input_boolean.turn_off 158 | entity_id: input_boolean.day_phase_night 159 | 160 | - alias: Day Phase Override Evening 161 | trigger: 162 | - entity_id: input_boolean.day_phase_evening 163 | platform: state 164 | to: "on" 165 | action: 166 | - service: input_boolean.turn_off 167 | entity_id: input_boolean.day_phase_morning 168 | - service: input_boolean.turn_off 169 | entity_id: input_boolean.day_phase_day 170 | - service: input_boolean.turn_off 171 | entity_id: input_boolean.day_phase_night 172 | 173 | - alias: Day Phase Override Night 174 | trigger: 175 | - entity_id: input_boolean.day_phase_night 176 | platform: state 177 | to: "on" 178 | action: 179 | - service: input_boolean.turn_off 180 | entity_id: input_boolean.day_phase_morning 181 | - service: input_boolean.turn_off 182 | entity_id: input_boolean.day_phase_day 183 | - service: input_boolean.turn_off 184 | entity_id: input_boolean.day_phase_evening 185 | -------------------------------------------------------------------------------- /configuration/sensor/away.yaml: -------------------------------------------------------------------------------- 1 | - platform: history_stats 2 | name: "Replay Entrance Hall" 3 | entity_id: light.entrance_hall 4 | state: "on" 5 | type: count 6 | start: > 7 | {{ as_timestamp(now()) - (7*86400) }} 8 | duration: 00:00:30 9 | 10 | - platform: history_stats 11 | name: "Replay Living Room" 12 | entity_id: light.living_room 13 | state: "on" 14 | type: count 15 | start: > 16 | {{ as_timestamp(now()) - (7*86400) }} 17 | duration: 00:00:30 18 | 19 | - platform: history_stats 20 | name: "Replay Dressing Room" 21 | entity_id: light.dressing_room 22 | state: "on" 23 | type: count 24 | start: > 25 | {{ as_timestamp(now()) - (7*86400) }} 26 | duration: 00:00:30 27 | 28 | - platform: history_stats 29 | name: "Replay Bedroom Ensuite" 30 | entity_id: light.bedroom_ensuite 31 | state: "on" 32 | type: count 33 | start: > 34 | {{ as_timestamp(now()) - (7*86400) }} 35 | duration: 00:00:30 36 | 37 | - platform: history_stats 38 | name: "Replay Bedroom" 39 | entity_id: light.bedroom 40 | state: "on" 41 | type: count 42 | start: > 43 | {{ as_timestamp(now()) - (7*86400) }} 44 | duration: 00:00:30 45 | 46 | - platform: history_stats 47 | name: "Replay Guest Ensuite" 48 | entity_id: light.guest_room_ensuite 49 | state: "on" 50 | type: count 51 | start: > 52 | {{ as_timestamp(now()) - (7*86400) }} 53 | duration: 00:00:30 54 | 55 | - platform: history_stats 56 | name: "Replay Garden" 57 | entity_id: light.garden 58 | state: "on" 59 | type: count 60 | start: > 61 | {{ as_timestamp(now()) - (7*86400) }} 62 | duration: 00:00:30 63 | 64 | - platform: history_stats 65 | name: "Replay Kitchen" 66 | entity_id: light.kitchen 67 | state: "on" 68 | type: count 69 | start: > 70 | {{ as_timestamp(now()) - (7*86400) }} 71 | duration: 00:00:30 72 | 73 | - platform: history_stats 74 | name: "Replay Top Floor Landing" 75 | entity_id: light.top_floor_landing 76 | state: "on" 77 | type: count 78 | start: > 79 | {{ as_timestamp(now()) - (7*86400) }} 80 | duration: 00:00:30 -------------------------------------------------------------------------------- /configuration/sensor/history.yaml: -------------------------------------------------------------------------------- 1 | - platform: history_stats 2 | name: Recent Motion 3 | entity_id: binary_sensor.house_motion 4 | type: count 5 | state: "on" 6 | end: "{{ now() }}" 7 | duration: 8 | minutes: 60 9 | -------------------------------------------------------------------------------- /configuration/sensor/system.yaml: -------------------------------------------------------------------------------- 1 | - platform: systemmonitor 2 | resources: 3 | - type: processor_use 4 | - type: load_1m 5 | - type: load_5m 6 | - type: load_15m 7 | - type: memory_use_percent 8 | - type: disk_use_percent 9 | arg: / 10 | - type: swap_use_percent 11 | - type: network_in 12 | arg: wlan0 13 | - type: network_out 14 | arg: wlan0 15 | 16 | - platform: command_line 17 | name: CPU Temp 18 | command: "cat /sys/class/thermal/thermal_zone0/temp" 19 | unit_of_measurement: "°C" 20 | value_template: "{{ value | multiply(0.001) }}" 21 | 22 | - platform: cpuspeed 23 | -------------------------------------------------------------------------------- /configuration/sensor/template.yaml: -------------------------------------------------------------------------------- 1 | - platform: template 2 | sensors: 3 | lights_on: 4 | friendly_name: "Lights On" 5 | unit_of_measurement: "Count" 6 | value_template: > 7 | {{ states.light 8 | | selectattr('state', 'eq', 'on') 9 | | rejectattr('attributes.is_hue_group') 10 | | list 11 | | count 12 | }} 13 | rooms_on: 14 | friendly_name: "Rooms On" 15 | unit_of_measurement: "Count" 16 | value_template: > 17 | {{ states.light 18 | | selectattr('state', 'eq', 'on') 19 | | selectattr('attributes.is_hue_group') 20 | | list 21 | | count 22 | }} 23 | -------------------------------------------------------------------------------- /configuration/switch/template.yaml: -------------------------------------------------------------------------------- 1 | - platform: template 2 | switches: 3 | brown_noise_on_roam: 4 | value_template: | 5 | {{ 6 | is_state("media_player.sonos_roam", "playing") and 7 | "brown-noise-cold-plunge.mp3" in state_attr("media_player.sonos_roam", "media_content_id") 8 | }} 9 | turn_on: 10 | service: script.brown_noise_on_roam 11 | turn_off: 12 | service: media_player.media_pause 13 | target: 14 | entity_id: media_player.sonos_roam 15 | -------------------------------------------------------------------------------- /secrets.yaml.sample: -------------------------------------------------------------------------------- 1 | hass_base_url: something.somewhere.outthere 2 | hass_password: xxxxxxxxxx 3 | 4 | # In here for CI purposes 5 | ssl_certificate: fullchain.pem 6 | ssl_key: privkey.pem 7 | 8 | db_url: mysql://user:password@SERVER_IP/DB_NAME?charset=utf8 9 | 10 | influx_host: xxxxxxxxxx 11 | influx_user: xxxxxxxxxx 12 | influx_pass: xxxxxxxxxx 13 | 14 | aws_access_key_id: xxxxxxxxxx 15 | aws_secret_access_key: xxxxxxxxxx 16 | 17 | nest_client_id: xxxxxxxxxx 18 | nest_client_secret: xxxxxxxxxx 19 | 20 | ring_username: xxxxxxxxxx 21 | ring_password: xxxxxxxxxx 22 | 23 | dyson_username: xxxxxxxxxx 24 | dyson_password: xxxxxxxxxx 25 | dyson_serial: xxxxxxxxxx 26 | 27 | spotify_client_id: xxxxxxxxxx 28 | spotify_client_secret: xxxxxxxxxx 29 | 30 | metoffice_key: xxxxxxxxxx 31 | darksky_key: xxxxxxxxxx 32 | openweathermap_key: xxxxxxxxxx 33 | 34 | transportapi_app_id: xxxxxxxxxx 35 | transportapi_key: xxxxxxxxxx 36 | 37 | # Zones 38 | zone_home_lat: 1.0000 39 | zone_home_long: 1.0000 40 | 41 | zone_d_work_lat: 1.0000 42 | zone_d_work_long: 1.0000 43 | 44 | zone_l_work_lat: 1.0000 45 | zone_l_work_long: 1.0000 46 | 47 | # Devices 48 | lauren_profile: http://graph.facebook.com/xxxxxxxxxx/picture?type=square 49 | dan_profile: http://graph.facebook.com/xxxxxxxxxx/picture?type=square 50 | dphone_mac: 00:00:00:00:00:00 51 | laurens_iphone_mac: 00:00:00:00:00:00 52 | 53 | # Hassio 54 | ssh_pub_key: xxxxxxxxxx 55 | --------------------------------------------------------------------------------