Created
February 7, 2020 10:55
-
-
Save d0ugal/4fe66cad7877a2885f5e120be0243b1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sensor: | |
- platform: template | |
sensors: | |
ring_video_url: | |
friendly_name: "Ring Video URL" | |
value_template: >- | |
{%- if states.camera.front_door.attributes.video_url != None -%} | |
{{states.camera.front_door.attributes.video_url.split('?')[0]}} | |
{%- else -%} | |
unknown | |
{%- endif -%} | |
hall_light_brightness: | |
entity_id: | |
- sensor.light_brightness | |
- binary_sensor.hall_presence | |
- binary_sensor.landing_presence | |
friendly_name: 'Hall Light Brightness' | |
unit_of_measurement: '%' | |
value_template: >- | |
{% set brightness = states.sensor.light_brightness.state|int %} | |
{% if is_state('binary_sensor.hall_presence', 'off') and is_state('binary_sensor.landing_presence', 'off') %} | |
{% set brightness = 0 %} | |
{% elif is_state('binary_sensor.hall_presence', 'off') and is_state('binary_sensor.landing_presence', 'on') %} | |
{% set brightness = (brightness / 4)|int %} | |
{% endif %} | |
{{ brightness }} | |
icon_template: 'mdi:lightbulb-on-outline' | |
automation: | |
- alias: Hall Lamp On | |
trigger: | |
- platform: state | |
entity_id: sensor.hall_light_brightness | |
- platform: state | |
entity_id: sensor.sun_elevation | |
condition: | |
- condition: numeric_state | |
entity_id: sensor.hall_light_brightness | |
above: 0 | |
action: | |
- service: light.turn_on | |
data_template: | |
entity_id: light.hall_lamp | |
brightness_pct: "{{ states('sensor.hall_light_brightness') }}" | |
transition: 1 | |
- service: switch.turn_on | |
entity_id: switch.hall_flux | |
- alias: Hall Lamp Off | |
trigger: | |
- platform: state | |
entity_id: sensor.hall_light_brightness | |
- platform: state | |
entity_id: sensor.sun_elevation | |
condition: | |
- condition: numeric_state | |
entity_id: sensor.hall_light_brightness | |
below: 1 | |
action: | |
- service: light.turn_off | |
data_template: | |
entity_id: light.hall_lamp | |
transition: 10 | |
- service: switch.turn_off | |
entity_id: switch.hall_flux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sensor: | |
- platform: template | |
sensors: | |
light_brightness: | |
entity_id: | |
- sensor.sun_elevation | |
- sensor.brightness_average | |
friendly_name: 'Light Brightness' | |
unit_of_measurement: '%' | |
value_template: >- | |
{% set avg = states.sensor.brightness_average.state|float %} | |
{% if avg > 3000 %} | |
{% set min_brightness = 0 %} | |
{% elif avg < 2000 %} | |
{% set min_brightness = 100 %} | |
{% else %} | |
{% set avg = avg - 2000 %} | |
{% set min_brightness = ((1 - (avg / 1000)) * 100)|round %} | |
{% endif %} | |
{{ [[100, 100 - (states("sensor.sun_elevation")|float * 10)]|min, min_brightness]|max|int }} | |
icon_template: 'mdi:lightbulb-on-outline' | |
- platform: min_max | |
name: Brightness Average | |
type: mean | |
entity_ids: | |
- sensor.basil_brightness | |
- sensor.rosemary_brightness | |
- sensor.mint_brightness | |
- sensor.sansevieria_trifasciata_brightness | |
- sensor.hebe_waireka_brightness | |
binary_sensor: | |
- platform: template | |
sensors: | |
lights_on: | |
entity_id: | |
- sensor.light_brightness | |
friendly_name: 'Lights On' | |
value_template: '{{ states("sensor.light_brightness")|float > 0 }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment