diff --git a/esphome/common/common.yaml b/esphome/common/common.yaml index 76ee17d0..f85af7ee 100644 --- a/esphome/common/common.yaml +++ b/esphome/common/common.yaml @@ -1,7 +1,7 @@ api: ota: - - platform: esphome + platform: esphome wifi: ssid: !secret wifi_ssid diff --git a/esphome/common/shelly_1_detached_push_button_common.yaml b/esphome/common/shelly_1_detached_push_button_common.yaml index 2205cd6b..36a87347 100644 --- a/esphome/common/shelly_1_detached_push_button_common.yaml +++ b/esphome/common/shelly_1_detached_push_button_common.yaml @@ -6,6 +6,7 @@ packages: esphome: name: ${device_name} comment: ${device_description} + friendly_name: ${friendly_name} platform: ESP8266 board: esp01_1m diff --git a/esphome/common/usb_switch_relay_common.yaml b/esphome/common/usb_switch_relay_common.yaml index fa365eda..b15dbdb8 100644 --- a/esphome/common/usb_switch_relay_common.yaml +++ b/esphome/common/usb_switch_relay_common.yaml @@ -47,7 +47,7 @@ output: - platform: gpio pin: GPIO14 id: green_led - inverted: true # start on + inverted: true # start on # Binary Output template to link relay and green LED states # LED is on when relay is off diff --git a/esphome/traffic-light.yaml b/esphome/traffic-light.yaml new file mode 100644 index 00000000..6fa3f607 --- /dev/null +++ b/esphome/traffic-light.yaml @@ -0,0 +1,198 @@ +--- +substitutions: + device_name: traffic-light + device_description: Traffic Light + friendly_name: Traffic Light + default_state: "ALWAYS_OFF" + icon: mdi:traffic-light + go_green_pin: D7 + go_red_pin: D6 + green_output_pin: D3 + amber_output_pin: D2 + red_output_pin: D1 + blue_led_pin: D4 + +packages: + common: !include common/common.yaml + +esphome: + name: ${device_name} + comment: ${device_description} + +esp8266: + board: d1_mini + +captive_portal: + +logger: + +# Enable web server +web_server: + port: 80 + +syslog: + ip_address: 172.24.32.13 + port: 515 + +light: + # ... and then make a light out of it. + - platform: monochromatic + id: blue_led_light + name: "${friendly_name} Blue LED" + output: blue_led + + - platform: binary + id: red + name: "${friendly_name} Red" + output: red_relay + + - platform: binary + id: green + name: "${friendly_name} Green" + output: green_relay + + - platform: binary + id: amber + name: "${friendly_name} Amber" + output: amber_relay + +binary_sensor: + - platform: gpio + pin: + number: ${go_green_pin} + # mode: INPUT_PULLUP + inverted: true + name: "Go Green Button" + on_release: + then: + switch.toggle: go_green_sequence + + - platform: gpio + pin: + number: ${go_red_pin} + # mode: INPUT_PULLUP + inverted: true + name: "Go Red Button" + on_release: + then: + switch.toggle: go_red_sequence + +output: + # Register the blue LED as a dimmable output .... + - platform: esp8266_pwm + id: blue_led + pin: ${blue_led_pin} + inverted: true + + - platform: gpio + # name: ${friendly_name} Green Relay + pin: ${green_output_pin} + id: green_relay + # restore_mode: "${default_state}" + + - platform: gpio + # name: ${friendly_name} Amber Relay + pin: ${amber_output_pin} + id: amber_relay + # restore_mode: "${default_state}" + + - platform: gpio + # name: ${friendly_name} Red Relay + pin: ${red_output_pin} + id: red_relay + # restore_mode: "${default_state}" + + # Page 35 of https://assets.publishing.service.gov.uk/media/5df0e29fed915d15f42c4820/dft-traffic-signs-manual-chapter-6.pdf + +switch: + - platform: template + id: go_green_sequence + name: "${friendly_name} Go Green Sequence" + turn_on_action: + # Start it up and show red for 3 seconds + - light.turn_off: + id: green + - light.turn_off: + id: amber + - light.turn_on: + id: red + - delay: 3s + # Now the sequence really starts + - light.turn_on: + id: amber + - delay: 2s + - light.turn_off: + id: red + - light.turn_off: + id: amber + - light.turn_on: + id: green + + - platform: template + id: go_red_sequence + name: "${friendly_name} Go Red Sequence" + turn_on_action: + # Start it up and show green for 3 seconds + - light.turn_off: + id: red + - light.turn_off: + id: amber + - light.turn_on: + id: green + - delay: 3s + # Now the sequence really starts + - light.turn_on: + id: amber + - light.turn_off: + id: green + - delay: 3s + - light.turn_off: + id: amber + - light.turn_on: + id: red + +# Blink the light if we aren't connected to WiFi. +interval: + - interval: 5000ms + id: no_wifi + then: + - if: + condition: + not: + wifi.connected: + then: + - light.turn_on: + id: blue_led_light + brightness: 100% + transition_length: 0s + - delay: 250ms + - light.turn_off: + id: blue_led_light + transition_length: 0ms + - delay: 250ms + - interval: 5000ms + id: no_api + then: + - if: + condition: + not: + api.connected: + then: + - light.turn_on: + id: blue_led_light + brightness: 100% + transition_length: 0s + - delay: 250ms + - light.turn_off: + id: blue_led_light + transition_length: 0ms + - delay: 250ms + - light.turn_on: + id: blue_led_light + brightness: 100% + transition_length: 0s + - delay: 250ms + - light.turn_off: + id: blue_led_light + transition_length: 0ms + - delay: 250ms diff --git a/packages/outside_lights.yaml b/packages/outside_lights.yaml index c0e8f004..4efc6b64 100644 --- a/packages/outside_lights.yaml +++ b/packages/outside_lights.yaml @@ -134,6 +134,9 @@ automation: "Woooo, it's dark and scary. Something moved! Turning on the outside lights!", "Did you hear that? I can't see a thing. Turning on the outside lights" ] | random + " https://amzn.to/2CR5mbQ" }} + - service: homeassistant.turn_on + entity_id: + - group.outside_lights - service: notify.mobile_app_nothing_phone_1 data: title: "Motion outside!" diff --git a/packages/valetudo.yaml b/packages/valetudo.yaml index 936a3244..98fd0a44 100644 --- a/packages/valetudo.yaml +++ b/packages/valetudo.yaml @@ -1,5 +1,4 @@ --- - homeassistant: customize: input_boolean.vacuum_fronthall: @@ -25,6 +24,9 @@ homeassistant: input_boolean.vacuum_ensuite: room_id: "3" +# Error handling +# https://github.com/oncleben31/home-assistant-config/blob/31fc1c21af4338d865361d189a1dda9fe01f04c9/config/entities/sensors/vacuum_error.yaml#L3 + input_boolean: vacuum_bootroom: name: Boot Room @@ -59,7 +61,6 @@ input_boolean: name: Ensuite icon: mdi:toilet - group: vacuum_rooms: name: Vacuum Rooms @@ -97,7 +98,63 @@ script: topic: valetudo/ConfusedMeaslyRaccoon/MapSegmentationCapability/clean/set payload_template: '{"segment_ids": {{segments}}}' mode: single - vacuum_clean_kithen: + + # A series of script calls to clean rooms. Called from the scheduler component. + vacuum_clean_fronthall: + alias: vacuum_clean_fronthall + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_fronthall") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to mop and clean the floor of the front hall!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the front hall has started." + + vacuum_clean_livingroom: + alias: vacuum_clean_livingroom + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_livingroom") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to mop and clean the living room!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the living room has started." + + vacuum_clean_bootroom: + alias: vacuum_clean_bootroom + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_bootroom") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to mop and clean the boot room floor!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the boot room has started." + + vacuum_clean_kitchen: alias: vacuum_clean_kitchen mode: single sequence: @@ -107,3 +164,136 @@ script: data: variables: segments: '{{expand("input_boolean.vacuum_kitchen") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to mop and clean the kitchen floor!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the kitchen has started." + + vacuum_clean_hallway: + alias: vacuum_clean_hallway + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_hallway") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to mop and clean the hallway!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the hallway has started." + + vacuum_clean_bathroom: + alias: vacuum_clean_bathroom + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_bathroom") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to mop and clean the bathroom!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the bathroom has started." + + vacuum_clean_study: + alias: vacuum_clean_study + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_study") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to clean the study carpet!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the study has started." + + vacuum_clean_craftroom: + alias: vacuum_clean_craftroom + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_craftroom") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to clean the craft room carpet!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the craft room has started." + + vacuum_clean_guestroom: + alias: vacuum_clean_guestroom + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_guestroom") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to clean the guest room!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the guest room has started." + + vacuum_clean_bedroom: + alias: vacuum_clean_bedroom + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_bedroom") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to clean the bedroom!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the bedroom has started." + + vacuum_clean_ensuite: + alias: vacuum_clean_ensuite + mode: single + sequence: + - service: script.turn_on + target: + entity_id: script.vacuum_clean_segments_message + data: + variables: + segments: '{{expand("input_boolean.vacuum_ensuite") | map(attribute="attributes.room_id") | list | to_json }}' + - service: script.tweet_engine + data_template: + tweet: "Dispatching my minion, Snowwhite the vacuum, to mop and clean the ensuite!" + - service: notify.mobile_app_nothing_phone_1 + data: + title: "Vacuuming" + message: "Vacuuming of the ensuite has started." diff --git a/recorder.yaml b/recorder.yaml index 5ddb2f2f..a8f827c8 100644 --- a/recorder.yaml +++ b/recorder.yaml @@ -1,5 +1,5 @@ db_url: !secret db_url -purge_keep_days: 30 +purge_keep_days: 21 exclude: domains: - automation