diff --git a/README.md b/README.md index 05a047f..858c86c 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Configuration for Home Assistant running Hass.io on a Raspberry Pi for a one bed - **Nanoleaf Aurora control**: + Manual theme selection. + Automatically rotate through device-based themes based on time of day (unless manually selected above). -- **LIFX Z ceiling wash lights control**: +- **LIFX Z under bed and ceiling wash lights control**: + Manual theme selection. + Automatically rotate through cloud-based themes based on time of day (unless manually selected above). - **Automatically correlated color temperature (CCT)**, for [f.lux](https://justgetflux.com/)-like white temperature shift to gradually remove blue light based on a custom color and brightness curve and preset active hours, not simply based on the sun otherwise Canadian winters would be pretty yellow. @@ -84,10 +84,12 @@ Configuration for Home Assistant running Hass.io on a Raspberry Pi for a one bed ### Task list #### Work in progress +- Device: Kitchen under-cabinet CCT lighting +- Device: Flic button (kitchen) #### Backlog - UI: Text-only state cards (weather, quotes...) -- Component: fix unlimited bandwidth consumption bug +- Component: Fix unlimited bandwidth consumption bug - Scene: Romantic - Scene: Gaming/Party - Automation: Away mode @@ -98,16 +100,16 @@ Configuration for Home Assistant running Hass.io on a Raspberry Pi for a one bed - Contribute back: HADashboard widget optimizations #### Wishlist -- Dashboard: context-aware link widgets +- Dashboard: Context-aware link widgets - Automation: Welcome home theme song front door trigger - Automation: Door/Window sensor temper alert +- Component: Airthings BLE custom component +- Component: Monitor indoor air quality - Component: UPS monitoring - Component: Read rooftop weather station (Fine Offset WH1080) -- Network: use USB gigabit connection to test for above 80MB/s downspeeds +- Device: Use USB gigabit connection to test for above 80MB/s downspeeds +- Device: Replace Wifi plug-in outlets with Z-Wave for stability - Device: Increase nightlight movement detection coverage -- Device: LIFX Z strips under bed with dedicated scenes. How romantic! -- Device: Kitchen under-cabinet CCT lighting -- Device: Flic button (kitchen) - Device: Window binary sensors/state overview - Device: Indoor air quality sensing and report - Device: Exterior light @@ -137,12 +139,15 @@ Configuration for Home Assistant running Hass.io on a Raspberry Pi for a one bed - **[Aeotec Z-Stick Gen5](https://aeotec.com/z-wave-usb-stick)** Z-Wave USB dongle. - **[NooElec NESDR SMArt](http://www.nooelec.com/store/nesdr-smart.html)** RTL-SDR (software-defined radio) USB dongle for reading AcuRite sensors. - **[Plugable USB Bluetooth Adapter](https://plugable.com/products/usb-bt4le/)** for Bluetooth Low Energy connections. +- **[Milight iBox2 Wifi Bridge](https://www.futlight.com/productdetails.aspx?id=239&typeid=125)** for kitchen RF LED strip controllers, using [LimitlessLED](https://home-assistant.io/components/light.limitlessled/) integration. - **[Acer Iconia One 10" tablet](https://www.acer.com/ac/en/CA/content/series/iconiaone10)** (1280x800 IPS screen) wallmounted as a kiosk. ### Devices and sensors - **[Nanoleaf Aurora](https://nanoleaf.me/en-ca/)** light panels kit. Pretty! - **[LIFX+](https://www.lifx.com/products/lifx-plus)** A19 RGB light bulb (x2). -- **[LIFX Z](https://www.lifx.com/products/lifx-z-starter-kit-without-homekit)** light strip without HomeKit as ceiling wash lights (x3). +- **[LIFX Z](https://www.lifx.com/products/lifx-z-starter-kit-without-homekit)** light strip without HomeKit as ceiling wash lights (x3) and bed underglow (x2) +- **[Milight CCT LED RF Controller](https://www.futlight.com/productdetails.aspx?id=293&typeid=146)** for white-adjustable undercabinet kitchen lights (x4), connected to appropriate Ul-listed power supplies. +- **[24V 3014 Warm White Cool White LED Strip](http://ledmontreal.com/en/led-strips-without-accessories/24v-led-strips-without-accessories/cct-adjustable-led-strip.html)** encased in custom cut and assembled [light-diffusing aluminum profiles](http://ledmontreal.com/en/led-bars-and-profiles-led-montreal/continuous-lighting-aluminum-profile.html), connected to above RF controllers. - **[Flic](https://flic.io/)** bluetooth low energy button. - **[Aeotec Door / Window Sensor Gen5](https://aeotec.com/z-wave-door-window-sensor)** for front door. - **[Aeotec MultiSensor 6](https://aeotec.com/z-wave-sensor)** for temperature/humidity/presence detection. diff --git a/appdaemon/dashboards/Status.dash b/appdaemon/dashboards/Status.dash index 232775d..b12e2b4 100644 --- a/appdaemon/dashboards/Status.dash +++ b/appdaemon/dashboards/Status.dash @@ -160,6 +160,46 @@ downspeed: color: white title2_style: "font-size: x-small;" +# +# Battery +# +front_door_sensor_battery: + widget_type: gauge + entity: sensor.front_door_sensor_battery + min: 0 + max: 100 + units: "%" + title: Front Door Sensor Battery + color: white + low_color: FF0000 + med_color: FFFF00 + high_color: 00FF00 + +bedroom_multisensor_battery: + widget_type: gauge + entity: sensor.bedroom_multisensor_battery + min: 0 + max: 100 + units: "%" + title: Bedroom Sensor Battery + color: white + low_color: FF0000 + med_color: FFFF00 + high_color: 00FF00 + +lounge_multisensor_battery: + widget_type: gauge + entity: sensor.lounge_multisensor_battery + min: 0 + max: 100 + units: "%" + title: Lounge Sensor Battery + color: white + low_color: FF0000 + med_color: FFFF00 + high_color: 00FF00 + + # # Layout # @@ -169,5 +209,5 @@ layout: - nav_switchboard, uptime, uptime_host, database_size, logfile_size - nav_weather, cpu_temp, cpu_used, ram_used, disk_used, spacer(2x1), sensor.speedtest_ping, upspeed, downspeed - nav_spacer(1x2) - - sensor.bedroom_temperature, sensor.bedroom_humidity - - nav_status, sensor.lounge_temperature, sensor.lounge_humidity + - sensor.bedroom_temperature, sensor.lounge_temperature, spacer(4x1), front_door_sensor_battery, bedroom_multisensor_battery, lounge_multisensor_battery + - nav_status, sensor.bedroom_humidity, sensor.lounge_humidity diff --git a/appdaemon/dashboards/Switchboard.dash b/appdaemon/dashboards/Switchboard.dash index 23b2fca..725c073 100644 --- a/appdaemon/dashboards/Switchboard.dash +++ b/appdaemon/dashboards/Switchboard.dash @@ -150,20 +150,30 @@ label_kitchen: title2_style: "font-size:175%;font-weight:400;" light_countertop: - widget_type: label + widget_type: light title: Countertop + entity: light.countertop widget_style: "background-color:SADDLEBROWN;" light_island: - widget_type: label + widget_type: light title: Island + entity: light.island widget_style: "background-color:SADDLEBROWN;" -light_cupboard: - widget_type: label - title: Cupboard +light_microwave: + widget_type: light + title: Microwave + entity: light.microwave + widget_style: "background-color:SADDLEBROWN;" + +light_sink: + widget_type: light + title: Sink + entity: light.sink widget_style: "background-color:SADDLEBROWN;" + # # Washroom # @@ -201,6 +211,27 @@ label_bedroom: widget_style: "background-color:INDIGO;" title2_style: "font-size:175%;font-weight:400;" +light_bed_effect: + widget_type: input_select + title2: Bed Effect + entity: input_select.bed_effect + sub_entity: sensor.bed_effect_loaded + widget_style: "background-color:INDIGO;" + state_text_style: "background-color:PURPLE;" + select_style: "background-color:PURPLE;color:$white;" + +light_headboard: + widget_type: light + title: Headboard + entity: light.headboard + widget_style: "background-color:INDIGO;" + +light_underbed: + widget_type: light + title: Underbed + entity: light.underbed + widget_style: "background-color:INDIGO;" + light_bedside: widget_type: switch title: Bedside @@ -213,16 +244,6 @@ light_nightstand: entity: switch.nightstand_light widget_style: "background-color:INDIGO;" -light_headboard: - widget_type: label - title: Headboard - widget_style: "background-color:INDIGO;" - -light_underbed: - widget_type: label - title: Underbed - widget_style: "background-color:INDIGO;" - fan_bedroom: widget_type: switch title: Fan @@ -270,9 +291,9 @@ light_spotlight: entity: light.spotlight widget_style: "background-color:DARKRED;" -light_torch: +light_lamp: widget_type: label - title: Torch + title: Lamp widget_style: "background-color:DARKRED;" light_souvenirs: @@ -320,7 +341,7 @@ layout: - include: header - nav_main, label(6x1), reload, temperature, clock - nav_switchboard, spacer, label_exterior, light_front_door, spacer(2x1), label_ceiling, washlight_bedroom, washlight_middle, washlight_lounge - - nav_weather, label_kitchen, light_island, spacer, label_washroom, light_shower, spacer, label_climate, switch_air_filter - - nav_spacer(1x2), light_cupboard, light_countertop, spacer, light_lavatory, spacer(2x1), switch_dehumidifier, switch_humidifier - - label_bedroom, light_nightstand, light_bedside, spacer_tetris, label_lounge, light_tv_backlight, light_aurora, light_aurora_effect - - nav_status, fan_bedroom, light_headboard, light_underbed, spacer, light_spotlight, light_souvenirs, light_window, light_torch + - nav_weather, label_kitchen, light_microwave, spacer, label_washroom, light_shower, spacer, label_climate, switch_air_filter + - nav_spacer(1x2), light_island, light_sink, light_countertop, spacer, light_lavatory, spacer, switch_dehumidifier, switch_humidifier + - label_bedroom, light_bed_effect, light_headboard, light_underbed, spacer_tetris, label_lounge, light_aurora_effect, light_aurora, light_tv_backlight + - nav_status, light_nightstand, light_bedside, fan_bedroom, spacer(2x1), light_spotlight, light_souvenirs, light_window, light_lamp diff --git a/appdaemon/dashboards/Weather.dash b/appdaemon/dashboards/Weather.dash index 42deb4d..d6613f1 100644 --- a/appdaemon/dashboards/Weather.dash +++ b/appdaemon/dashboards/Weather.dash @@ -273,4 +273,4 @@ layout: - nav_weather, wind_icon, weekly_forecast(2x1) - nav_spacer(1x2), spacer, temperature_today, weather_icon_today - spacer, spacer(6x1), temperature_tomorrow, weather_icon_tomorrow - - nav_status, aqi, aqi_particles, aqi_ozone, aqi_carbon_monoxide, aqi_nitrogen_dioxide, uv, spacer, temperature_after_tomorrow, weather_icon_after_tomorrow + - nav_status, uv, aqi, aqi_particles, aqi_ozone, aqi_carbon_monoxide, aqi_nitrogen_dioxide, spacer, temperature_after_tomorrow, weather_icon_after_tomorrow diff --git a/automations/aurora_brightness.yaml b/automations/aurora_brightness.yaml new file mode 100644 index 0000000..6560304 --- /dev/null +++ b/automations/aurora_brightness.yaml @@ -0,0 +1,15 @@ +# +# Change Nanoleaf Aurora's brightness. +# +- id: aurora_brightness + alias: Aurora BRIGHTNESS + trigger: + # When a brightness level is changed. + - platform: state + entity_id: variable.aurora_brightness + + action: + - service: light.turn_on + data_template: + entity_id: light.aurora + brightness: "{{ states('variable.aurora_brightness') }}" diff --git a/automations/aurora_default.yaml b/automations/aurora_default.yaml new file mode 100644 index 0000000..0d091e8 --- /dev/null +++ b/automations/aurora_default.yaml @@ -0,0 +1,20 @@ +# +# Return the Aurora to its default scheduled effect. +# +- id: aurora_default + alias: Aurora DEFAULT + trigger: + # If the default effect is selected. + - platform: state + entity_id: input_select.aurora_effect + to: Auto + + action: + - service: notify.group + data: + title: 'Hass.io' + message: "aurora_select reset: {{ states('input_select.aurora_effect') }}" + + # Remove the Aurora effect override. + - service: input_boolean.turn_off + entity_id: input_boolean.aurora_effect_override diff --git a/automations/aurora_effect.yaml b/automations/aurora_effect.yaml index d33332d..8cd929a 100644 --- a/automations/aurora_effect.yaml +++ b/automations/aurora_effect.yaml @@ -1,54 +1,16 @@ +# # Change Nanoleaf Aurora based on its loaded-in effects. +# - id: aurora_effect - alias: Apply Aurora effect + alias: Aurora EFFECT trigger: - # When an effect is received via MQTT. + # When an effect is changed. - platform: state - entity_id: sensor.aurora_effect + entity_id: variable.aurora_effect action: - - service: notify.group - data: - title: 'Hass.io' - message: "aurora_effect received: {{ states('sensor.aurora_effect') }}" - - service: light.turn_on data_template: entity_id: - light.aurora - effect: "{{ states('sensor.aurora_effect') }}" - - # - service: light.turn_on - # data: - # entity_id: light.aurora - - # - service: rest_command.aurora_set_effect - # data_template: - # name: "{{ states('sensor.aurora_effect') }}" - -# Change Nanoleaf Aurora's brightness. -- id: aurora_brightness - alias: Apply Nanoleaf Aurora brightness - trigger: - # When a brightness level is received via MQTT. - - platform: state - entity_id: sensor.aurora_brightness - - action: - - service: notify.group - data: - title: 'Hass.io' - message: "aurora_brightness received: {{ states('sensor.aurora_brightness') }}" - - - delay: - seconds: 5 - - - service: light.turn_on - data_template: - entity_id: light.aurora - brightness: "{{ states('sensor.aurora_brightness') }}" - - # - service: rest_command.aurora_set_brightness - # data_template: - # brightness: "{{ states('sensor.aurora_brightness') }}" - + effect: "{{ states('variable.aurora_effect') }}" diff --git a/automations/aurora_schedule.yaml b/automations/aurora_schedule.yaml index 2ab7a63..2f4cc95 100644 --- a/automations/aurora_schedule.yaml +++ b/automations/aurora_schedule.yaml @@ -1,13 +1,14 @@ +# # Schecule the Nanoleaf Aurora based on its loaded-in effects. +# # see: https://forum.nanoleaf.me/docs/openapi +# - id: aurora_schedule - alias: Rotate Aurora based on a schedule - initial_state: 'on' + alias: Aurora SCHEDULE trigger: # Every hour on the hour. - platform: time - # minutes: 00 - minutes: /5 + minutes: 00 seconds: 00 # When an item which was off or physically disconnected comes back online. @@ -16,11 +17,6 @@ - light.aurora from: 'off' - # When alerts are disabled. - - platform: state - entity_id: input_boolean.alert_mode - to: 'off' - # When scenes are disabled. - platform: state entity_id: input_boolean.scene_mode @@ -32,26 +28,24 @@ to: 'off' condition: + # If automation was not trigered lately. + - condition: template + value_template: >- + {% set current = as_timestamp(utcnow()) %} + {% set last_triggered = as_timestamp(states.automation.aurora_schedule.attributes.last_triggered) | float %} + + {{ current - last_triggered > 1}} + # If the Aurora is active. - condition: state entity_id: light.aurora state: 'on' - # If no other process is handling the Aurora. - - condition: state - entity_id: input_boolean.aurora_semaphore - state: 'off' - # If no effect overrides are in place. - condition: state entity_id: input_boolean.aurora_effect_override state: 'off' - # If no alerts are enabled. - - condition: state - entity_id: input_boolean.alert_mode - state: 'off' - # If no scenes are enabled. - condition: state entity_id: input_boolean.scene_mode @@ -68,61 +62,78 @@ state: 'off' action: - # Reserve the Aurora. - - service: input_boolean.turn_on - entity_id: input_boolean.aurora_semaphore - - # Send the effect update via Mosquitto. - - service: mqtt.publish - data_template: - topic: 'home/aurora/effect' - payload: >- + # Update the effect variable. + - service: variable.set_variable + data: + variable: aurora_effect + value_template: >- {% set hour = states('sensor.time').split(':')[0] %} - {% set effects = { - '00':{'brightness':'35', 'name':'Be Productive'}, - '01':{'brightness':'30', 'name':'Canada Day'}, - '02':{'brightness':'25', 'name':'Color Burst'}, - '03':{'brightness':'20', 'name':'Fifty shades'}, - '04':{'brightness':'20', 'name':'Flames'}, - '05':{'brightness':'25', 'name':'Forest'}, - - '06':{'brightness':'45', 'name':'Inner Peace'}, - '07':{'brightness':'60', 'name':'Movie Night'}, - '08':{'brightness':'75', 'name':'Nemo'}, - '09':{'brightness':'80', 'name':'Northern Lights'}, - '10':{'brightness':'85', 'name':'Rain'}, - '11':{'brightness':'90', 'name':'Retro Future'}, - - '12':{'brightness':'100','name':'Romantic'}, - '13':{'brightness':'90', 'name':'Serve warm and chilled'}, - '14':{'brightness':'85', 'name':'Snowfall'}, - '15':{'brightness':'80', 'name':'Stranger Things'}, - '16':{'brightness':'75', 'name':'Synthwave'}, - '17':{'brightness':'70', 'name':'Tron Legacy'}, - - '18':{'brightness':'65', 'name':'Tron2'}, - '19':{'brightness':'60', 'name':'Vibrant Sunrise'}, - '20':{'brightness':'55', 'name':'Inner Peace'}, - '21':{'brightness':'50', 'name':'Nemo'}, - '22':{'brightness':'45', 'name':'Flames'}, - '23':{'brightness':'40', 'name':'Retro Future'} + {% set schedule = { + '00': 'Be Productive', + '01': 'Canada Day', + '02': 'Color Burst', + '03': 'Fifty shades', + '04': 'Flames', + '05': 'Forest', + + '06': 'Inner Peace', + '07': 'Movie Night', + '08': 'Nemo', + '09': 'Northern Lights', + '10': 'Rain', + '11': 'Retro Future', + + '12': 'Romantic', + '13': 'Serve warm and chilled', + '14': 'Snowfall', + '15': 'Stranger Things', + '16': 'Synthwave', + '17': 'Tron Legacy', + + '18': 'Tron2', + '19': 'Vibrant Sunrise', + '20': 'Inner Peace', + '21': 'Nemo', + '22': 'Flames', + '23': 'Retro Future', } %} - { - "name": "{{ effects[hour]['name'] }}", - "brightness": "{{ effects[hour]['brightness'] }}" - } + {{ schedule[hour] }} - # Notify the owner. - # - service: notify.group - # data: - # title: 'Hass.io' - # message: "aurora effects sent." - - # Pause a while, to minimize race conditions. - - delay: - seconds: 5 + # Update the brightness variable. + - service: variable.set_variable + data: + variable: aurora_brightness + value_template: >- + {% set hour = states('sensor.time').split(':')[0] %} + {% set schedule = { + '00': '35', + '01': '30', + '02': '25', + '03': '20', + '04': '20', + '05': '25', + + '06': '45', + '07': '60', + '08': '75', + '09': '80', + '10': '85', + '11': '95', + + '12': '100', + '13': '100', + '14': '95', + '15': '90', + '16': '85', + '17': '80', + + '18': '75', + '19': '70', + '20': '65', + '21': '60', + '22': '55', + '23': '50', + } %} - # Release the Aurora. - - service: input_boolean.turn_off - entity_id: input_boolean.aurora_semaphore + {{ schedule[hour] }} diff --git a/automations/aurora_select.yaml b/automations/aurora_select.yaml index 5432b2a..3201797 100644 --- a/automations/aurora_select.yaml +++ b/automations/aurora_select.yaml @@ -1,16 +1,14 @@ +# # Manually select a Nanoleaf Aurora loaded-in effect. +# - id: aurora_select - alias: Select Aurora effect + alias: Aurora SELECT trigger: + # An effect has been selected. - platform: state entity_id: input_select.aurora_effect condition: - # If no other process is handling the Aurora. - - condition: state - entity_id: input_boolean.aurora_semaphore - state: 'off' - # If an actual effect is selected. - condition: template value_template: "{% if not is_state('input_select.aurora_effect', 'Auto') %}true{% endif %}" @@ -21,50 +19,26 @@ title: 'Hass.io' message: "aurora_select sent: {{ states('input_select.aurora_effect') }}" - # Reserve the Aurora. - - service: input_boolean.turn_on - entity_id: input_boolean.aurora_semaphore - # Override the Aurora effect. - service: input_boolean.turn_on entity_id: input_boolean.aurora_effect_override - # Send the effect update via Mosquitto. - - service: mqtt.publish - data_template: - topic: 'home/aurora/effect' - payload: >- - { - "name": "{{ states('input_select.aurora_effect') }}" - } - - # Release the Aurora. - - service: input_boolean.turn_off - entity_id: input_boolean.aurora_semaphore - -# Return the aurora to its default scheduled effect. -- id: aurora_default - alias: Default Nanoleaf Aurora effect - trigger: - - platform: state - entity_id: input_select.aurora_effect - to: Auto - - action: - - service: notify.group + # Update the effect variable. + - service: variable.set_variable data: - title: 'Hass.io' - message: "aurora_select reset: {{ states('input_select.aurora_effect') }}" + variable: aurora_effect + value_template: >- + {{ states('input_select.aurora_effect') }} - # Remove the Aurora effect override. - - service: input_boolean.turn_off - entity_id: input_boolean.aurora_effect_override +# # Todo convert into AppDeamon because set_options doesn't understand templates. +# # see: https://pypkg.com/pypi/homeassistant/f/homeassistant/components/input_select.py # see: https://home-assistant.io/cookbook/automation_kodi_dynamic_input_select/ +# # - id: aurora_effects_list -# alias: List aurora effects +# alias: Aurora effects list # trigger: # # Every five minutes. # - platform: time diff --git a/automations/bed_default.yaml b/automations/bed_default.yaml new file mode 100644 index 0000000..7dcf7d2 --- /dev/null +++ b/automations/bed_default.yaml @@ -0,0 +1,15 @@ +# +# Return the bed washlights to the default scheduled effect. +# +- id: bed_default + alias: Bed DEFAULT + trigger: + # If the default effect is selected. + - platform: state + entity_id: input_select.bed_effect + to: Auto + + action: + # Remove the effect override. + - service: input_boolean.turn_off + entity_id: input_boolean.bed_effect_override diff --git a/automations/bed_effect.yaml b/automations/bed_effect.yaml new file mode 100644 index 0000000..a75f869 --- /dev/null +++ b/automations/bed_effect.yaml @@ -0,0 +1,28 @@ +# +# Change bed wash lights based on Lifx Cloud scenes. +# +- id: bed_effect + alias: Bed EFFECT + trigger: + # When an effect is changed. + - platform: state + entity_id: variable.bed_effect + + action: + # Send the effect's UUID to the Lifx Cloud scenes service. + - service: shell_command.activate_lifx_cloud_scene + data_template: + uuid: >- + {% set effects = { + 'Neon': '2910cd6c-1644-4b6b-b2bf-8eb26f254288', + 'Reading': '444b1097-1e26-40f7-a1a8-7f68a161550c', + 'Relaxing': '48c32539-48f8-4bcc-826a-e88b2b0c9b8e', + 'Warming': '33975782-8725-4b27-a96b-d87018da999b', + } %} + {% set selected = states('variable.bed_effect') %} + + {% if effects[selected] %} + {{ effects[selected] }} + {% endif %} + duration: 5 + key: !secret lifx_cloud_token diff --git a/automations/bed_schedule.yaml b/automations/bed_schedule.yaml new file mode 100644 index 0000000..cad9682 --- /dev/null +++ b/automations/bed_schedule.yaml @@ -0,0 +1,106 @@ +# +# Schedule bed wash lights based on Lifx Cloud scenes. +# +# see: https://api.developer.lifx.com/docs/activate-scene +# +- id: bed_schedule + alias: Bed SCHEDULE + trigger: + # Every hour on the hour. + - platform: time + minutes: 00 + seconds: 00 + + # When Home Assistant starts. + - platform: homeassistant + event: start + + # When an item which was off comes back online. + - platform: state + entity_id: + - light.headboard + - light.underbed + to: 'on' + + # When scenes are disabled. + - platform: state + entity_id: input_boolean.scene_mode + to: 'off' + + # When bed washlight effect override is being released. + - platform: state + entity_id: input_boolean.bed_effect_override + to: 'off' + + condition: + # If automation was not trigered lately. + - condition: template + value_template: >- + {% set current = as_timestamp(utcnow()) %} + {% set last_triggered = as_timestamp(states.automation.bed_schedule.attributes.last_triggered) | float %} + + {{ current - last_triggered > 1}} + + # If bed lights are on. + - condition: state + entity_id: group.bed + state: 'on' + + # If no effect overrides are in place. + - condition: state + entity_id: input_boolean.bed_effect_override + state: 'off' + + # If no scenes are enabled. + - condition: state + entity_id: input_boolean.scene_mode + state: 'off' + + # Not during the night mode. + - condition: state + entity_id: input_boolean.night_mode + state: 'off' + + # Not during the nap mode. + - condition: state + entity_id: input_boolean.nap_mode + state: 'off' + + action: + # Update the effect variable. + - service: variable.set_variable + data: + variable: bed_effect + value_template: >- + {% set hour = states('sensor.time').split(':')[0] %} + {% set schedule = { + '00': 'Neon', + '01': 'Warming', + '02': 'Relaxing', + '03': 'Neon', + '04': 'Warming', + '05': 'Relaxing', + + '06': 'Neon', + '07': 'Warming', + '08': 'Relaxing', + '09': 'Neon', + '10': 'Warming', + '11': 'Relaxing', + + '12': 'Neon', + '13': 'Warming', + '14': 'Relaxing', + '15': 'Neon', + '16': 'Warming', + '17': 'Relaxing', + + '18': 'Neon', + '19': 'Warming', + '20': 'Relaxing', + '21': 'Neon', + '22': 'Warming', + '23': 'Relaxing', + } %} + + {{ schedule[hour] }} diff --git a/automations/bed_select.yaml b/automations/bed_select.yaml new file mode 100644 index 0000000..589b4d0 --- /dev/null +++ b/automations/bed_select.yaml @@ -0,0 +1,26 @@ +# +# Manually select a LIFX cloud effect for the bed washlights. +# +- id: bed_select + alias: Bed SELECT + trigger: + # An effect has been selected. + - platform: state + entity_id: input_select.bed_effect + + condition: + # If an actual effect is selected. + - condition: template + value_template: "{% if not is_state('input_select.bed_effect', 'Auto') %}true{% endif %}" + + action: + # Override any bed washlight effect. + - service: input_boolean.turn_on + entity_id: input_boolean.bed_effect_override + + # Update the effect variable. + - service: variable.set_variable + data: + variable: bed_effect + value_template: >- + {{ states('input_select.bed_effect') }} diff --git a/automations/bedroom_low.yaml b/automations/bedroom_low.yaml new file mode 100644 index 0000000..ba05813 --- /dev/null +++ b/automations/bedroom_low.yaml @@ -0,0 +1,31 @@ +# +# Set bedroom to low-power mode. +# +- id: bedroom_low_power + alias: Bedroom LOW POWER + trigger: + # When low-power mode is enabled. + - platform: state + entity_id: input_boolean.low_mode + to: 'on' + + action: + # Turn on some devices. + - service: homeassistant.turn_on + data: + entity_id: + - switch.nightstand_light + - switch.bedside_light + + # Turn off some devices. + - service: homeassistant.turn_off + entity_id: + - switch.bedroom_fan + + # Turn off some devices. + - service: light.turn_off + data: + entity_id: + - light.headboard + - light.underbed + transition: 5 diff --git a/automations/bedroom_off.yaml b/automations/bedroom_off.yaml new file mode 100644 index 0000000..2733688 --- /dev/null +++ b/automations/bedroom_off.yaml @@ -0,0 +1,26 @@ +# +# Turn off bedroom. +# +- id: bedroom_off + alias: Bedroom OFF + trigger: + # When nap mode is enabled. + - platform: state + entity_id: input_boolean.nap_mode + to: 'on' + + action: + # Turn off smart lights. + - service: light.turn_off + data: + entity_id: + - light.headboard + - light.underbed + transition: 10 + + # Turn off binary devices + - service: homeassistant.turn_off + entity_id: + - switch.nightstand_light + - switch.bedside_light + - switch.bedroom_fan diff --git a/automations/bedroom_on.yaml b/automations/bedroom_on.yaml new file mode 100644 index 0000000..e9ed8f0 --- /dev/null +++ b/automations/bedroom_on.yaml @@ -0,0 +1,26 @@ +# +# Turn on bedroom. +# +- id: bedroom_on + alias: Bedroom ON + trigger: + # When nap mode is disabled. + - platform: state + entity_id: input_boolean.nap_mode + to: 'off' + + action: + # Turn on smart lights. + - service: light.turn_on + data: + entity_id: + - light.headboard + - light.underbed + transition: 5 + + # Turn on binary devices. + - service: homeassistant.turn_on + entity_id: + - switch.nightstand_light + - switch.bedside_light + - switch.bedroom_fan diff --git a/automations/cct.yaml b/automations/cct.yaml index ff3edd4..dd04713 100644 --- a/automations/cct.yaml +++ b/automations/cct.yaml @@ -1,9 +1,11 @@ -# Adjust color temperature based on cyrcadian rythm. +# +# Adjust color temperature (CCT) based on cyrcadian rythm. +# # see: https://community.home-assistant.io/t/lifx-circadian-rhythm-time-of-day-automation/23091 # see: https://sigmaluminous.com/the-circadian-rhythm-and-color-temperature/ +# - id: cct - alias: Adjust white light temperature - initial_state: 'on' + alias: CCT trigger: # Every five minutes. - platform: time @@ -17,22 +19,12 @@ - light.spotlight to: 'on' - # When alerts are disabled. - - platform: state - entity_id: input_boolean.alert_mode - to: 'off' - # When scenes are disabled. - platform: state entity_id: input_boolean.scene_mode to: 'off' condition: - # If no alerts are enabled. - - condition: state - entity_id: input_boolean.alert_mode - state: 'off' - # If no scenes are enabled. - condition: state entity_id: input_boolean.scene_mode diff --git a/automations/ceiling_default.yaml b/automations/ceiling_default.yaml new file mode 100644 index 0000000..c18d527 --- /dev/null +++ b/automations/ceiling_default.yaml @@ -0,0 +1,15 @@ +# +# Return the ceiling washlights to the default scheduled effect. +# +- id: ceiling_default + alias: Ceiling DEFAULT + trigger: + # If the default effect is selected. + - platform: state + entity_id: input_select.ceiling_effect + to: Auto + + action: + # Remove the effect override. + - service: input_boolean.turn_off + entity_id: input_boolean.ceiling_effect_override diff --git a/automations/ceiling_effect.yaml b/automations/ceiling_effect.yaml index 76370aa..da2b374 100644 --- a/automations/ceiling_effect.yaml +++ b/automations/ceiling_effect.yaml @@ -1,19 +1,39 @@ +# # Change ceiling wash lights based on Lifx Cloud scenes. +# - id: ceiling_effect - alias: Apply effect to ceiling washlight + alias: Ceiling EFFECT trigger: - # When an effect is received via MQTT. + # When an effect is changed. - platform: state - entity_id: sensor.ceiling_effect_uuid + entity_id: variable.ceiling_effect action: - - service: notify.group - data: - title: 'Hass.io' - message: "ceiling_effect received: {{ states('sensor.ceiling_effect') }} ({{ states('sensor.ceiling_effect_uuid') }})" - + # Send the effect's UUID to the Lifx Cloud scenes service. - service: shell_command.activate_lifx_cloud_scene data_template: - uuid: "{{ states('sensor.ceiling_effect_uuid') }}" + uuid: >- + {% set effects = { + 'Blissful': 'e1cd000b-2780-40e9-8ae5-2ca55b67b01d', + 'Celebrations': '9428fffc-8466-489e-b93a-c7f062c45a81', + 'Cheerful': '2223a575-b13d-468f-875c-1d8275b2f718', + 'Daylight': '40d6b6a6-0eb7-48bc-81c1-b469e91a9b6d', + 'Focusing': '83bfebf8-ab73-483f-9987-5c6a8a340609', + 'Intense': 'd8a58aca-0e9a-4379-8668-363e237316b2', + 'Mellow': '4cc1d4fe-cf9e-4391-899b-0bb5f13f4c73', + 'Movie': 'ba3ac9bf-ae54-4e11-a8a8-d7ec6862293d', + 'Northern Lights': '7e85572c-facc-46d9-a3fa-832ed82a9496', + 'Powerful': 'afed3ed6-c918-44d5-9207-7e895c6d3d0f', + 'Relaxing': 'c4d42b21-8d79-4637-a04a-0ace24824c30', + 'Serene': '66d389bc-fd2a-460d-9d70-3063db2ea509', + 'Soothing': 'a09a3137-98f1-41a8-b9ae-64a1cec54c1a', + 'Tranquil': '34cacbbe-d4ad-4abf-b108-6973431d63d3', + 'Warming': '8b85e701-0189-4c4b-a703-cfa3d0f0ab64', + } %} + {% set selected = states('variable.ceiling_effect') %} + + {% if effects[selected] %} + {{ effects[selected] }} + {% endif %} duration: 10 key: !secret lifx_cloud_token diff --git a/automations/ceiling_off.yaml b/automations/ceiling_off.yaml new file mode 100644 index 0000000..ad30324 --- /dev/null +++ b/automations/ceiling_off.yaml @@ -0,0 +1,23 @@ +# +# Turn off ceiling washlights. +# +- id: ceiling_off + alias: Ceiling OFF + trigger: + # When nap mode is enabled. + - platform: state + entity_id: input_boolean.nap_mode + to: 'on' + + # When night mode is enabled. + - platform: state + entity_id: input_boolean.night_mode + to: 'on' + + action: + # Turn off ceiling washlights. + - service: homeassistant.turn_off + data: + entity_id: + - group.ceiling + transition: 10 diff --git a/automations/ceiling_on.yaml b/automations/ceiling_on.yaml new file mode 100644 index 0000000..5539ac7 --- /dev/null +++ b/automations/ceiling_on.yaml @@ -0,0 +1,34 @@ +# +# Turn on ceiling washlights. +# +- id: ceiling_on + alias: Ceiling ON + trigger: + # When nap mode is disabled. + - platform: state + entity_id: input_boolean.nap_mode + to: 'off' + + # When night mode is disabled. + - platform: state + entity_id: input_boolean.night_mode + to: 'off' + + condition: + # If nap mode is disabled. + - condition: state + entity_id: input_boolean.nap_mode + state: 'off' + + # If night mode is disabled + - condition: state + entity_id: input_boolean.night_mode + state: 'off' + + action: + # Turn on ceiling washlights. + - service: homeassistant.turn_on + data: + entity_id: + - group.ceiling + transition: 5 diff --git a/automations/ceiling_schedule.yaml b/automations/ceiling_schedule.yaml index 8ec082b..c37a125 100644 --- a/automations/ceiling_schedule.yaml +++ b/automations/ceiling_schedule.yaml @@ -1,14 +1,20 @@ +# # Schedule ceiling wash lights based on Lifx Cloud scenes. +# # see: https://api.developer.lifx.com/docs/activate-scene -- id: ceiling_lights_schedule - alias: Rotate ceiling washlights based on a schedule - initial_state: 'on' +# +- id: ceiling_schedule + alias: Ceiling SCHEDULE trigger: # Every hour on the hour. - platform: time - minutes: /5 + minutes: 00 seconds: 00 + # When Home Assistant starts. + - platform: homeassistant + event: start + # When an item which was off comes back online. - platform: state entity_id: @@ -17,11 +23,6 @@ - light.middle to: 'on' - # When alerts are disabled. - - platform: state - entity_id: input_boolean.alert_mode - to: 'off' - # When scenes are disabled. - platform: state entity_id: input_boolean.scene_mode @@ -33,6 +34,14 @@ to: 'off' condition: + # If automation was not trigered lately. + - condition: template + value_template: >- + {% set current = as_timestamp(utcnow()) %} + {% set last_triggered = as_timestamp(states.automation.ceiling_schedule.attributes.last_triggered) | float %} + + {{ current - last_triggered > 1}} + # If ceiling lights are on. - condition: state entity_id: group.ceiling @@ -43,16 +52,6 @@ entity_id: input_boolean.ceiling_effect_override state: 'off' - # If no other process is handling the ceiling lights. - - condition: state - entity_id: input_boolean.ceiling_semaphore - state: 'off' - - # If no alerts are enabled. - - condition: state - entity_id: input_boolean.alert_mode - state: 'off' - # If no scenes are enabled. - condition: state entity_id: input_boolean.scene_mode @@ -69,14 +68,11 @@ state: 'off' action: - # Reserve the ceilight lights. - - service: input_boolean.turn_on - entity_id: input_boolean.ceilight_semaphore - - - service: mqtt.publish - data_template: - topic: 'home/ceiling/effect' - payload: >- + # Update the effect variables. + - service: variable.set_variable + data: + variable: ceiling_effect + value_template: >- {% set hour = states('sensor.time').split(':')[0] %} {% set schedule = { '00': 'Warming', @@ -107,40 +103,5 @@ '22': 'Soothing', '23': 'Tranquil', } %} - {% set effects = { - 'Blissful': 'e1cd000b-2780-40e9-8ae5-2ca55b67b01d', - 'Celebrations': '9428fffc-8466-489e-b93a-c7f062c45a81', - 'Cheerful': '2223a575-b13d-468f-875c-1d8275b2f718', - 'Daylight': '40d6b6a6-0eb7-48bc-81c1-b469e91a9b6d', - 'Focusing': '83bfebf8-ab73-483f-9987-5c6a8a340609', - 'Intense': 'd8a58aca-0e9a-4379-8668-363e237316b2', - 'Mellow': '4cc1d4fe-cf9e-4391-899b-0bb5f13f4c73', - 'Movie': 'ba3ac9bf-ae54-4e11-a8a8-d7ec6862293d', - 'Northern Lights': '7e85572c-facc-46d9-a3fa-832ed82a9496', - 'Powerful': 'afed3ed6-c918-44d5-9207-7e895c6d3d0f', - 'Relaxing': 'c4d42b21-8d79-4637-a04a-0ace24824c30', - 'Serene': '66d389bc-fd2a-460d-9d70-3063db2ea509', - 'Soothing': 'a09a3137-98f1-41a8-b9ae-64a1cec54c1a', - 'Tranquil': '34cacbbe-d4ad-4abf-b108-6973431d63d3', - 'Warming': '8b85e701-0189-4c4b-a703-cfa3d0f0ab64', - } %} - {% set selected = schedule[hour] %} - - { - "name": "{{ selected }}", - "uuid": "{{ effects[selected] }}" - } - - # Notify the owner. - # - service: notify.group - # data: - # title: 'Hass.io' - # message: "ceiling_lifx_cloud_scenes sent." - - # Pause a while, to minimize race conditions. - - delay: - seconds: 5 - - # Release the cealing lights. - - service: input_boolean.turn_off - entity_id: input_boolean.ceilight_semaphore + + {{ schedule[hour] }} diff --git a/automations/ceiling_select.yaml b/automations/ceiling_select.yaml index 812dbd9..9c6db25 100644 --- a/automations/ceiling_select.yaml +++ b/automations/ceiling_select.yaml @@ -1,74 +1,26 @@ +# # Manually select a LIFX cloud effect for the ceiling washlights. +# - id: ceiling_select - alias: Select Ceiling Washlight Effect + alias: Ceiling SELECT trigger: + # An effect has been selected. - platform: state entity_id: input_select.ceiling_effect condition: - # If no other process is handling the ceiling washlights. - - condition: state - entity_id: input_boolean.ceiling_semaphore - state: 'off' - # If an actual effect is selected. - condition: template value_template: "{% if not is_state('input_select.ceiling_effect', 'Auto') %}true{% endif %}" action: - # Reserve the ceiling washlights. - - service: input_boolean.turn_on - entity_id: input_boolean.ceiling_semaphore - # Override any ceiling washlight effect. - service: input_boolean.turn_on entity_id: input_boolean.ceiling_effect_override - # Send the effect update via Mosquitto. - - service: mqtt.publish - data_template: - topic: 'home/ceiling/effect' - payload: >- - {% set effects = { - 'Blissful': 'e1cd000b-2780-40e9-8ae5-2ca55b67b01d', - 'Celebrations': '9428fffc-8466-489e-b93a-c7f062c45a81', - 'Cheerful': '2223a575-b13d-468f-875c-1d8275b2f718', - 'Daylight': '40d6b6a6-0eb7-48bc-81c1-b469e91a9b6d', - 'Focusing': '83bfebf8-ab73-483f-9987-5c6a8a340609', - 'Intense': 'd8a58aca-0e9a-4379-8668-363e237316b2', - 'Mellow': '4cc1d4fe-cf9e-4391-899b-0bb5f13f4c73', - 'Movie': 'ba3ac9bf-ae54-4e11-a8a8-d7ec6862293d', - 'Northern Lights': '7e85572c-facc-46d9-a3fa-832ed82a9496', - 'Powerful': 'afed3ed6-c918-44d5-9207-7e895c6d3d0f', - 'Relaxing': 'c4d42b21-8d79-4637-a04a-0ace24824c30', - 'Serene': '66d389bc-fd2a-460d-9d70-3063db2ea509', - 'Soothing': 'a09a3137-98f1-41a8-b9ae-64a1cec54c1a', - 'Tranquil': '34cacbbe-d4ad-4abf-b108-6973431d63d3', - 'Warming': '8b85e701-0189-4c4b-a703-cfa3d0f0ab64', - } %} - {% set selected = states('input_select.ceiling_effect') %} - - {% if effects[selected] %} - { - "name": "{{ selected }}", - "uuid": "{{ effects[selected] }}" - } - {% endif %} - - # Release the ceiling washlights. - - service: input_boolean.turn_off - entity_id: input_boolean.ceiling_semaphore - - -# Return the ceiling washlights to the default scheduled effect. -- id: ceiling_washlight_default - alias: Default Ceiling Washlight Effect - trigger: - - platform: state - entity_id: input_select.ceiling_effect - to: Auto - - action: - # Remove the effect override. - - service: input_boolean.turn_off - entity_id: input_boolean.ceiling_effect_override + # Update the effect variables. + - service: variable.set_variable + data: + variable: ceiling_effect + value_template: >- + {{ states('input_select.ceiling_effect') }} diff --git a/automations/door_left_open.yaml b/automations/check_doors.yaml similarity index 86% rename from automations/door_left_open.yaml rename to automations/check_doors.yaml index d599776..cf0c28d 100644 --- a/automations/door_left_open.yaml +++ b/automations/check_doors.yaml @@ -1,7 +1,10 @@ +# # Warns someone if a door was left open for too long. +# # Todo: Add condition that no one has been detected at home. -- id: door_left_open - alias: 'Door left open' +# +- id: check_door_left_open + alias: Check door left open trigger: - platform: state entity_id: input_boolean.doors_open diff --git a/automations/check_humidity.yaml b/automations/check_humidity.yaml deleted file mode 100644 index 3833d7e..0000000 --- a/automations/check_humidity.yaml +++ /dev/null @@ -1,65 +0,0 @@ -# Check if humidity is too low. -- id: check_humidity_low - alias: Check low humidity - trigger: - # At noon. - - platform: time - hours: 12 - minutes: 00 - seconds: 00 - - condition: - # Humidity is too low. - - condition: numeric_state - entity_id: sensor.average_humidity - below: 35 - - # Doors are closed. - - condition: state - entity_id: input_boolean.doors_open - state: 'off' - - # Windows are closed. - - condition: state - entity_id: input_boolean.windows_open - state: 'off' - - action: - - service: persistent_notification.create - data: - notification_id: humidity - title: "Humidity is too low: {{ states('sensor.average_humidity') }}%" - message: "Take a long hot shower or install a humidifier." - -# Check if humidity is too high. -- id: check_humidity_high - alias: Check high humidity - trigger: - # At noon. - - platform: time - hours: 12 - minutes: 00 - seconds: 00 - - condition: - # Humidity is too high. - - condition: numeric_state - entity_id: sensor.average_humidity - above: 50 - - # Doors are closed. - - condition: state - entity_id: input_boolean.doors_open - state: 'off' - - # Windows are closed. - - condition: state - entity_id: input_boolean.windows_open - state: 'off' - - action: - - service: persistent_notification.create - data: - notification_id: humidity - title: "Humidity is too high: {{ states('sensor.average_humidity') }}%" - message: "Check the dehumidifier." diff --git a/automations/check_humidity_high.yaml b/automations/check_humidity_high.yaml new file mode 100644 index 0000000..e27c413 --- /dev/null +++ b/automations/check_humidity_high.yaml @@ -0,0 +1,34 @@ +# +# Check if humidity is too high. +# +- id: check_humidity_high + alias: Check humidity HIGH + trigger: + # At noon. + - platform: time + hours: 12 + minutes: 00 + seconds: 00 + + condition: + # Humidity is too high. + - condition: numeric_state + entity_id: sensor.average_humidity + above: 50 + + # Doors are closed. + - condition: state + entity_id: input_boolean.doors_open + state: 'off' + + # Windows are closed. + - condition: state + entity_id: input_boolean.windows_open + state: 'off' + + action: + - service: persistent_notification.create + data: + notification_id: humidity + title: "Humidity is too high: {{ states('sensor.average_humidity') }}%" + message: "Check the dehumidifier." diff --git a/automations/check_humidity_low.yaml b/automations/check_humidity_low.yaml new file mode 100644 index 0000000..91dc9da --- /dev/null +++ b/automations/check_humidity_low.yaml @@ -0,0 +1,34 @@ +# +# Check if humidity is too low. +# +- id: check_humidity_low + alias: Check humidity LOW + trigger: + # At noon. + - platform: time + hours: 12 + minutes: 00 + seconds: 00 + + condition: + # Humidity is too low. + - condition: numeric_state + entity_id: sensor.average_humidity + below: 35 + + # Doors are closed. + - condition: state + entity_id: input_boolean.doors_open + state: 'off' + + # Windows are closed. + - condition: state + entity_id: input_boolean.windows_open + state: 'off' + + action: + - service: persistent_notification.create + data: + notification_id: humidity + title: "Humidity is too low: {{ states('sensor.average_humidity') }}%" + message: "Take a long hot shower or install a humidifier." diff --git a/automations/mold_conditions.yaml b/automations/check_mold.yaml similarity index 94% rename from automations/mold_conditions.yaml rename to automations/check_mold.yaml index ac80309..c0bf000 100644 --- a/automations/mold_conditions.yaml +++ b/automations/check_mold.yaml @@ -1,8 +1,11 @@ +# # Warns someone if humidity levels may lead to mold issues. +# # Only triggers if windows and doors are open, because we're not responsible # for what's happening outside. -- id: mold_conditions - alias: 'Mold conditions' +# +- id: check_mold_conditions + alias: Check mold conditions trigger: # Mold grows above 55% relative humidity, and thrives above 70%. - platform: numeric_state diff --git a/automations/update_available.yaml b/automations/check_update.yaml similarity index 55% rename from automations/update_available.yaml rename to automations/check_update.yaml index 50249ea..f9d3c96 100644 --- a/automations/update_available.yaml +++ b/automations/check_update.yaml @@ -1,8 +1,10 @@ -# Warns someone when a new version of Home Assistant is available. +# +# Notifies when a new version of Home Assistant is available. +# # An updated Hass.io version usually follows shortly. -- id: update_available - alias: Update Available - initial_state: 'off' +# +- id: check_update_availability + alias: Check update availability trigger: platform: state entity_id: updater.updater @@ -16,4 +18,4 @@ - service: notify.group data: title: 'Hass.io' - message: 'Update for Home Assistant is available.' + message: "Home Assistant {{ states('updater.updater') }} is available. Installed version: {{ states('sensor.current_version') }}" diff --git a/automations/dehumidify_stop.yaml b/automations/dehumidifier_off.yaml similarity index 94% rename from automations/dehumidify_stop.yaml rename to automations/dehumidifier_off.yaml index 71c69a4..d53540e 100644 --- a/automations/dehumidify_stop.yaml +++ b/automations/dehumidifier_off.yaml @@ -1,6 +1,8 @@ +# # Turn off the Dehumidifier when it's no longer relevant. -- id: dehumidify_stop - alias: Stop dehumidifying +# +- id: dehumidifier_off + alias: Dehumidifier OFF trigger: # Humidity is getting too low. - platform: numeric_state diff --git a/automations/dehumidify.yaml b/automations/dehumidifier_on.yaml similarity index 94% rename from automations/dehumidify.yaml rename to automations/dehumidifier_on.yaml index 6ac4234..d49362d 100644 --- a/automations/dehumidify.yaml +++ b/automations/dehumidifier_on.yaml @@ -1,6 +1,8 @@ +# # Turn on the dehumidifier when appropriate if humidify levels are too high. -- id: dehumidity - alias: Dehumidify +# +- id: dehumidifier_on + alias: Dehumidifier ON trigger: # Humidity is getting too high. - platform: numeric_state diff --git a/automations/front_door.yaml b/automations/front_door.yaml deleted file mode 100644 index 5b5f06d..0000000 --- a/automations/front_door.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# Warn whenever the front door is opening. -# Todo: map door sensor state values to binary values. -- id: front_door_opens - alias: 'Front door opens' - trigger: - - platform: state - entity_id: sensor.aeotec_zw120_door_window_sensor_gen5_access_control - from: '23' - to: '22' - - action: - # Flash the shower light, in case one didn't hear the door opening. - - service: light.lifx_effect_pulse - data: - entity_id: - - light.shower - mode: breathe - color_name: cyan - brightness: 120 - period: 1 - cycles: 1 - -# Warn whenever the front door is closing. -- id: front_door_closes - alias: 'Front door closes' - trigger: - - platform: state - entity_id: sensor.aeotec_zw120_door_window_sensor_gen5_access_control - from: '22' - to: '23' - - action: - # Flash the shower light, in case one didn't hear the door closing. - - service: light.lifx_effect_pulse - data: - entity_id: - - light.shower - mode: blink - color_name: purple - brightness: 120 - period: 1 - cycles: 1 diff --git a/automations/front_door_closed.yaml b/automations/front_door_closed.yaml new file mode 100644 index 0000000..b3c77b3 --- /dev/null +++ b/automations/front_door_closed.yaml @@ -0,0 +1,22 @@ +# +# Warn whenever the front door is closing. +# +- id: front_door_closed + alias: Front door CLOSED + trigger: + - platform: state + entity_id: sensor.aeotec_zw120_door_window_sensor_gen5_access_control + from: '22' + to: '23' + + action: + # Flash the shower light, in case one didn't hear the door closing. + - service: light.lifx_effect_pulse + data: + entity_id: + - light.shower + mode: blink + color_name: purple + brightness: 120 + period: 1 + cycles: 1 diff --git a/automations/front_door_opened.yaml b/automations/front_door_opened.yaml new file mode 100644 index 0000000..626edeb --- /dev/null +++ b/automations/front_door_opened.yaml @@ -0,0 +1,24 @@ +# +# Warn whenever the front door is opening. +# +# Todo: map door sensor state values to binary values. +# +- id: front_door_opened + alias: Front door OPENED + trigger: + - platform: state + entity_id: sensor.aeotec_zw120_door_window_sensor_gen5_access_control + from: '23' + to: '22' + + action: + # Flash the shower light, in case one didn't hear the door opening. + - service: light.lifx_effect_pulse + data: + entity_id: + - light.shower + mode: breathe + color_name: cyan + brightness: 120 + period: 1 + cycles: 1 diff --git a/automations/go_to_sleep.yaml b/automations/go_to_sleep.yaml new file mode 100644 index 0000000..aae3ddc --- /dev/null +++ b/automations/go_to_sleep.yaml @@ -0,0 +1,24 @@ +# +# Go to sleep. +# +# Todo: convert script into night mode and automations. +# +- id: go_to_sleep + alias: Go to sleep + trigger: + # Bedsite Flic button is held. + - platform: event + event_type: flic_click + event_data: + button_name: flic_80e4da737711 + click_type: hold + + condition: + # Not during the night mode. + - condition: state + entity_id: input_boolean.night_mode + state: 'off' + + action: + - service: script.turn_on + entity_id: script.go_to_sleep diff --git a/automations/lounge_low.yaml b/automations/lounge_low.yaml new file mode 100644 index 0000000..8f9e314 --- /dev/null +++ b/automations/lounge_low.yaml @@ -0,0 +1,33 @@ +# +# Set lounge to low-power mode. +# +- id: lounge_low_power + alias: Lounge LOW POWER + trigger: + # When low-power mode is enabled. + - platform: state + entity_id: input_boolean.low_mode + to: 'on' + + action: + # Turn on some binary devices. + - service: homeassistant.turn_on + data: + entity_id: + - light.lightpack + - switch.souvenirs_light + - switch.window_light + + # Turn on some smart lights. + - service: homeassistant.turn_on + data: + entity_id: + - light.spotlight + transition: 5 + + # Turn off some smart lights. + - service: homeassistant.turn_off + data: + entity_id: + - light.aurora + transition: 10 diff --git a/automations/lounge_off.yaml b/automations/lounge_off.yaml new file mode 100644 index 0000000..246c299 --- /dev/null +++ b/automations/lounge_off.yaml @@ -0,0 +1,27 @@ +# +# Turn off lounge. +# +- id: lounge_off + alias: Lounge OFF + trigger: + # When night mode is enabled. + - platform: state + entity_id: input_boolean.night_mode + to: 'on' + + action: + # Turn off binary devices. + - service: homeassistant.turn_off + data: + entity_id: + - light.lightpack + - switch.souvenirs_light + - switch.window_light + + # Turn off smart lights. + - service: light.turn_off + data: + entity_id: + - light.aurora + - light.spotlight + transition: 10 diff --git a/automations/lounge_on.yaml b/automations/lounge_on.yaml new file mode 100644 index 0000000..11bef6b --- /dev/null +++ b/automations/lounge_on.yaml @@ -0,0 +1,43 @@ +# +# Turn on lounge. +# +- id: lounge_on + alias: Lounge ON + trigger: + # When nap mode is disabled. + - platform: state + entity_id: input_boolean.nap_mode + to: 'off' + + # When night mode is disabled. + - platform: state + entity_id: input_boolean.night_mode + to: 'off' + + condition: + # If nap mode is disabled. + - condition: state + entity_id: input_boolean.nap_mode + state: 'off' + + # If night mode is disabled + - condition: state + entity_id: input_boolean.night_mode + state: 'off' + + action: + # Turn on binary devices. + - service: homeassistant.turn_on + data: + entity_id: + - light.lightpack + - switch.souvenirs_light + - switch.window_light + + # Turn on smart lights. + - service: light.turn_on + data: + entity_id: + - light.aurora + - light.spotlight + transition: 5 diff --git a/automations/low_mode_start.yaml b/automations/low_mode_start.yaml new file mode 100644 index 0000000..bcd57c8 --- /dev/null +++ b/automations/low_mode_start.yaml @@ -0,0 +1,16 @@ +# +# Enable low-power state for a more relaxed environment. +# +- id: low_power_mode_start + alias: Low power mode START + trigger: + # When nap mode is enabled. + - platform: state + entity_id: input_boolean.nap_mode + to: 'on' + + action: + # Enable low-power mode. + - service: input_boolean.turn_on + data: + entity_id: input_boolean.low_mode diff --git a/automations/low_mode_stop.yaml b/automations/low_mode_stop.yaml new file mode 100644 index 0000000..1e421ee --- /dev/null +++ b/automations/low_mode_stop.yaml @@ -0,0 +1,21 @@ +# +# Disable low-power state. +# +- id: low_power_mode_stop + alias: Low power mode STOP + trigger: + # When nap mode is disabled. + - platform: state + entity_id: input_boolean.nap_mode + to: 'off' + + # When night mode is enabled. + - platform: state + entity_id: input_boolean.night_mode + to: 'on' + + action: + # Disable low-power mode. + - service: input_boolean.turn_off + data: + entity_id: input_boolean.low_mode diff --git a/automations/media_player.yaml b/automations/media_player_resume.yaml similarity index 51% rename from automations/media_player.yaml rename to automations/media_player_resume.yaml index da39e34..07378c9 100644 --- a/automations/media_player.yaml +++ b/automations/media_player_resume.yaml @@ -1,28 +1,8 @@ -- id: media_player - alias: "Media player starts" - trigger: - - platform: state - entity_id: media_player.kodi - from: 'idle' - to: 'playing' - - condition: - # Sun has set. - - condition: state - entity_id: sun.sun - state: 'below_horizon' - - # Not during the nap mode. - - condition: state - entity_id: input_boolean.nap_mode - state: 'off' - - action: - - service: scene.turn_on - entity_id: scene.movies - +# +# Media player plays content. +# - id: media_player_resume - alias: "Media player resumes" + alias: Media player RESUME trigger: - platform: state entity_id: media_player.kodi @@ -58,26 +38,20 @@ - condition: state entity_id: group.ceiling state: 'on' - - service: mqtt.publish - data_template: - topic: 'home/ceiling/effect' - payload: >- - { - "name": "Movie", - "uuid": "ba3ac9bf-ae54-4e11-a8a8-d7ec6862293d" - } + - service: variable.set_variable + data: + variable: ceiling_effect + value: "Movie" # If the Aurora is active, set it to its dedicated Movie scene. - condition: state entity_id: light.aurora state: 'on' - - service: mqtt.publish - data_template: - topic: 'home/aurora/effect' - payload: >- - { - "name": "Flames", - "brightness": 21 - } - - + - service: variable.set_variable + data: + variable: aurora_effect + value: "Flames" + - service: variable.set_variable + data: + variable: aurora_brightness + value: "21" diff --git a/automations/media_player_start.yaml b/automations/media_player_start.yaml new file mode 100644 index 0000000..ac514c3 --- /dev/null +++ b/automations/media_player_start.yaml @@ -0,0 +1,25 @@ +# +# Media player starts, turn on mood lights. +# +- id: media_player_start + alias: Media player START + trigger: + - platform: state + entity_id: media_player.kodi + from: 'idle' + to: 'playing' + + condition: + # Sun has set. + - condition: state + entity_id: sun.sun + state: 'below_horizon' + + # Not during the nap mode. + - condition: state + entity_id: input_boolean.nap_mode + state: 'off' + + action: + - service: scene.turn_on + entity_id: scene.movies diff --git a/automations/media_player_stop.yaml b/automations/media_player_stop.yaml index 79a5da6..80f7299 100644 --- a/automations/media_player_stop.yaml +++ b/automations/media_player_stop.yaml @@ -1,5 +1,8 @@ +# +# Media player paused/stopped. +# - id: media_player_stop - alias: "Media player paused/stopped" + alias: Media player STOP trigger: - platform: state entity_id: media_player.kodi @@ -9,6 +12,13 @@ entity_id: media_player.kodi to: 'idle' + - platform: state + entity_id: media_player.kodi + to: 'off' + action: - service: input_boolean.turn_off entity_id: input_boolean.scene_mode + + - service: scene.turn_off + entity_id: scene.movies diff --git a/automations/nap_mode_start.yaml b/automations/nap_mode_start.yaml new file mode 100644 index 0000000..879438e --- /dev/null +++ b/automations/nap_mode_start.yaml @@ -0,0 +1,27 @@ +# +# When someone takes a nap. +# +# Should lower lights and minimize noises without preventing someone else +# from being active. +# +- id: nap_mode_start + alias: Nap mode START + trigger: + # Bedsite Flic button is pressed once. + - platform: event + event_type: flic_click + event_data: + button_name: flic_80e4da737711 + click_type: single + + condition: + # If nap mode is not currently enabled. + - condition: state + entity_id: input_boolean.nap_mode + state: 'off' + + action: + # Enable nap mode. + - service: input_boolean.turn_on + data: + entity_id: input_boolean.nap_mode diff --git a/automations/nap_mode_stop.yaml b/automations/nap_mode_stop.yaml new file mode 100644 index 0000000..c520d40 --- /dev/null +++ b/automations/nap_mode_stop.yaml @@ -0,0 +1,29 @@ +# +# When someone ends their nap. +# +- id: nap_mode_stop + alias: Nap mode STOP + trigger: + # When night mode is enabled. + - platform: state + entity_id: input_boolean.night_mode + to: 'on' + + # Bedsite Flic button is pressed once. + - platform: event + event_type: flic_click + event_data: + button_name: flic_80e4da737711 + click_type: single + + condition: + # If nap time is in effect. + - condition: state + entity_id: input_boolean.nap_mode + state: 'on' + + action: + # Disable nap mode. + - service: input_boolean.turn_off + data: + entity_id: input_boolean.nap_mode diff --git a/automations/nap_time.yaml b/automations/nap_time.yaml deleted file mode 100644 index 8112de2..0000000 --- a/automations/nap_time.yaml +++ /dev/null @@ -1,45 +0,0 @@ -- id: nap_time - alias: Nap time - trigger: - # Bedsite Flic button is pressed once. - - platform: event - event_type: flic_click - event_data: - button_name: flic_80e4da737711 - click_type: single - - condition: - # If nap time is not currently enabled. - - condition: state - entity_id: input_boolean.nap_mode - state: 'off' - - action: - - service: script.turn_on - entity_id: script.take_a_nap - -- id: nap_time_over - alias: Nap time over - trigger: - # Bedsite Flic button is pressed once. - - platform: event - event_type: flic_click - event_data: - button_name: flic_80e4da737711 - click_type: single - - condition: - # If nap time is in effect. - - condition: state - entity_id: input_boolean.nap_mode - state: 'on' - - action: - - service: homeassistant.turn_on - entity_id: - - switch.nightstand_light - - switch.bedside_light - - - service: input_boolean.turn_off - data: - entity_id: input_boolean.nap_mode diff --git a/automations/nightlight_off.yaml b/automations/nightlight_off.yaml index 763235a..55276d3 100644 --- a/automations/nightlight_off.yaml +++ b/automations/nightlight_off.yaml @@ -1,5 +1,10 @@ +# +# Turn off nightlights when appropriate. +# +# Todo: use a timer. +# - id: nightlight_off - alias: Turn off night lights + alias: Nightlight OFF trigger: # Lounge motion no longer detected. - platform: state @@ -19,4 +24,4 @@ entity_id: - light.shower - light.spotlight - transition: 5 + transition: 10 diff --git a/automations/nightlight.yaml b/automations/nightlight_on.yaml similarity index 92% rename from automations/nightlight.yaml rename to automations/nightlight_on.yaml index 8a9cbc3..fd240ad 100644 --- a/automations/nightlight.yaml +++ b/automations/nightlight_on.yaml @@ -1,7 +1,10 @@ +# # Turn on nightlights when appropriate. +# # Todo: map door sensor state values to binary values. -- id: nightlight - alias: Turn on night lights +# +- id: nightlight_on + alias: Nightlight ON trigger: # Lounge motion detected. - platform: state diff --git a/automations/quiet_time.yaml b/automations/quiet_mode_start.yaml similarity index 89% rename from automations/quiet_time.yaml rename to automations/quiet_mode_start.yaml index b39782f..7592847 100644 --- a/automations/quiet_time.yaml +++ b/automations/quiet_mode_start.yaml @@ -1,6 +1,8 @@ +# # When noise makers should not be running. -- id: quiet_time - alias: Declare quiet time +# +- id: quiet_mode_start + alias: Quiet mode START trigger: # It's too late. - platform: time diff --git a/automations/quiet_time_stop.yaml b/automations/quiet_mode_stop.yaml similarity index 94% rename from automations/quiet_time_stop.yaml rename to automations/quiet_mode_stop.yaml index 956e90e..0094211 100644 --- a/automations/quiet_time_stop.yaml +++ b/automations/quiet_mode_stop.yaml @@ -1,6 +1,8 @@ +# # When noise makers should be allowed to run. -- id: quiet_time_stop - alias: End quiet time +# +- id: quiet_mode_stop + alias: Quiet mode STOP trigger: # It's daytime. - platform: time diff --git a/automations/wake_up.yaml b/automations/wake_up.yaml index e75faab..8ff5e2e 100644 --- a/automations/wake_up.yaml +++ b/automations/wake_up.yaml @@ -1,3 +1,8 @@ +# +# Wake up. +# +# Todo: convert script into night mode and automations. +# - id: wake_up alias: Wake up trigger: @@ -17,23 +22,3 @@ action: - service: script.turn_on entity_id: script.wake_up - -- id: go_to_sleep - alias: Go to Sleep - trigger: - # Bedsite Flic button is held. - - platform: event - event_type: flic_click - event_data: - button_name: flic_80e4da737711 - click_type: hold - - condition: - # Not during the night mode. - - condition: state - entity_id: input_boolean.night_mode - state: 'off' - - action: - - service: script.turn_on - entity_id: script.go_to_sleep diff --git a/automations/washroom_low.yaml b/automations/washroom_low.yaml new file mode 100644 index 0000000..ea297b4 --- /dev/null +++ b/automations/washroom_low.yaml @@ -0,0 +1,20 @@ +# +# Set washroom in low-power mode. +# +# Todo: force dim lights. +# +- id: washroom_low_power + alias: Washroom LOW POWER + trigger: + # When low-power mode is enabled. + - platform: state + entity_id: input_boolean.low_mode + to: 'on' + + action: + # Turn on some devices. + - service: homeassistant.turn_on + data: + entity_id: + - light.shower + transition: 5 diff --git a/automations/washroom_off.yaml b/automations/washroom_off.yaml new file mode 100644 index 0000000..1fee101 --- /dev/null +++ b/automations/washroom_off.yaml @@ -0,0 +1,23 @@ +# +# Turn off washroom. +# +- id: washroom_off + alias: Washroom OFF + trigger: + # When nap mode is enabled. + - platform: state + entity_id: input_boolean.nap_mode + to: 'on' + + # When night mode is enabled. + - platform: state + entity_id: input_boolean.night_mode + to: 'on' + + action: + # Turn off devices. + - service: homeassistant.turn_off + data: + entity_id: + - group.washroom + transition: 5 diff --git a/automations/washroom_on.yaml b/automations/washroom_on.yaml new file mode 100644 index 0000000..ab9b654 --- /dev/null +++ b/automations/washroom_on.yaml @@ -0,0 +1,34 @@ +# +# Turn on washroom. +# +- id: washroom_on + alias: Washroom ON + trigger: + # When nap mode is disabled. + - platform: state + entity_id: input_boolean.nap_mode + to: 'off' + + # When night mode is disabled. + - platform: state + entity_id: input_boolean.night_mode + to: 'off' + + condition: + # If nap mode is disabled. + - condition: state + entity_id: input_boolean.nap_mode + state: 'off' + + # If night mode is disabled + - condition: state + entity_id: input_boolean.night_mode + state: 'off' + + action: + # Turn on devices. + - service: homeassistant.turn_on + data: + entity_id: + - group.washroom + transition: 5 diff --git a/configuration.yaml b/configuration.yaml index d321c2d..ceb3ab5 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -10,8 +10,8 @@ homeassistant: # metric for Metric, imperial for Imperial unit_system: metric time_zone: America/Toronto - customize: !include customize.yaml customize_glob: !include customize_glob.yaml + customize: !include customize.yaml # Show links to resources in log and frontend #introduction: @@ -25,8 +25,13 @@ logger: # Enables the frontend frontend: + # javascript_version: es5 extra_html_url: - - /www/custom_ui/state-card-custom-ui.html + - /local/custom_ui/state-card-custom-ui.html + - /local/custom_ui/state-card-value_only.html + extra_html_url_es5: + - /local/custom_ui/state-card-custom-ui-es5.html + - /local/custom_ui/state-card-value_only.html # Enables configuration UI config: @@ -47,7 +52,9 @@ updater: include_used_components: true # Discover some devices automatically -# discovery: +discovery: + ignore: + - plex_mediaserver # Allows you to issue voice commands from the frontend in enabled browsers conversation: @@ -66,7 +73,8 @@ sun: # MQTT mqtt: - broker: core-mosquitto + broker: !secret mqtt_broker + port: !secret mqtt_port username: !secret mqtt_username password: !secret mqtt_password @@ -165,4 +173,5 @@ sensor: !include_dir_merge_list sensors/ rest_command: !include misc/rest_commands.yaml shell_command: !include misc/shell_commands.yaml switch: !include_dir_merge_list switches/ +variable: !include misc/variables.yaml zone: !include_dir_list zones/ diff --git a/custom_components/README.md b/custom_components/README.md new file mode 100644 index 0000000..0f51c2b --- /dev/null +++ b/custom_components/README.md @@ -0,0 +1,22 @@ +# Custom components, community contributions and overrides + + +## Custom components + +None. + + +## Community components + +- [Doomsday Clock](https://github.com/renemarc/home-assistant-custom-components) +- [Lightpack](https://github.com/kklemm91/Lightpack-HASS) +- [Nanoleaf Aurora](https://github.com/Oro/home-assistant/tree/light-aurora) +- [Variables](https://github.com/rogro82/hass-variables) + + +## Overriden components + +- [EBox](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/sensor/ebox.py) + + Support for "unlimited" values. +- [GTFS](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/sensor/gtfs.py) + + Support for next departures. diff --git a/custom_components/variable.py b/custom_components/variable.py new file mode 100644 index 0000000..209d34e --- /dev/null +++ b/custom_components/variable.py @@ -0,0 +1,208 @@ +import asyncio +import logging +import json + +import voluptuous as vol + +from homeassistant.const import (CONF_NAME, ATTR_ICON) +from homeassistant.helpers import config_validation as cv +from homeassistant.helpers import template +from homeassistant.exceptions import TemplateError +from homeassistant.loader import bind_hass +from homeassistant.helpers.entity import Entity +from homeassistant.helpers.entity_component import EntityComponent +from homeassistant.helpers.restore_state import async_get_last_state + +_LOGGER = logging.getLogger(__name__) + +DOMAIN = 'variable' +ENTITY_ID_FORMAT = DOMAIN + '.{}' + +CONF_ATTRIBUTES = "attributes" +CONF_VALUE = "value" +CONF_RESTORE = "restore" + +ATTR_VARIABLE = "variable" +ATTR_VALUE = 'value' +ATTR_VALUE_TEMPLATE = 'value_template' +ATTR_ATTRIBUTES = "attributes" +ATTR_ATTRIBUTES_TEMPLATE = "attributes_template" +ATTR_REPLACE_ATTRIBUTES = "replace_attributes" + +SERVICE_SET_VARIABLE = "set_variable" +SERVICE_SET_VARIABLE_SCHEMA = vol.Schema({ + vol.Required(ATTR_VARIABLE): cv.string, + vol.Optional(ATTR_VALUE): cv.match_all, + vol.Optional(ATTR_VALUE_TEMPLATE): cv.template, + vol.Optional(ATTR_ATTRIBUTES): dict, + vol.Optional(ATTR_ATTRIBUTES_TEMPLATE): cv.template, + vol.Optional(ATTR_REPLACE_ATTRIBUTES): cv.boolean +}) + +CONFIG_SCHEMA = vol.Schema({ + DOMAIN: vol.Schema({ + cv.slug: vol.Any({ + vol.Optional(CONF_NAME): cv.string, + vol.Optional(CONF_VALUE): cv.match_all, + vol.Optional(CONF_ATTRIBUTES): dict, + vol.Optional(CONF_RESTORE): cv.boolean, + }, None) + }) +}, extra=vol.ALLOW_EXTRA) + +@bind_hass +def set_variable(hass, variable, value, value_template, attributes, attributes_template, replace_attributes): + """Set input_boolean to True.""" + hass.services.call(DOMAIN, SERVICE_SET_VARIABLE, { + ATTR_VARIABLE: variable, + ATTR_VALUE: value, + ATTR_VALUE_TEMPLATE: value_template, + ATTR_ATTRIBUTES: attributes, + ATTR_ATTRIBUTES_TEMPLATE: attributes_template, + ATTR_REPLACE_ATTRIBUTES: replace_attributes, + }) + +@asyncio.coroutine +def async_setup(hass, config): + """Set up variables.""" + component = EntityComponent(_LOGGER, DOMAIN, hass) + + entities = [] + + for variable_id, variable_config in config[DOMAIN].items(): + if not variable_config: + variable_config = {} + + name = variable_config.get(CONF_NAME) + value = variable_config.get(CONF_VALUE) + attributes = variable_config.get(CONF_ATTRIBUTES) + restore = variable_config.get(CONF_RESTORE, False) + + entities.append(Variable(variable_id, name, value, attributes, restore)) + + @asyncio.coroutine + def async_set_variable_service(call): + """Handle calls to the set_variable service.""" + + entity_id = ENTITY_ID_FORMAT.format(call.data.get(ATTR_VARIABLE)) + entity = component.entities[entity_id] + + if entity: + target_variables = [ entity ] + tasks = [variable.async_set_variable( + call.data.get(ATTR_VALUE), + call.data.get(ATTR_VALUE_TEMPLATE), + call.data.get(ATTR_ATTRIBUTES), + call.data.get(ATTR_ATTRIBUTES_TEMPLATE), + call.data.get(ATTR_REPLACE_ATTRIBUTES, False)) + for variable in target_variables] + if tasks: + yield from asyncio.wait(tasks, loop=hass.loop) + + else: + _LOGGER.warning('Failed to set unknown variable: %s', entity_id) + + hass.services.async_register( + DOMAIN, SERVICE_SET_VARIABLE, async_set_variable_service, + schema=SERVICE_SET_VARIABLE_SCHEMA) + + yield from component.async_add_entities(entities) + return True + +class Variable(Entity): + """Representation of a variable.""" + + def __init__(self, variable_id, name, value, attributes, restore): + """Initialize a variable.""" + self.entity_id = ENTITY_ID_FORMAT.format(variable_id) + self._name = name + self._value = value + self._attributes = attributes + self._restore = restore + + @asyncio.coroutine + def async_added_to_hass(self): + """Run when entity about to be added.""" + if self._restore == True: + state = yield from async_get_last_state(self.hass, self.entity_id) + if state: + self._value = state.state + + @property + def should_poll(self): + """If entity should be polled.""" + return False + + @property + def name(self): + """Return the name of the variable.""" + return self._name + + @property + def icon(self): + """Return the icon to be used for this entity.""" + if self._attributes is not None: + return self._attributes.get(ATTR_ICON) + else: + return None + + @property + def state(self): + """Return the state of the component.""" + return self._value + + @property + def state_attributes(self): + """Return the state attributes.""" + return self._attributes + + @asyncio.coroutine + def async_set_variable(self, value, value_template, attributes, attributes_template, replace_attributes): + """Update variable.""" + + current_state = self.hass.states.get(self.entity_id) + updated_attributes = None + updated_value = None + + if not replace_attributes and self._attributes is not None: + updated_attributes = dict(self._attributes) + + if attributes is not None: + if updated_attributes is not None: + updated_attributes.update(attributes) + else: + updated_attributes = attributes + + elif attributes_template is not None: + attributes_template.hass = self.hass + + try: + attributes = json.loads(attributes_template.async_render({ 'variable': current_state })) + + if isinstance(attributes, dict): + if updated_attributes is not None: + updated_attributes.update(attributes) + else: + updated_attributes = attributes + + except TemplateError as ex: + _LOGGER.error('Could not render attribute_template %s: %s', + self.entity_id, ex) + + if value is not None: + updated_value = value + + elif value_template is not None: + try: + value_template.hass = self.hass + updated_value = value_template.async_render({ 'variable': current_state }) + except TemplateError as ex: + _LOGGER.error('Could not render value_template %s: %s', + self.entity_id, ex) + + self._attributes = updated_attributes; + + if updated_value is not None: + self._value = updated_value; + + yield from self.async_update_ha_state() diff --git a/customize.yaml b/customize.yaml index 6ad0875..209ba6c 100644 --- a/customize.yaml +++ b/customize.yaml @@ -1,9 +1,43 @@ -sensor.date_friendly: - extra_data_template: ${entities['sensor.day'].state} -switch.dehumidifier: - homebridge_hidden: false - icon: mdi:cup-water - confirm_controls_show_lock: true +# +# Automations. +# +automation.cct: + icon: mdi:white-balance-auto +automation.check_door_left_open: + icon: mdi:door-open +automation.check_mold_conditions: + icon: mdi:biohazard +automation.check_update_availability: + icon: mdi:cloud-upload +automation.go_to_sleep: + icon: mdi:weather-night +automation.wake_up: + icon: mdi:weather-sunny + + +# +# Binary sensors. +# +binary_sensor.flic_80e4da737711: + friendly_name: Flic blue + + +# +# Cameras. +# +camera.environment_canada_rain: + friendly_name: Rain +camera.environment_canada_snow: + friendly_name: Snow +camera.noaa_geocolor: + friendly_name: GeoColor +camera.noaa_water_vapour: + friendly_name: Water Vapour + + +# +# Device trackers. +# device_tracker.cellphone_her: friendly_name: !secret nickname_her icon: mdi:cellphone-iphone @@ -11,37 +45,61 @@ device_tracker.cellphone_him: friendly_name: !secret nickname_him gravatar: !secret gravatar_him icon: mdi:cellphone-iphone -sensor.uptime_os: - icon: mdi:pi -sensor.ipv4_address_eth0: - friendly_name: Local IP Address -sensor.speedtest_ping: - friendly_name: Ping -sensor.speedtest_upload: - friendly_name: Upspeed - icon: mdi:upload-network -sensor.speedtest_download: - friendly_name: Downspeed - icon: mdi:download-network -sensor.ebox_upload_before_offpeak: - homebridge_hidden: false - friendly_name: Uploads -sensor.ebox_download_before_offpeak: - homebridge_hidden: false - friendly_name: Downloads -sensor.ebox_usage: - homebridge_hidden: false - friendly_name: Monthly usage -sensor.bedroom_temperature: - homebridge_hidden: false - icon: mdi:thermometer -sensor.bedroom_humidity: - homebridge_hidden: false - icon: mdi:water-percent -light.shower: - extra_data_template: if (attributes.brightness) return Math.round(1000000 / attributes.color_temp - / 10) * 10 + ' Kelvin @ ' + Math.round(attributes.brightness / 255 * 100) + '%'; - else return null; + + +# +# Groups. +# +group.configuration_view: + order: 5 +group.default_view: + order: 1 +group.status_view: + order: 4 +group.switchboard_view: + order: 2 +group.weather_view: + order: 3 + + +# +# Input booleans. +# +input_boolean.low_mode: + icon: mdi:weather-sunset-down +input_boolean.nap_mode: + icon: mdi:sleep +input_boolean.night_mode: + icon: mdi:weather-night +input_boolean.quiet_mode: + icon: mdi:volume-mute +input_boolean.scene_mode: + icon: mdi:looks + + +# +# Input selectors. +# +input_select.aurora_effect: + icon: mdi:blank +input_select.bed_effect: + friendly_name: Bed Effect + icon: mdi:blank +input_select.ceiling_effect: + friendly_name: Effect + icon: mdi:blank + + +# +# Lights. +# +light.aurora: + extra_data_template: >- + return (attributes.brightness) ? + attributes.effect + ' @ ' + + Math.round(attributes.brightness / 255 * 100) + '%' + : null; + icon: mdi:vector-triangle slider_theme: max: 255 min: 0 @@ -49,22 +107,11 @@ light.shower: pin: true report_when_not_changed: false state_card_mode: break-slider -switch.souvenirs_light: - homebridge_hidden: false - friendly_name: Souvenirs Light - icon: mdi:trophy -switch.bedside_light: - homebridge_hidden: false - icon: mdi:creation -switch.bedroom_fan: - homebridge_hidden: false - icon: mdi:fan -switch.nightstand_light: - homebridge_hidden: false - icon: mdi:lamp light.bedroom: - extra_data_template: if (attributes.brightness) return Math.round(attributes.brightness - / 255 * 100) + '%'; else return null; + extra_data_template: >- + return (entities['sensor.ceiling_effect_loaded'].state) ? + entities['sensor.ceiling_effect_loaded'].state + : null; icon: mdi:led-strip slider_theme: max: 255 @@ -72,10 +119,52 @@ light.bedroom: off_when_min: true pin: true report_when_not_changed: false - state_card_mode: break-slider +light.countertop: + extra_data_template: >- + return (attributes.brightness) ? + Math.round(650 - (attributes.color_temp - 154) * 380 / 346) * 10 + ' K @ ' + + Math.round(attributes.brightness / 255 * 100) + '%' + : null; + icon: mdi:border-top + slider_theme: + max: 255 + min: 0 + off_when_min: true + pin: true + report_when_not_changed: false +light.island: + extra_data_template: >- + return (attributes.brightness) ? + Math.round(650 - (attributes.color_temp - 154) * 380 / 346) * 10 + ' K @ ' + + Math.round(attributes.brightness / 255 * 100) + '%' + : null; + icon: mdi:table-column + slider_theme: + max: 255 + min: 0 + off_when_min: true + pin: true + report_when_not_changed: false +light.headboard: + extra_data_template: >- + return (entities['sensor.bed_effect_loaded'].state) ? + entities['sensor.bed_effect_loaded'].state + : null; + icon: mdi:gate + slider_theme: + max: 255 + min: 0 + off_when_min: true + pin: true + report_when_not_changed: false +light.lightpack: + homebridge_hidden: false + icon: mdi:television light.lounge: - extra_data_template: if (attributes.brightness) return Math.round(attributes.brightness - / 255 * 100) + '%'; else return null; + extra_data_template: >- + return (entities['sensor.ceiling_effect_loaded'].state) ? + entities['sensor.ceiling_effect_loaded'].state + : null; icon: mdi:led-strip slider_theme: max: 255 @@ -83,10 +172,24 @@ light.lounge: off_when_min: true pin: true report_when_not_changed: false - state_card_mode: break-slider +light.microwave: + extra_data_template: >- + return (attributes.brightness) ? + Math.round(650 - (attributes.color_temp - 154) * 380 / 346) * 10 + ' K @ ' + + Math.round(attributes.brightness / 255 * 100) + '%' + : null; + icon: mdi:gradient + slider_theme: + max: 255 + min: 0 + off_when_min: true + pin: true + report_when_not_changed: false light.middle: - extra_data_template: if (attributes.brightness) return Math.round(attributes.brightness - / 255 * 100) + '%'; else return null; + extra_data_template: >- + return (entities['sensor.ceiling_effect_loaded'].state) ? + entities['sensor.ceiling_effect_loaded'].state + : null; icon: mdi:led-strip slider_theme: max: 255 @@ -94,11 +197,40 @@ light.middle: off_when_min: true pin: true report_when_not_changed: false +light.shower: + extra_data_template: >- + return (attributes.brightness) ? + Math.round(1000000 / attributes.color_temp / 10) * 10 + ' K @ ' + + Math.round(attributes.brightness / 255 * 100) + '%' + : null; + icon: mdi:spotlight + slider_theme: + max: 255 + min: 0 + off_when_min: true + pin: true + report_when_not_changed: false state_card_mode: break-slider +light.sink: + extra_data_template: >- + return (attributes.brightness) ? + Math.round(650 - (attributes.color_temp - 154) * 380 / 346) * 10 + ' K @ ' + + Math.round(attributes.brightness / 255 * 100) + '%' + : null; + icon: mdi:water-pump + slider_theme: + max: 255 + min: 0 + off_when_min: true + pin: true + report_when_not_changed: false light.spotlight: - extra_data_template: if (attributes.brightness) return Math.round(1000000 / attributes.color_temp - / 10) * 10 + ' Kelvin @ ' + Math.round(attributes.brightness / 255 * 100) + '%'; - else return null; + extra_data_template: >- + return (attributes.brightness) ? + Math.round(1000000 / attributes.color_temp / 10) * 10 + ' K @ ' + + Math.round(attributes.brightness / 255 * 100) + '%' + : null; + icon: mdi:spotlight-beam slider_theme: max: 255 min: 0 @@ -106,44 +238,185 @@ light.spotlight: pin: true report_when_not_changed: false state_card_mode: break-slider -light.lightpack: +light.underbed: + extra_data_template: >- + return (entities['sensor.bed_effect_loaded'].state) ? + entities['sensor.bed_effect_loaded'].state + : null; + icon: mdi:hotel + slider_theme: + max: 255 + min: 0 + off_when_min: true + pin: true + report_when_not_changed: false + +# +# Sensors. +# +sensor.bedroom_multisensor_battery: + group: + group.battery: + friendly_name: Bedroom + icon: mdi:hotel + group.bedroom: + friendly_name: Multisensor Battery +sensor.front_door_sensor_battery: + group: + group.battery: + friendly_name: Front Door + icon: mdi:door + group.kitchen: + friendly_name: Front Door Battery +sensor.lounge_multisensor_battery: + group: + group.battery: + friendly_name: Lounge + icon: mdi:sofa + group.lounge: + friendly_name: Multisensor Battery +sensor.bing_wallpaper_info: + custom_ui_state_card: state-card-value_only +sensor.date_friendly: + extra_data_template: >- + ${entities['sensor.day'].state} +sensor.good_vibes: + custom_ui_state_card: state-card-value_only + + +# Sensors: Climate. +sensor.average_humidity: + group: + group.humidity: + friendly_name: Average +sensor.average_humidity_friendly: + extra_badge: + entity_id: sensor.average_humidity +sensor.average_temperature: + group: + group.temperature: + friendly_name: Average +sensor.bedroom_humidity: homebridge_hidden: false - icon: mdi:television -switch.window_light: - icon: mdi:creation -binary_sensor.flic_80e4da737711: - friendly_name: Flic blue + icon: mdi:water-percent + group: + group.bedroom: + friendly_name: Humidity + group.humidity: + friendly_name: Bedroom + icon: mdi:hotel +sensor.bedroom_temperature: + homebridge_hidden: false + icon: mdi:thermometer + group: + group.bedroom: + friendly_name: Temperature + group.temperature: + friendly_name: Bedroom + icon: mdi:hotel +sensor.lounge_humidity: + homebridge_hidden: false + icon: mdi:water-percent + group: + group.lounge: + friendly_name: Humidity + group.humidity: + friendly_name: Lounge + icon: mdi:sofa +sensor.lounge_temperature: + homebridge_hidden: false + icon: mdi:thermometer + group: + group.lounge: + friendly_name: Temperature + group.temperature: + friendly_name: Lounge + icon: mdi:sofa + +# Sensors: Outdoor Life Quality. +sensor.aqi_carbon_monoxide_friendly: + extra_data_template: >- + return entities['sensor.aqi_carbon_monoxide'].state != 'unknown' ? + entities['sensor.aqi_carbon_monoxide'].state + ' ' + + entities['sensor.aqi_carbon_monoxide'].attributes['unit_of_measurement'] + : null; sensor.aqi_friendly: extra_badge: entity_id: sensor.aqi -sensor.aqi_particles_friendly: - extra_badge: - entity_id: sensor.aqi_particles -sensor.aqi_ozone_friendly: - extra_badge: - entity_id: sensor.aqi_ozone -sensor.aqi_carbon_monoxide_friendly: - extra_badge: - entity_id: sensor.aqi_carbon_monoxide sensor.aqi_nitrogen_dioxide_friendly: - extra_badge: - entity_id: sensor.aqi_nitrogen_dioxide + extra_data_template: >- + return entities['sensor.aqi_nitrogen_dioxide'].state != 'unknown' ? + entities['sensor.aqi_nitrogen_dioxide'].state + ' ' + + entities['sensor.aqi_nitrogen_dioxide'].attributes['unit_of_measurement'] + : null; +sensor.aqi_ozone_friendly: + extra_data_template: >- + return entities['sensor.aqi_ozone'].state != 'unknown' ? + entities['sensor.aqi_ozone'].state + ' ' + + entities['sensor.aqi_ozone'].attributes['unit_of_measurement'] + : null; +sensor.aqi_particles_friendly: + extra_data_template: >- + return entities['sensor.aqi_particles'].state != 'unknown' ? + entities['sensor.aqi_particles'].state + ' ' + + entities['sensor.aqi_particles'].attributes['unit_of_measurement'] + : null; sensor.uv_friendly: extra_badge: entity_id: sensor.uv -sensor.home_to_metro_hour: - extra_badge: - entity_id: sensor.home_to_metro -sensor.home_to_metro_2_hour: - icon: mdi:blank - friendly_name: Next - extra_badge: - entity_id: sensor.home_to_metro_2_countdown -sensor.home_to_metro_3_hour: - icon: mdi:blank - friendly_name: After - extra_badge: - entity_id: sensor.home_to_metro_3_countdown + +# Sensors: System. +sensor.cpu_used: + friendly_name: CPU Load + icon: mdi:chip + extra_data_template: >- + return + parseFloat(entities['sensor.average_load_1m'].state).toFixed(2) + ' ' + + parseFloat(entities['sensor.average_load_5m'].state).toFixed(2) + ' ' + + parseFloat(entities['sensor.average_load_15m'].state).toFixed(2) + ' ' + + '(' + entities['sensor.cpu_cores'].state + ' cores)'; +sensor.database_size: + icon: mdi:database +sensor.disk_used_percent: + extra_data_template: >- + return + Math.round(parseFloat(entities['sensor.disk_free_home'].state)) + ' ' + + entities['sensor.disk_free_home'].attributes['unit_of_measurement'] + + ' available'; +sensor.ebox_download_before_offpeak: + homebridge_hidden: false + friendly_name: Downloads +sensor.ebox_upload_before_offpeak: + homebridge_hidden: false + friendly_name: Uploads +sensor.ebox_usage: + homebridge_hidden: false + friendly_name: Monthly usage +sensor.ipv4_address_eth0: + friendly_name: Local IP Address +sensor.logfile_size: + icon: mdi:history +sensor.ram_used_percent: + extra_data_template: >- + return + Math.round(parseFloat(entities['sensor.ram_available'].state)) + ' ' + + entities['sensor.ram_available'].attributes['unit_of_measurement'] + + ' available'; +sensor.speedtest_download: + friendly_name: Downspeed + icon: mdi:download-network + show_last_changed: true +sensor.speedtest_ping: + friendly_name: Ping + show_last_changed: true +sensor.speedtest_upload: + friendly_name: Upspeed + icon: mdi:upload-network + show_last_changed: true +sensor.uptime_os: + icon: mdi:pi + +# Sensors: Transit. sensor.home_to_market_hour: icon: mdi:cart extra_badge: @@ -158,51 +431,86 @@ sensor.home_to_market_3_hour: friendly_name: After extra_badge: entity_id: sensor.home_to_market_3_countdown -sensor.wind_speed: +sensor.home_to_metro_hour: extra_badge: - entity_id: sensor.wind_bearing_cardinal - extra_data_template: ${entities['sensor.wind_scale_friendly'].state} -sensor.outside_temperature: - extra_data_template: ${entities['sensor.feels_like'].state} -sensor.dark_sky_summary: - friendly_name: Summary - extra_data_template: ${entities['sensor.dark_sky_minutely_summary'].state} -camera.environment_canada_rain: - friendly_name: Rain -camera.environment_canada_snow: - friendly_name: Snow -camera.noaa_geocolor: - friendly_name: GeoColor -camera.noaa_water_vapour: - friendly_name: Water Vapour -sensor.dark_sky_hourly_summary: - friendly_name: 24h Summary + entity_id: sensor.home_to_metro +sensor.home_to_metro_2_hour: + icon: mdi:blank + friendly_name: Next + extra_badge: + entity_id: sensor.home_to_metro_2_countdown +sensor.home_to_metro_3_hour: + icon: mdi:blank + friendly_name: After + extra_badge: + entity_id: sensor.home_to_metro_3_countdown + +# Sensors: Weather +sensor.weather_details: + custom_ui_state_card: state-card-value_only +sensor.dark_sky_minutely_summary: + custom_ui_state_card: state-card-value_only sensor.dark_sky_daily_summary: friendly_name: Weekly Forecast - extra_data_template: ${entities['sensor.dark_sky_daily_summary'].state} + extra_data_template: >- + ${entities['sensor.dark_sky_daily_summary'].state} hide_control: true -sensor.average_humidity_friendly: + custom_ui_state_card: state-card-value_only +sensor.dark_sky_hourly_summary: + friendly_name: 24h Summary + custom_ui_state_card: state-card-value_only +sensor.dark_sky_summary: + friendly_name: " " + extra_data_template: >- + ${entities['sensor.outside_temperature'].state}${entities['sensor.outside_temperature'].attributes['unit_of_measurement']} +sensor.wind_speed: + friendly_name: " " extra_badge: - entity_id: sensor.average_humidity -input_select.aurora_effect: - extra_data_template: ${entities['sensor.aurora_effect'].state} - icon: mdi:blank -light.aurora: - extra_data_template: if (attributes.brightness) return attributes.effect + ' @ ' - + Math.round(attributes.brightness / 255 * 100) + '%'; else return null; - icon: mdi:vector-triangle - slider_theme: - max: 255 - min: 0 - off_when_min: true - pin: true - report_when_not_changed: false - state_card_mode: break-slider -group.all_automations: {} -input_select.ceiling_effect: - friendly_name: Effect -group.ceiling: {} -sensor.database_size: - icon: mdi:database -sensor.logfile_size: - icon: mdi:history + entity_id: sensor.wind_bearing_cardinal + extra_data_template: >- + ${entities['sensor.wind_scale_friendly'].state} + + +# +# Scenes. +# +scene.romantic: + icon: mdi:heart +scene.shutdown: + icon: mdi:power + + +# +# Scripts. +# +script.go_to_sleep: + icon: mdi:weather-night +script.wake_up: + icon: mdi:weather-sunny + + +# +# Switches. +# +switch.bedroom_fan: + homebridge_hidden: false + icon: mdi:fan + group: + group.bedroom: + friendly_name: Fan +switch.bedside_light: + homebridge_hidden: false + icon: mdi:creation +switch.dehumidifier: + homebridge_hidden: false + icon: mdi:water-off + confirm_controls_show_lock: true +switch.nightstand_light: + homebridge_hidden: false + icon: mdi:page-layout-body +switch.souvenirs_light: + homebridge_hidden: false + friendly_name: Souvenirs Light + icon: mdi:trophy +switch.window_light: + icon: mdi:creation diff --git a/customize_glob.yaml b/customize_glob.yaml index a1028b8..7a57635 100644 --- a/customize_glob.yaml +++ b/customize_glob.yaml @@ -1,20 +1,81 @@ +# +# Global. +# "*.*": custom_ui_state_card: state-card-custom-ui + + +# +# Automations. +# +automation.*: + extra_data_template: >- + return attributes.last_triggered ? window.hassUtil.relativeTime(new Date(attributes.last_triggered)) : null; +automation.aurora_*: + icon: mdi:vector-triangle +automation.bed_*: + icon: mdi:hotel +automation.bedroom_*: + icon: mdi:hotel +automation.ceiling_*: + icon: mdi:led-strip +automation.check_humidity_*: + icon: mdi:water-percent +automation.dehumidifier_*: + icon: mdi:water-off +automation.front_door_*: + icon: mdi:door +automation.lounge_*: + icon: mdi:sofa +automation.low_power_mode_*: + icon: mdi:weather-sunset-down +automation.media_player_*: + icon: mdi:kodi +automation.nap_mode_*: + icon: mdi:sleep +automation.nightlight_*: + icon: mdi:walk +automation.night_mode_*: + icon: mdi:weather-night +automation.quiet_mode_*: + icon: mdi:volume-mute +automation.washroom_*: + icon: mdi:water-pump + + +# +# Input Booleans. +# +input_boolean.*: + show_last_changed: true + + +# +# Sensors. +# +sensor.*_fan: + group: + group.bedroom: + friendly_name: Fan sensor.*_humidity: group: group.bedroom: friendly_name: Humidity + # group.humidity: + # friendly_name: Humidity group.lounge: friendly_name: Humidity -sensor.*_temperature: - group: - group.bedroom: - friendly_name: Temperature - group.lounge: - friendly_name: Temperature sensor.*_luminance: group: group.bedroom: friendly_name: Luminance group.lounge: friendly_name: Luminance +sensor.*_temperature: + group: + group.bedroom: + friendly_name: Temperature + group.lounge: + friendly_name: Temperature + # group.temperature: + # friendly_name: Temperature diff --git a/groups/configuration.yaml b/groups/configuration.yaml new file mode 100644 index 0000000..692f234 --- /dev/null +++ b/groups/configuration.yaml @@ -0,0 +1,94 @@ +# +# View. +# +configuration_view: + view: yes + name: Configuration + icon: mdi:settings + entities: + - group.modes + - group.automations + - group.automations_modes + - group.automations_devices + - group.automations_areas + + +# +# Groups. +# +modes: + name: Modes + control: hidden + entities: + - input_boolean.night_mode + - input_boolean.nap_mode + - input_boolean.quiet_mode + - input_boolean.low_mode + - input_boolean.scene_mode + +automations: + name: Automations + control: hidden + entities: + - automation.cct + - automation.check_door_left_open + - automation.check_humidity_high + - automation.check_humidity_low + - automation.check_mold_conditions + - automation.check_update_availability + - automation.front_door_closed + - automation.front_door_opened + - automation.go_to_sleep + - automation.wake_up + +automations_areas: + name: Areas Automations + control: hidden + entities: + - automation.bedroom_low_power + - automation.bedroom_off + - automation.bedroom_on + - automation.ceiling_default + - automation.ceiling_effect + - automation.ceiling_off + - automation.ceiling_on + - automation.ceiling_schedule + - automation.ceiling_select + - automation.lounge_low_power + - automation.lounge_off + - automation.lounge_on + - automation.washroom_low_power + - automation.washroom_off + - automation.washroom_on + +automations_devices: + name: Devices Automations + control: hidden + entities: + - automation.aurora_brightness + - automation.aurora_default + - automation.aurora_effect + - automation.aurora_schedule + - automation.aurora_select + - automation.bed_default + - automation.bed_effect + - automation.bed_schedule + - automation.bed_select + - automation.dehumidifier_off + - automation.dehumidifier_on + - automation.media_player_resume + - automation.media_player_start + - automation.media_player_stop + - automation.nightlight_off + - automation.nightlight_on + +automations_modes: + name: Modes Automations + control: hidden + entities: + - automation.low_power_mode_start + - automation.low_power_mode_stop + - automation.quiet_mode_start + - automation.quiet_mode_stop + - automation.nap_mode_start + - automation.nap_mode_stop diff --git a/groups/default.yaml b/groups/default.yaml new file mode 100644 index 0000000..5e3eec6 --- /dev/null +++ b/groups/default.yaml @@ -0,0 +1,75 @@ +# +# View. +# +default_view: + view: yes + icon: mdi:home-assistant + entities: + - group.notifications + - group.wallpaper + - group.now + - group.public_transit + - group.climate + - group.actions + + +# +# Groups. +# +actions: + name: Actions + control: hidden + entities: + - scene.romantic + - scene.shutdown + - script.wake_up + - script.go_to_sleep + - script.take_a_nap + +climate: + name: Climate Control + entities: + - sensor.average_temperature + - sensor.average_humidity_friendly + - switch.dehumidifier + +notifications: + name: Notifications + entities: + - persistent_notification.humidity + +public_transit: + name: Public Transit + entities: + - sensor.home_to_metro_hour + - sensor.home_to_metro_2_hour + - sensor.home_to_metro_3_hour + - sensor.home_to_market_hour + - sensor.home_to_market_2_hour + - sensor.home_to_market_3_hour + +wallpaper: + name: " " + entities: + - camera.bing_wallpaper + - sensor.bing_wallpaper_info + +now: + name: " " + entities: + - sensor.date_friendly + - sensor.time_friendly + - sensor.sun_state + +# media: +# name: Media +# entities: +# - media_player.kodi +# - media_player.plex +# - sensor.plex_htpc + +# presence: +# name: Presence +# entities: +# - device_tracker.cellphone_him +# - device_tracker.cellphone_her diff --git a/groups/groups.yaml b/groups/groups.yaml deleted file mode 100644 index 68dc5a2..0000000 --- a/groups/groups.yaml +++ /dev/null @@ -1,208 +0,0 @@ -public_transit: - name: Public transit - entities: - - sensor.home_to_metro_hour - - sensor.home_to_metro_2_hour - - sensor.home_to_metro_3_hour - - sensor.home_to_market_hour - - sensor.home_to_market_2_hour - - sensor.home_to_market_3_hour - -life_quality: - name: Outdoor Life Quality - entities: - - sensor.doomsday_clock - - sensor.aqi_friendly - - sensor.aqi_particles_friendly - - sensor.aqi_ozone_friendly - - sensor.aqi_carbon_monoxide_friendly - - sensor.aqi_nitrogen_dioxide_friendly - - sensor.uv_friendly - -ceiling: - name: Ceiling washlights - entities: - - input_select.ceiling_effect - - light.bedroom - - light.middle - - light.lounge - -lounge: - name: Lounge - entities: - - light.aurora - - input_select.aurora_effect - - light.spotlight - - light.lightpack - - switch.souvenirs_light - - switch.window_light - - sensor.lounge_humidity - - sensor.lounge_temperature - - sensor.lounge_luminance - -notifications: - name: notifications - entities: - - persistent_notification.humidity - -bedroom: - name: Bedroom - entities: - - switch.nightstand_light - - switch.bedside_light - - switch.bedroom_fan - - sensor.bedroom_humidity - - sensor.bedroom_temperature - -washroom: - name: Washroom - entities: - - light.shower - -climate: - name: Climate control - entities: - - sensor.average_humidity_friendly - - sensor.average_temperature - - switch.dehumidifier - -humidity: - name: Humidity - entities: - - sensor.average_humidity - - sensor.bedroom_humidity - - sensor.aeotec_zw100_multisensor_6_relative_humidity - -temperature: - name: Temperature - entities: - - sensor.average_temperature - - sensor.bedroom_temperature - - sensor.aeotec_zw100_multisensor_6_temperature - -automations: - name: Automations - control: hidden - entities: - - automation.adjust_white_light_temperature - - automation.apply_effect_to_ceiling_washlight - - automation.apply_aurora_brightness - - automation.apply_aurora_effect - - automation.check_high_humidity - - automation.check_low_humidity - - automation.declare_quiet_time - - automation.default_ceiling_washlight_effect - - automation.default_aurora_effect - - automation.dehumidify - - automation.door_left_open - - automation.end_quiet_time - - automation.front_door_closes - - automation.front_door_opens - - automation.go_to_sleep - - automation.media_player_pausedstopped - - automation.media_player_resumes - - automation.media_player_starts - - automation.mold_conditions - - automation.nap_time - - automation.nap_time_over - - automation.rotate_ceiling_washlights_based_on_a_schedule - - automation.rotate_aurora_based_on_a_schedule - - automation.select_ceiling_washlight_effect - - automation.select_aurora_effect - - automation.stop_dehumidifying - - automation.turn_off_night_lights - - automation.turn_on_night_lights - - automation.update_available - - automation.wake_up - -scripts: - name: Scripts - control: hidden - entities: - - script.wake_up - - script.go_to_sleep - - script.take_a_nap - -# media: -# name: Media -# entities: -# - media_player.kodi -# - media_player.plex -# - sensor.plex_htpc - -net_status: - name: Net Status - icon: mdi:home-assistant - entities: - - sensor.speedtest_ping - - sensor.speedtest_upload - - sensor.speedtest_download - # - sensor.fastcom_download - - sensor.ebox_upload_before_offpeak - - sensor.ebox_download_before_offpeak - - sensor.ebox_usage_friendly - - sensor.ebox_download_remaining - - sensor.ebox_download_daily_capacity - -# presence: -# name: Presence -# entities: -# - device_tracker.cellphone_him -# - device_tracker.cellphone_her - -scenes: - name: Scenes - control: hidden - entities: - - scene.romantic - - scene.shutdown - - input_boolean.night_mode - - input_boolean.nap_mode - - input_boolean.quiet_mode - - input_boolean.scene_mode - -status: - name: Status - entities: - - sensor.good_vibes - - sensor.date_friendly - - sensor.time_friendly - - sensor.sun_state - -system: - name: System - icon: mdi:home-assistant - entities: - - sensor.ipv4_address_eth0 - - sensor.uptime_friendly - - sensor.uptime_host - - sensor.cpu_temp - - sensor.cpu_used - - sensor.ram_free_percent - - sensor.disk_free_percent - - sensor.database_size - - sensor.logfile_size - -weather: - name: Current Weather - entities: - - sensor.dark_sky_summary - - sensor.outside_temperature - - sensor.outside_humidity - - sensor.wind_speed - - sensor.dark_sky_hourly_summary - - sensor.dark_sky_daily_summary - # - sensor.moon - -weather_forecast: - name: Weekly Forecast - entities: - - sensor.dark_sky_daily_summary - -weather_maps: - name: Weather Maps - entities: - - camera.environment_canada_rain - - camera.environment_canada_snow - - camera.noaa_geocolor - - camera.noaa_water_vapour diff --git a/groups/status.yaml b/groups/status.yaml new file mode 100644 index 0000000..b261d2f --- /dev/null +++ b/groups/status.yaml @@ -0,0 +1,68 @@ +# +# View. +# +status_view: + view: yes + name: Status + icon: mdi:server + entities: + - group.system + - group.network + - group.battery + - group.humidity + - group.temperature + + +# +# Groups. +# +battery: + name: Battery Levels + entities: + - sensor.front_door_sensor_battery + - sensor.bedroom_multisensor_battery + - sensor.lounge_multisensor_battery + + +humidity: + name: Humidity + entities: + - sensor.average_humidity + - sensor.bedroom_humidity + - sensor.lounge_humidity + +network: + name: Network + icon: mdi:home-assistant + entities: + - sensor.speedtest_ping + - sensor.speedtest_upload + - sensor.speedtest_download + # - sensor.fastcom_download + - sensor.ebox_upload_before_offpeak + - sensor.ebox_download_before_offpeak + - sensor.ebox_usage_friendly + - sensor.ebox_download_remaining + - sensor.ebox_download_daily_capacity + +system: + name: System + icon: mdi:home-assistant + entities: + - updater.updater + - sensor.ipv4_address_eth0 + - sensor.uptime_friendly + - sensor.uptime_host + - sensor.cpu_temp + - sensor.cpu_used + - sensor.ram_used_percent + - sensor.disk_used_percent + - sensor.database_size + - sensor.logfile_size + +temperature: + name: Temperature + entities: + - sensor.average_temperature + - sensor.bedroom_temperature + - sensor.lounge_temperature diff --git a/groups/switchboard.yaml b/groups/switchboard.yaml new file mode 100644 index 0000000..9184f8a --- /dev/null +++ b/groups/switchboard.yaml @@ -0,0 +1,70 @@ +# +# View. +# +switchboard_view: + view: yes + name: Switchboard + icon: mdi:nintendo-switch + entities: + - group.ceiling + - group.washroom + - group.kitchen + - group.lounge + - group.bedroom + + +# +# Groups. +# +bed: + name: Bed + entities: + - input_select.bed_effect + - light.underbed + - light.headboard + +bedroom: + name: Bedroom + entities: + - input_select.bed_effect + - light.underbed + - light.headboard + - switch.nightstand_light + - switch.bedside_light + - switch.bedroom_fan + - sensor.bedroom_temperature + - sensor.bedroom_humidity + +ceiling: + name: Ceiling + entities: + - input_select.ceiling_effect + - light.bedroom + - light.middle + - light.lounge + +kitchen: + name: Kitchen + entities: + - light.countertop + - light.sink + - light.microwave + - light.island + +lounge: + name: Lounge + entities: + - input_select.aurora_effect + - light.aurora + - light.spotlight + - light.lightpack + - switch.souvenirs_light + - switch.window_light + - sensor.lounge_temperature + - sensor.lounge_humidity + - sensor.lounge_luminance + +washroom: + name: Washroom + entities: + - light.shower diff --git a/groups/views.yaml b/groups/views.yaml deleted file mode 100644 index 96fb9f9..0000000 --- a/groups/views.yaml +++ /dev/null @@ -1,47 +0,0 @@ -default_view: - view: yes - icon: mdi:home-assistant - entities: - - group.notifications - - group.status - - group.public_transit - - group.climate - - group.scripts - - group.scenes - -switchboard_view: - view: yes - name: Switchboard - icon: mdi:nintendo-switch - entities: - - group.ceiling - - group.climate - - group.washroom - - group.bedroom - - group.lounge - -weather_view: - view: yes - name: Weather - icon: mdi:weather-partlycloudy - entities: - - group.life_quality - - group.weather - - group.weather_forecast - - group.weather_maps - -status_view: - view: yes - name: System Status - icon: mdi:server - entities: - - group.system - - group.net_status - -configuration_view: - view: yes - name: Configuration - icon: mdi:settings - entities: - - group.automations - - group.all_automations diff --git a/groups/weather.yaml b/groups/weather.yaml new file mode 100644 index 0000000..664b8c6 --- /dev/null +++ b/groups/weather.yaml @@ -0,0 +1,67 @@ +# +# View. +# +weather_view: + view: yes + name: Weather + icon: mdi:weather-partlycloudy + entities: + - group.weather + - group.radar_rain + - group.radar_snow + - group.atmospheric_safety + - group.weather_forecast + - group.satellite_geocolor + - group.satellite_water + + +# +# Groups. +# +atmospheric_safety: + name: Atmospheric Safety + entities: + - sensor.doomsday_clock + - sensor.uv_friendly + - sensor.aqi_friendly + - sensor.aqi_particles_friendly + - sensor.aqi_ozone_friendly + - sensor.aqi_carbon_monoxide_friendly + - sensor.aqi_nitrogen_dioxide_friendly + +radar_rain: + name: Rain Radar Map + entities: + - camera.environment_canada_rain + +radar_snow: + name: Snow Radar Map + entities: + - camera.environment_canada_snow + +satellite_geocolor: + name: Geocolor Satellite Map + entities: + - camera.noaa_geocolor + +satellite_water: + name: Water Vapour Satellite Map + entities: + - camera.noaa_water_vapour + +weather: + name: " " + entities: + - sensor.dark_sky_summary + - sensor.weather_details + # - sensor.outside_temperature + - sensor.outside_humidity + - sensor.wind_speed + - sensor.dark_sky_hourly_summary + # - sensor.moon + + +weather_forecast: + name: Weekly Forecast + entities: + - sensor.dark_sky_daily_summary diff --git a/lights/limitlessled.yaml b/lights/limitlessled.yaml new file mode 100644 index 0000000..50c04c5 --- /dev/null +++ b/lights/limitlessled.yaml @@ -0,0 +1,21 @@ +- platform: limitlessled + bridges: + - host: !secret limitleddled_bridge_host + port: !secret limitleddled_bridge_port + groups: + - number: 4 + type: white + name: Island + fade: on + - number: 1 + type: white + name: Countertop + fade: on + - number: 2 + type: white + name: Sink + fade: on + - number: 3 + type: white + name: Microwave + fade: on diff --git a/misc/binary_sensors.yaml b/misc/binary_sensors.yaml index 6de8739..6847cf4 100644 --- a/misc/binary_sensors.yaml +++ b/misc/binary_sensors.yaml @@ -1,4 +1,6 @@ # Flic smart button - platform: flic + host: !secret flic_host + port: !secret flic_port discovery: true timeout: 3 diff --git a/misc/input_boolean.yaml b/misc/input_boolean.yaml index a177157..f4a326b 100644 --- a/misc/input_boolean.yaml +++ b/misc/input_boolean.yaml @@ -1,7 +1,3 @@ -alert_mode: - name: Alert mode - initial: off - windows_open: name: Windows are open initial: off @@ -14,14 +10,18 @@ scene_mode: name: Scene mode initial: off -night_mode: - name: Night mode +low_mode: + name: Low power mode initial: off nap_mode: name: Nap mode initial: off +night_mode: + name: Night mode + initial: off + quiet_mode: name: Quiet mode initial: off @@ -30,16 +30,12 @@ update_available: name: Update available initial: off -aurora_semaphore: - name: Aurora is being updated - initial: off - aurora_effect_override: name: Aurora has overriding effect set initial: off -ceiling_semaphore: - name: Ceiling washlights are being updated +bed_effect_override: + name: Bed washlights have overriding effect set initial: off ceiling_effect_override: diff --git a/misc/input_select.yaml b/misc/input_select.yaml index bd9e9fb..9e79269 100644 --- a/misc/input_select.yaml +++ b/misc/input_select.yaml @@ -42,12 +42,22 @@ aurora_effect: initial: Auto icon: mdi:star +bed_effect: + name: Bed Washlights Effect + options: + - Auto + - Neon + - Reading + - Relaxing + - Warming + initial: Auto + icon: mdi:motel + ceiling_effect: name: Ceiling Washlights Effect options: - Auto - Blissful - - Aurora - Celebrations - Cheerful - Daylight @@ -55,6 +65,7 @@ ceiling_effect: - Intense - Mellow - Movie + - Northen Lights - Powerful - Relaxing - Serene diff --git a/misc/variables.yaml b/misc/variables.yaml new file mode 100644 index 0000000..a42931d --- /dev/null +++ b/misc/variables.yaml @@ -0,0 +1,34 @@ +# +# Nanoleaf Aurora effect. +# +aurora_effect: + value: False + restore: true + + +# +# Nanoleaf Aurora brightness. +# +aurora_brightness: + value: False + restore: true + + +# +# Bed wash lights effect. +# +bed_effect: + value: False + restore: true + attributes: + uuid: '' + + +# +# Ceiling wash lights effect. +# +ceiling_effect: + value: False + restore: true + attributes: + uuid: '' diff --git a/scripts/take_a_nap.yaml b/scripts/take_a_nap.yaml index f9cb76d..a880dbd 100644 --- a/scripts/take_a_nap.yaml +++ b/scripts/take_a_nap.yaml @@ -1,38 +1,28 @@ -take_a_nap: - alias: Take a nap - sequence: - - event: LOGBOOK_ENTRY - event_data: - name: EVENT - message: "Nap Time! Turning some lights and noises off." - - # - service: notify.group +# take_a_nap: +# alias: Take a nap +# sequence: + # # Turn off smart lights that might interfere with sleep. + # - service: light.turn_off # data: - # message: "Nap Time! Turning some lights and noises off." - - - service: light.turn_off - data: - entity_id: - - light.shower - - light.bedroom - - light.lounge - - light.middle - transition: 10 - - - service: switch.turn_off - data: - entity_id: - - switch.dehumidifier + # entity_id: + # - light.headboard + # - light.underbed + # - light.bedroom + # - light.lounge + # - light.middle + # - light.shower + # - light.aurora + # transition: 10 - - service: switch.turn_off - data: - entity_id: - - light.aurora - - switch.bedroom_fan - - switch.nightstand_light - - switch.bedside_light + # # Turn off binary devices in bedroom. + # - service: switch.turn_off + # data: + # entity_id: + # - switch.bedroom_fan + # - switch.nightstand_light + # - switch.bedside_light - # Enable nap mode. - - service: input_boolean.turn_on - data: - entity_id: input_boolean.nap_mode + # # Enable nap mode. + # - service: input_boolean.turn_on + # data: + # entity_id: input_boolean.nap_mode diff --git a/scripts/wake_up.yaml b/scripts/wake_up.yaml index 7e9e792..20b211a 100644 --- a/scripts/wake_up.yaml +++ b/scripts/wake_up.yaml @@ -1,20 +1,16 @@ wake_up: alias: Wake up sequence: - - event: LOGBOOK_ENTRY - event_data: - name: EVENT - message: "Good Morning! Turning lights and fan on." - - # - service: notify.group - # data: - # message: "Good Morning! Turning lights and fan on." - # Disable night mode. - service: input_boolean.turn_off data: entity_id: input_boolean.night_mode + # Disable nap mode. + - service: input_boolean.turn_off + data: + entity_id: input_boolean.nap_mode + # Disable quiet mode. - service: input_boolean.turn_off data: @@ -24,11 +20,13 @@ wake_up: - service: light.turn_on data: entity_id: - - light.shower - - light.spotlight + - light.headboard + - light.underbed - light.bedroom - light.lounge - light.middle + - light.shower + - light.spotlight - light.aurora - light.lightpack transition: 5 diff --git a/secrets-dummy.yaml b/secrets-dummy.yaml index a67f763..0ed5a66 100644 --- a/secrets-dummy.yaml +++ b/secrets-dummy.yaml @@ -16,12 +16,16 @@ ebox_password: "" environment_canada_radar: "" +flic_host: "" +flic_port: 12345 + gtfs_data: "" gtfs_origin_1: "" gtfs_destination_1: "" gtfs_origin_2: "" gtfs_destination_2: "" +gravatar_her: "" gravatar_him: "" http_password: "" @@ -36,6 +40,9 @@ kodi_password: "" lifx_cloud_token: "" +limitleddled_bridge_host: "" +limitleddled_bridge_port: 12345 + lightpack_host: "" lightpack_port: 12345 lightpack_api_key: "" @@ -43,6 +50,8 @@ lightpack_on: "" lightpack_off: "" lightpack_state: "" +mqtt_broker: "" +mqtt_port: 12345 mqtt_username: "" mqtt_password: "" diff --git a/sensors/calendar.yaml b/sensors/calendar.yaml index c547f9c..eca1f81 100644 --- a/sensors/calendar.yaml +++ b/sensors/calendar.yaml @@ -47,7 +47,10 @@ entity_id: - sensor.time value_template: >- - {{ states('sensor.time').lstrip('0') }} + {% set hour = states('sensor.time').split(':')[0] | int %} + {% set minutes = states('sensor.time').split(':')[1] %} + + {{ hour }}:{{ minutes }} after_tomorrow: friendly_name: After Tomorrow @@ -63,7 +66,7 @@ - platform: template sensors: days_in_month: - friendly_name: Days in month + friendly_name: Days in Month icon_template: mdi:calendar entity_id: - sensor.date @@ -79,7 +82,7 @@ {{ days }} days_remaining_in_month: - friendly_name: Days remaining in month + friendly_name: Days Remaining in Month icon_template: mdi:calendar entity_id: - sensor.date diff --git a/sensors/climate.yaml b/sensors/climate.yaml index f5c6426..2a81efb 100644 --- a/sensors/climate.yaml +++ b/sensors/climate.yaml @@ -9,14 +9,13 @@ name: Bedroom Humidity state_topic: "home/bedroom/bedroom" unit_of_measurement: '%' - value_template: '{{ value_json.humidity }}' + value_template: '{{ value_json.humidity | round }}' - platform: mqtt name: Bedroom Temperature state_topic: "home/bedroom/bedroom" unit_of_measurement: '°C' - value_template: '{{ value_json.temperature_C }}' - + value_template: '{{ value_json.temperature_C | round }}' # # Lounge climate @@ -27,25 +26,19 @@ friendly_name: Lounge Humidity unit_of_measurement: '%' icon_template: mdi:water-percent - entity_id: - - sensor.aeotec_zw100_multisensor_6_relative_humidity - value_template: "{{ states('sensor.aeotec_zw100_multisensor_6_relative_humidity') }}" + value_template: "{{ states('sensor.aeotec_zw100_multisensor_6_relative_humidity') | round }}" lounge_temperature: friendly_name: Lounge Temperature unit_of_measurement: '°C' icon_template: mdi:thermometer - entity_id: - - sensor.aeotec_zw100_multisensor_6_temperature - value_template: "{{ states('sensor.aeotec_zw100_multisensor_6_temperature') }}" + value_template: "{{ states('sensor.aeotec_zw100_multisensor_6_temperature') | round }}" lounge_luminance: friendly_name: Lounge Luminance unit_of_measurement: 'lux' icon_template: mdi:blur - entity_id: - - sensor.aeotec_zw100_multisensor_6_luminance - value_template: "{{ states('sensor.aeotec_zw100_multisensor_6_luminance') }}" + value_template: "{{ states('sensor.aeotec_zw100_multisensor_6_luminance') | round }}" # @@ -65,12 +58,10 @@ - platform: template sensors: average_temperature: - friendly_name: Average Temperature + friendly_name: Temperature unit_of_measurement: '°C' icon_template: mdi:thermometer - entity_id: - - sensor.average_temperature_exact - value_template: "{{ states('sensor.average_temperature_exact')|round }}" + value_template: "{{ states('sensor.average_temperature_exact') | round }}" # @@ -90,20 +81,16 @@ - platform: template sensors: average_humidity: - friendly_name: Average Humidity + friendly_name: Humidity unit_of_measurement: '%' icon_template: mdi:water-percent - entity_id: - - sensor.average_humidity_exact - value_template: "{{ states('sensor.average_humidity_exact')|round }}" + value_template: "{{ states('sensor.average_humidity_exact') | round }}" - platform: template sensors: average_humidity_friendly: friendly_name: Humidity icon_template: mdi:water-percent - entity_id: - - sensor.average_humidity value_template: >- {% set humidity = states('sensor.average_humidity') | int %} diff --git a/sensors/health.yaml b/sensors/health.yaml index 878db2c..e4599f1 100644 --- a/sensors/health.yaml +++ b/sensors/health.yaml @@ -1,10 +1,12 @@ # # Doomsday Clock # +# see: https://github.com/renemarc/home-assistant-custom-components # see: https://thebulletin.org/doomsday-dashboard # see: https://github.com/mattbierner/MinutesToMidnight/blob/master/index.js # - platform: doomsday_clock + scan_interval: 86400 # @@ -35,7 +37,7 @@ - platform: template sensors: aqi: - friendly_name: AQI + friendly_name: Air Quality Index icon_template: mdi:chemical-weapon entity_id: - sensor.aqi_exact @@ -44,10 +46,12 @@ {% if index != "unknown" %} {{ index | float | round }} + {% else %} + {{ index }} {% endif %} aqi_friendly: - friendly_name: AQI + friendly_name: Air Quality Index icon_template: mdi:chemical-weapon entity_id: - sensor.aqi_exact @@ -101,6 +105,8 @@ {% if counter > 0 %} {{ (levels / counter) | round }} + {% else %} + unknown {% endif %} aqi_particles_friendly: @@ -156,6 +162,8 @@ {% if counter > 0 %} {{ (levels / counter) | round }} + {% else %} + unknown {% endif %} aqi_ozone_friendly: @@ -211,6 +219,8 @@ {% if counter > 0 %} {{ (levels / counter) | round }} + {% else %} + unknown {% endif %} aqi_nitrogen_dioxide_friendly: @@ -266,6 +276,8 @@ {% if counter > 0 %} {{ (levels / counter) | round }} + {% else %} + unknown {% endif %} aqi_carbon_monoxide_friendly: diff --git a/sensors/isp.yaml b/sensors/isp.yaml index 3d87d22..b653933 100644 --- a/sensors/isp.yaml +++ b/sensors/isp.yaml @@ -15,7 +15,7 @@ - platform: template sensors: ebox_usage_friendly: - friendly_name: Monthly usage + friendly_name: Monthly Usage icon_template: mdi:percent unit_of_measurement: '%' entity_id: @@ -30,7 +30,7 @@ {% endif %} ebox_download_remaining: - friendly_name: Remaining downloads + friendly_name: Remaining Downloads icon_template: mdi:briefcase-download unit_of_measurement: 'Gb' entity_id: @@ -47,7 +47,7 @@ {% endif %} ebox_download_daily_capacity: - friendly_name: Daily capacity + friendly_name: Daily Capacity icon_template: mdi:speedometer unit_of_measurement: 'Gb' entity_id: diff --git a/sensors/light.yaml b/sensors/light.yaml index d8155a2..a7a5587 100644 --- a/sensors/light.yaml +++ b/sensors/light.yaml @@ -1,43 +1,32 @@ # -# Ceiling wash lights effects +# Bed wash lights loaded effect. # -- platform: mqtt - name: Ceiling Effect - state_topic: 'home/ceiling/effect' - value_template: '{{ value_json.name }}' - qos: 1 +- platform: template + sensors: + bed_effect_loaded: + friendly_name: Bed Effect Loaded + value_template: >- + {% if is_state('group.bed', 'on') %} + {{ states('variable.bed_effect') }} + {% endif %} -- platform: mqtt - name: Ceiling Effect UUID - state_topic: 'home/ceiling/effect' - value_template: '{{ value_json.uuid }}' - qos: 1 +# +# Ceiling wash lights loaded effect. +# - platform: template sensors: ceiling_effect_loaded: friendly_name: Ceiling Effect Loaded value_template: >- {% if is_state('group.ceiling', 'on') %} - {{ states('sensor.ceiling_effect') }} + {{ states('variable.ceiling_effect') }} {% endif %} # -# Nanoleaf Aurora effect and brightness +# Nanoleaf Aurora loaded effect. # -- platform: mqtt - name: Aurora Effect - state_topic: 'home/aurora/effect' - value_template: '{{ value_json.name }}' - qos: 1 - -- platform: mqtt - name: Aurora Brightness - state_topic: 'home/aurora/effect' - value_template: '{{ value_json.brightness }}' - qos: 1 - - platform: template sensors: aurora_effect_loaded: diff --git a/sensors/misc.yaml b/sensors/misc.yaml index 07dcb3d..8d18e1b 100644 --- a/sensors/misc.yaml +++ b/sensors/misc.yaml @@ -6,7 +6,7 @@ - platform: template sensors: good_vibes: - friendly_name: Good vibes + friendly_name: Good Vibes icon_template: mdi:emoticon-happy value_template: >- {# Fetch a scheduled sensor to avoid updating this template non-stop. #} diff --git a/sensors/power.yaml b/sensors/power.yaml new file mode 100644 index 0000000..ab673f9 --- /dev/null +++ b/sensors/power.yaml @@ -0,0 +1,87 @@ +# +# AcuRite battery monitoring +# +- platform: mqtt + name: Bedroom AcuRite Battery + state_topic: "home/bedroom/bedroom" + unit_of_measurement: '%' + value_template: >- + {% set battery_level = value_json.battery | default(0) | int %} + + {% if battery_level %} + 100 + {% else %} + 10 + {% endif %} + +- platform: template + sensors: + bedroom_multisensor_battery: + friendly_name: Bedroom Multisensor Battery + unit_of_measurement: '%' + value_template: >- + {% set battery_level = states('sensor.bedroom_acurite_battery') | default(0) | int %} + + {{ battery_level }} + icon_template: >- + {% set battery_level = states('sensor.bedroom_acurite_battery') | default(0) | int %} + + {% if battery_level > 10 %} + mdi:battery + {% elif battery_round == 10 %} + mdi:battery-10 + {% else %} + mdi:battery-outline + {% endif %} + + +# +# Aeotec battery monitoring +# +- platform: template + sensors: + front_door_sensor_battery: + friendly_name: Front Door Sensor Battery + unit_of_measurement: '%' + value_template: >- + {% set battery_level = states.zwave.aeotec_zw120_door_window_sensor_gen5.attributes.battery_level | default(0) | int %} + + {% if battery_level %} + {{ battery_level | round }} + {% else %} + {{ states('zwave.aeotec_zw120_door_window_sensor_gen5') }} + {%- endif %} + icon_template: >- + {% set battery_level = states.zwave.aeotec_zw120_door_window_sensor_gen5.attributes.battery_level | default(0) | int %} + {% set battery_round = (battery_level / 10) | int * 10 %} + + {% if battery_round >= 100 %} + mdi:battery + {% elif battery_round > 0 %} + mdi:battery-{{ battery_round }} + {% else %} + mdi:battery-outline + {% endif %} + + lounge_multisensor_battery: + friendly_name: Lounge Multisensor Battery + unit_of_measurement: '%' + value_template: >- + {% set battery_level = states.zwave.aeotec_zw100_multisensor_6.attributes.battery_level | default(0) %} + + {% if battery_level %} + {{ battery_level | round }} + {% else %} + {{ states('zwave.aeotec_zw100_multisensor_6') }} + {%- endif %} + icon_template: >- + {% set battery_level = states.zwave.aeotec_zw100_multisensor_6.attributes.battery_level | default(0) | int %} + {% set battery_round = (battery_level / 10) | int * 10 %} + + {% if battery_round >= 100 %} + mdi:battery + {% elif battery_round > 0 %} + mdi:battery-{{ battery_round }} + {% else %} + mdi:battery-outline + {% endif %} diff --git a/sensors/system.yaml b/sensors/system.yaml index 47b5b20..4d15f2d 100644 --- a/sensors/system.yaml +++ b/sensors/system.yaml @@ -12,9 +12,15 @@ resources: - type: disk_use_percent arg: /home + - type: disk_free + arg: /home - type: ipv4_address arg: eth0 + - type: load_1m + - type: load_5m + - type: load_15m - type: memory_use_percent + - type: memory_free - type: processor_use - type: since_last_boot @@ -25,56 +31,62 @@ - platform: template sensors: version_friendly: - friendly_name: Home Assistant version + friendly_name: Home Assistant Version icon_template: mdi:update - entity_id: - - sensor.current_version value_template: >- {% if states('sensor.current_version') != "unknown" %} - HASS v{{ states('sensor.current_version') }} + HASS {{ states('sensor.current_version') }} {% else %} HASS {% endif %} update_available: - friendly_name: Update available + friendly_name: Update Available icon_template: mdi:update - entity_id: - - input_boolean.update_available value_template: >- - {% if is_state('input_boolean.update_available', 'on') %} - Update available. + {% if states('updater.updater') != "unknown" %} + Update available: {{ states('updater.updater') }} {% endif %} # -# Available disk space +# Disk space # - platform: template sensors: + disk_used_percent: + friendly_name: Disk Used /home + icon_template: mdi:harddisk + unit_of_measurement: '%' + value_template: >- + {{ states('sensor.disk_used_home') | float | round }} + disk_free_percent: - friendly_name: Disk free /home + friendly_name: Disk Free /home icon_template: mdi:harddisk unit_of_measurement: '%' - entity_id: - - sensor.disk_used_home value_template: >- - {{ (100 - states('sensor.disk_used_home')|float) | int }} + {{ 100 - states('sensor.disk_used_home') | float | round }} # -# Available RAM space +# RAM space # - platform: template sensors: + ram_used_percent: + friendly_name: RAM Used + icon_template: mdi:memory + unit_of_measurement: '%' + value_template: >- + {{ states('sensor.ram_used') | float | round }} + ram_free_percent: - friendly_name: RAM free + friendly_name: RAM Free icon_template: mdi:memory unit_of_measurement: '%' - entity_id: - - sensor.ram_used value_template: >- - {{ (100 - states('sensor.ram_used')|float) | int }} + {{ 100 - states('sensor.ram_used') | float | round }} # @@ -83,7 +95,7 @@ - platform: template sensors: uptime_host: - friendly_name: Server uptime + friendly_name: Server Uptime icon_template: mdi:server entity_id: - sensor.since_last_boot @@ -188,6 +200,16 @@ {% endif %} +# +# CPU cores count +# +- platform: command_line + name: CPU Cores + scan_interval: 86400 + command: "grep 'model name' /proc/cpuinfo | wc -l" + icon_template: mdi:chip + + # # CPU temperature # diff --git a/sensors/weather.yaml b/sensors/weather.yaml index daa0ddc..d2b670e 100644 --- a/sensors/weather.yaml +++ b/sensors/weather.yaml @@ -1,5 +1,5 @@ # -# Dark Dky weather +# Dark Sky weather # - platform: darksky api_key: !secret darksky_api_key @@ -51,7 +51,7 @@ - platform: template sensors: outside_humidity: - friendly_name: Relative humidity + friendly_name: Humidity icon_template: mdi:water-percent unit_of_measurement: '%' entity_id: @@ -66,7 +66,7 @@ - platform: template sensors: feels_like: - friendly_name: Feels like + friendly_name: Feels Like entity_id: - sensor.outside_temperature - sensor.dark_sky_apparent_temperature @@ -79,7 +79,7 @@ {% endif %} feels_like_1: - friendly_name: Feels like + friendly_name: Feels Like entity_id: - sensor.dark_sky_daily_high_temperature_1 - sensor.dark_sky_daily_high_apparent_temperature_1 @@ -92,7 +92,7 @@ {% endif %} feels_like_2: - friendly_name: Feels like + friendly_name: Feels Like entity_id: - sensor.dark_sky_daily_high_temperature_2 - sensor.dark_sky_daily_high_apparent_temperature_2 @@ -105,7 +105,7 @@ {% endif %} weather_summary: - friendly_name: Weather summary + friendly_name: Weather Summary entity_id: - sensor.dark_sky_temperature - sensor.dark_sky_summary @@ -113,7 +113,7 @@ {{ states('sensor.dark_sky_temperature') | round(0) }}˚ {{ states('sensor.dark_sky_summary') }}. weather_details: - friendly_name: Weather details + friendly_name: Weather Details entity_id: - sensor.dark_sky_temperature - sensor.dark_sky_apparent_temperature @@ -140,7 +140,7 @@ - platform: template sensors: precip_probability: - friendly_name: Probability of precipitation + friendly_name: Probability of Precipitation entity_id: - sensor.dark_sky_precip_probability value_template: >- @@ -153,7 +153,7 @@ {% endif %} precip_probability_friendly: - friendly_name: Probability of precipitation + friendly_name: Probability of Precipitation entity_id: - sensor.dark_sky_precip_probability value_template: >- @@ -166,7 +166,7 @@ {% endif %} precip_probability_1: - friendly_name: Probability of precipitation + friendly_name: Probability of Precipitation entity_id: - sensor.dark_sky_precip_probability_1 value_template: >- @@ -179,7 +179,7 @@ {% endif %} precip_probability_friendly_1: - friendly_name: Probability of precipitation + friendly_name: Probability of Precipitation entity_id: - sensor.dark_sky_precip_probability_1 value_template: >- @@ -192,7 +192,7 @@ {% endif %} precip_probability_2: - friendly_name: Probability of precipitation + friendly_name: Probability of Precipitation entity_id: - sensor.dark_sky_precip_probability_2 value_template: >- @@ -205,7 +205,7 @@ {% endif %} precip_probability_friendly_2: - friendly_name: Probability of precipitation + friendly_name: Probability of Precipitation entity_id: - sensor.dark_sky_precip_probability_2 value_template: >- @@ -224,14 +224,14 @@ - platform: template sensors: weather_low: - friendly_name: Low temperature + friendly_name: Low Temperature entity_id: - sensor.dark_sky_daily_low_temperature value_template: >- {{ states('sensor.dark_sky_daily_low_temperature') | round }} weather_low_friendly: - friendly_name: Low temperature + friendly_name: Low Temperature entity_id: - sensor.dark_sky_daily_low_temperature value_template: >- @@ -240,14 +240,14 @@ min: {{ temp }}˚ weather_low_1: - friendly_name: Low temperature + friendly_name: Low Temperature entity_id: - sensor.dark_sky_daily_low_temperature_1 value_template: >- {{ states('sensor.dark_sky_daily_low_temperature_1') | round }} weather_low_1_friendly: - friendly_name: Low temperature + friendly_name: Low Temperature entity_id: - sensor.dark_sky_daily_low_temperature_1 value_template: >- @@ -256,14 +256,14 @@ min: {{ temp }}˚ weather_low_2: - friendly_name: Low temperature + friendly_name: Low Temperature entity_id: - sensor.dark_sky_daily_low_temperature_2 value_template: >- {{ states('sensor.dark_sky_daily_low_temperature_2') | round }} weather_low_2_friendly: - friendly_name: Low temperature + friendly_name: Low Temperature entity_id: - sensor.dark_sky_daily_low_temperature_2 value_template: >- @@ -367,7 +367,7 @@ - platform: template sensors: wind_speed: - friendly_name: Wind speed + friendly_name: Wind Speed unit_of_measurement: 'km/h' entity_id: - sensor.dark_sky_wind_speed @@ -383,7 +383,7 @@ {% endif %} wind_scale_friendly: - friendly_name: Wind scale + friendly_name: Wind Scale entity_id: - sensor.dark_sky_wind_speed value_template: >- @@ -435,7 +435,7 @@ - platform: template sensors: wind_bearing_cardinal: - friendly_name: Wind bearing + friendly_name: Wind Bearing entity_id: - sensor.dark_sky_wind_bearing value_template: >- @@ -446,7 +446,7 @@ {{ directions[(val % 8)] }} wind_bearing_cardinal_friendly: - friendly_name: Wind bearing + friendly_name: Wind Bearing entity_id: - sensor.dark_sky_wind_bearing value_template: >- @@ -466,7 +466,7 @@ {{ directions[(val % 8)] }} wind_bearing_cardinal_16: - friendly_name: Wind bearing + friendly_name: Wind Bearing entity_id: - sensor.dark_sky_wind_bearing value_template: >- @@ -477,7 +477,7 @@ {{ directions[(val % 16)] }} wind_bearing_cardinal_16_friendly: - friendly_name: Wind bearing + friendly_name: Wind Bearing entity_id: - sensor.dark_sky_wind_bearing value_template: >- diff --git a/www/custom_ui/state-card-value_only.html b/www/custom_ui/state-card-value_only.html new file mode 100644 index 0000000..aed3b2b --- /dev/null +++ b/www/custom_ui/state-card-value_only.html @@ -0,0 +1,92 @@ + + + + + + +