diff --git a/automations/files/daily.yaml b/automations/files/daily.yaml index a11d83f..36015d5 100644 --- a/automations/files/daily.yaml +++ b/automations/files/daily.yaml @@ -8,23 +8,23 @@ - service: light.turn_on data: flash: long - brightness: 120 + brightness: 200 rgb_color: - 0 - 0 - 255 - entity_id: light.computer_cave_2 + entity_id: light.desk_lamp mode: single - id: daily_off alias: Daily notificaion off trigger: - platform: time - at: '10:55' + at: '11:25' condition: [] action: - service: light.turn_on data: kelvin: 3200 - entity_id: light.computer_cave_2 + entity_id: light.desk_lamp mode: single diff --git a/automations/tasks/air-purifier.yaml b/automations/tasks/air-purifier.yaml new file mode 100644 index 0000000..66ed9c5 --- /dev/null +++ b/automations/tasks/air-purifier.yaml @@ -0,0 +1,30 @@ +--- +- name: Build air purifiers automations + template: + src: air-purifier/automations.yaml.j2 + dest: build/automations/air-purifier.yaml + +- name: Build air purifiers fan + template: + src: air-purifier/fan.yaml.j2 + dest: build/fan/air-purifier.yaml + +- name: Build air purifiers switch + template: + src: air-purifier/switch.yaml.j2 + dest: build/switch/air-purifier.yaml + +- name: Build air purifiers inputs + template: + src: air-purifier/input_number.yaml.j2 + dest: build/input_number/air-purifier.yaml + +- name: Build air purifiers inputs + template: + src: air-purifier/input_select.yaml.j2 + dest: build/input_select/air-purifier.yaml + +- name: Build air purifiers sensor + template: + src: air-purifier/sensor.yaml.j2 + dest: build/sensors/air-purifier.yaml diff --git a/automations/tasks/main.yaml b/automations/tasks/main.yaml index df4b8dd..83ef4d3 100644 --- a/automations/tasks/main.yaml +++ b/automations/tasks/main.yaml @@ -2,8 +2,6 @@ - name: Build lights automations template: src: lights.yaml.j2 - dest: build/lights.yaml -- name: Build air purifiers automations - template: - src: air-purifier.yaml.j2 - dest: build/air-purifier.yaml \ No newline at end of file + dest: build/automations/lights.yaml + +- include_tasks: air-purifier.yaml \ No newline at end of file diff --git a/automations/templates/air-purifier.yaml.j2 b/automations/templates/air-purifier/automations.yaml.j2 similarity index 100% rename from automations/templates/air-purifier.yaml.j2 rename to automations/templates/air-purifier/automations.yaml.j2 diff --git a/automations/templates/air-purifier/fan.yaml.j2 b/automations/templates/air-purifier/fan.yaml.j2 new file mode 100644 index 0000000..68660e4 --- /dev/null +++ b/automations/templates/air-purifier/fan.yaml.j2 @@ -0,0 +1,7 @@ +{% for airPurifier in airPurifiers %} +# {{ airPurifier.name }} +- platform: xiaomi_miio + host: {{ airPurifier.ip }} + token: '{{ airPurifier.token }}' + name: '{{ airPurifier.name }} Purifier' +{% endfor %} \ No newline at end of file diff --git a/automations/templates/air-purifier/input_number.yaml.j2 b/automations/templates/air-purifier/input_number.yaml.j2 new file mode 100644 index 0000000..00b9e9d --- /dev/null +++ b/automations/templates/air-purifier/input_number.yaml.j2 @@ -0,0 +1,10 @@ +{% for airPurifier in airPurifiers %} +# {{ airPurifier.name }} +{{ airPurifier.componentId }}_favorite_level: + name: "Favorite level" + initial: 0 + min: 0 + max: 14 + step: 1 + icon: "mdi:weather-windy" +{% endfor %} \ No newline at end of file diff --git a/automations/templates/air-purifier/input_select.yaml.j2 b/automations/templates/air-purifier/input_select.yaml.j2 new file mode 100644 index 0000000..f512534 --- /dev/null +++ b/automations/templates/air-purifier/input_select.yaml.j2 @@ -0,0 +1,10 @@ +{% for airPurifier in airPurifiers %} +# {{ airPurifier.name }} +{{ airPurifier.componentId }}_mode: + name: Mode + options: + - Auto + - Silent + - Favorite + icon: "mdi:animation-outline" +{% endfor %} \ No newline at end of file diff --git a/automations/templates/air-purifier/sensor.yaml.j2 b/automations/templates/air-purifier/sensor.yaml.j2 new file mode 100644 index 0000000..74b8743 --- /dev/null +++ b/automations/templates/air-purifier/sensor.yaml.j2 @@ -0,0 +1,30 @@ +{% for airPurifier in airPurifiers %} +# {{ airPurifier.name }} +- platform: template + sensors: + {{ airPurifier.componentId }}_temp: + friendly_name: "Temperature" + value_template: {{ '"{{ state_attr(\''+ airPurifier.entityId +'\', \'temperature\') }}"' }} + unit_of_measurement: "°C" + device_class: "temperature" + {{ airPurifier.componentId }}_humidity: + friendly_name: "Humidity" + value_template: {{ '"{{ state_attr(\''+ airPurifier.entityId +'\', \'humidity\') }}"' }} + unit_of_measurement: "%" + device_class: "humidity" + {{ airPurifier.componentId }}_air_quality_pm25: + friendly_name: "Air quality" + value_template: {{ '"{{ state_attr(\''+ airPurifier.entityId +'\', \'aqi\') }}"' }} + unit_of_measurement: "μg/m³" + icon_template: "mdi:weather-fog" + {{ airPurifier.componentId }}_speed: + friendly_name: "Fan speed" + value_template: {{ '"{{ state_attr(\''+ airPurifier.entityId +'\', \'motor_speed\') }}"' }} + unit_of_measurement: "rpm" + icon_template: "mdi:speedometer" + {{ airPurifier.componentId }}_filter_remaining: + friendly_name: "Filter remaining" + value_template: {{ '"{{ state_attr(\''+ airPurifier.entityId +'\', \'filter_life_remaining\') }}"' }} + unit_of_measurement: "%" + icon_template: "mdi:heart-outline" +{% endfor %} \ No newline at end of file diff --git a/automations/templates/air-purifier/switch.yaml.j2 b/automations/templates/air-purifier/switch.yaml.j2 new file mode 100644 index 0000000..89a6893 --- /dev/null +++ b/automations/templates/air-purifier/switch.yaml.j2 @@ -0,0 +1,41 @@ +{% for airPurifier in airPurifiers %} +# {{ airPurifier.name }} +- platform: template + switches: + {{ airPurifier.componentId }}_led: + friendly_name: "LED" + value_template: "{{ '{{ is_state_attr(\''+ airPurifier.entityId +'\', \'led\', true) }}"' }} + turn_on: + service: xiaomi_miio.fan_set_led_on + data: + entity_id: {{ airPurifier.entityId }} + turn_off: + service: xiaomi_miio.fan_set_led_off + data: + entity_id: {{ airPurifier.entityId }} + icon_template: "mdi:lightbulb-outline" + {{ airPurifier.componentId }}_child_lock: + friendly_name: "Child lock" + value_template: "{{ '{{ is_state_attr(\''+ airPurifier.entityId +'\', \'child_lock\', true) }}"' }} + turn_on: + service: xiaomi_miio.fan_set_child_lock_on + data: + entity_id: {{ airPurifier.entityId }} + turn_off: + service: xiaomi_miio.fan_set_child_lock_off + data: + entity_id: {{ airPurifier.entityId }} + icon_template: "mdi:lock-outline" + {{ airPurifier.componentId }}_buzzer: + friendly_name: "Buzzer" + value_template: "{{ '{{ is_state_attr(\''+ airPurifier.entityId +'\', \'buzzer\', true) }}"' }} + turn_on: + service: xiaomi_miio.fan_set_buzzer_on + data: + entity_id: {{ airPurifier.entityId }} + turn_off: + service: xiaomi_miio.fan_set_buzzer_off + data: + entity_id: {{ airPurifier.entityId }} + icon_template: "mdi:volume-high" +{% endfor %} \ No newline at end of file diff --git a/automations/vars/main.yaml b/automations/vars/main.yaml index e368d6a..228c991 100644 --- a/automations/vars/main.yaml +++ b/automations/vars/main.yaml @@ -1,6 +1,5 @@ --- # vars file for automations - lights: - entityId: light.tv_left name: TV Left @@ -40,6 +39,10 @@ airPurifiers: - entityId: fan.xiaomi_miio_device componentId: xiaomi_miio_device name: Living Room + ip: 192.168.60.6 + token: 66e56ff414f359b371b2d0b86e3d37d4 - entityId: fan.bedroom_air_purifier componentId: bedroom_air_purifier - name: Bedroom \ No newline at end of file + name: Bedroom + ip: 192.168.60.5 + token: a32c6e74647ac03ad79afaa590b5203c \ No newline at end of file