upd: notification
This commit is contained in:
@@ -1092,6 +1092,11 @@ trigger_variables:
|
|||||||
display_target_temperature: "sensor.{{ nspanel_name_trigger }}_display_target_temperature"
|
display_target_temperature: "sensor.{{ nspanel_name_trigger }}_display_target_temperature"
|
||||||
relay01_entity: "switch.{{ nspanel_name_trigger }}_relay_1"
|
relay01_entity: "switch.{{ nspanel_name_trigger }}_relay_1"
|
||||||
relay02_entity: "switch.{{ nspanel_name_trigger }}_relay_2"
|
relay02_entity: "switch.{{ nspanel_name_trigger }}_relay_2"
|
||||||
|
|
||||||
|
##### notification Trigger #####
|
||||||
|
notification_unread: "switch.{{ nspanel_name_trigger }}_notification_unread"
|
||||||
|
notification_text: "sensor.{{ nspanel_name_trigger }}_notification_text"
|
||||||
|
notification_label: "sensor.{{ nspanel_name_trigger }}_notification_label"
|
||||||
|
|
||||||
##### WEATHER Trigger #####
|
##### WEATHER Trigger #####
|
||||||
weather: !input "weather"
|
weather: !input "weather"
|
||||||
@@ -1109,6 +1114,8 @@ variables:
|
|||||||
time: "{{ (as_timestamp(now()) | timestamp_custom('%H:%M')) }}"
|
time: "{{ (as_timestamp(now()) | timestamp_custom('%H:%M')) }}"
|
||||||
language: !input "language"
|
language: !input "language"
|
||||||
|
|
||||||
|
notification_sound: "switch.{{ nspanel_name_trigger }}_notification_sound"
|
||||||
|
|
||||||
##### PUSH TO NEXTION DISPLAY #####
|
##### PUSH TO NEXTION DISPLAY #####
|
||||||
command_text_printf: "esphome.{{ nspanel_name }}_send_command_text_printf"
|
command_text_printf: "esphome.{{ nspanel_name }}_send_command_text_printf"
|
||||||
command_value: "esphome.{{ nspanel_name }}_send_command_value"
|
command_value: "esphome.{{ nspanel_name }}_send_command_value"
|
||||||
@@ -1116,6 +1123,8 @@ variables:
|
|||||||
command_font_color: "esphome.{{ nspanel_name }}_send_command_font_color"
|
command_font_color: "esphome.{{ nspanel_name }}_send_command_font_color"
|
||||||
command_background_color: "esphome.{{ nspanel_name }}_send_command_background_color"
|
command_background_color: "esphome.{{ nspanel_name }}_send_command_background_color"
|
||||||
command_thermostat_cycle: "esphome.{{ nspanel_name }}_send_thermostat_cycle_state"
|
command_thermostat_cycle: "esphome.{{ nspanel_name }}_send_thermostat_cycle_state"
|
||||||
|
command_notification_show: "esphome.{{ nspanel_name }}_notification_show"
|
||||||
|
command_notification_clear: "esphome.{{ nspanel_name }}_notification_clear"
|
||||||
|
|
||||||
###### SYNC SETTINGS #####
|
###### SYNC SETTINGS #####
|
||||||
delay_boot: !input "delay"
|
delay_boot: !input "delay"
|
||||||
@@ -1848,6 +1857,37 @@ trigger:
|
|||||||
value_template: '{{ states(last_click) is match "releaseclimate" }}'
|
value_template: '{{ states(last_click) is match "releaseclimate" }}'
|
||||||
id: open_climate_settings
|
id: open_climate_settings
|
||||||
|
|
||||||
|
##### Trigger - Notification #####
|
||||||
|
|
||||||
|
##### Notification Text - Trigger "notification_text_state" #####
|
||||||
|
- platform: event
|
||||||
|
event_type: state_changed
|
||||||
|
event_data:
|
||||||
|
entity_id: '{{ notification_text }}'
|
||||||
|
id: notification_text_state
|
||||||
|
|
||||||
|
##### Notification Text - Trigger "notification_text_state" #####
|
||||||
|
- platform: event
|
||||||
|
event_type: state_changed
|
||||||
|
event_data:
|
||||||
|
entity_id: '{{ notification_unread }}'
|
||||||
|
id: notification_unread_state
|
||||||
|
|
||||||
|
#### Show notification - Trigger ####
|
||||||
|
- platform: template
|
||||||
|
value_template: '{{ states(last_click) is match "homebutton04release" }}'
|
||||||
|
id: open_notification_page
|
||||||
|
|
||||||
|
#### Notification clear - Trigger ####
|
||||||
|
- platform: template
|
||||||
|
value_template: '{{ states(last_click) is match "notificationclearrelease" }}'
|
||||||
|
id: btn_notificationclearrelease
|
||||||
|
|
||||||
|
#### Notification accept - Trigger ####
|
||||||
|
- platform: template
|
||||||
|
value_template: '{{ states(last_click) is match "notificationacceptrelease" }}'
|
||||||
|
id: btn_notificationacceptrelease
|
||||||
|
|
||||||
##### Trigger - Button General #################################################################################################################
|
##### Trigger - Button General #################################################################################################################
|
||||||
|
|
||||||
##### Page Button - Trigger "short_press" - SHORT Press via "last_click" #####
|
##### Page Button - Trigger "short_press" - SHORT Press via "last_click" #####
|
||||||
@@ -2624,6 +2664,77 @@ action:
|
|||||||
data:
|
data:
|
||||||
cmd: home.icon_top_04.pic={{ flame_pic }}
|
cmd: home.icon_top_04.pic={{ flame_pic }}
|
||||||
|
|
||||||
|
###### INIT Notify ######
|
||||||
|
- service: "{{ command_notification_clear }}"
|
||||||
|
data: {}
|
||||||
|
|
||||||
|
#### Notification Symbol ####
|
||||||
|
- conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id:
|
||||||
|
- notification_text_state
|
||||||
|
- notification_unread_state
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ trigger.event.data.new_state.state != 'unavailable' and trigger.event.data.new_state.state != 'unknown' and states(current_page) == page_home }}"
|
||||||
|
sequence:
|
||||||
|
- alias: "Set notifiy pic"
|
||||||
|
variables:
|
||||||
|
notify_pic: >-
|
||||||
|
{%- if is_state(notification_unread, 'on') and states(notification_text) |length > 0 -%} {{ home_button_notify_red }}
|
||||||
|
{%- elif is_state(notification_unread, 'off') and states(notification_text) |length > 0 -%} {{ home_button_notify_white }}
|
||||||
|
{%- else -%} {{ home_button_blank }}
|
||||||
|
{%- endif -%}
|
||||||
|
- service: "{{ command_printf }}"
|
||||||
|
data:
|
||||||
|
cmd: "homebt04_pic.pic={{ notify_pic }}"
|
||||||
|
|
||||||
|
##### Show last notification #####
|
||||||
|
- conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id: open_notification_page
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ states(notification_text) |length > 0}} "
|
||||||
|
sequence:
|
||||||
|
- service: "{{ command_printf }}"
|
||||||
|
data:
|
||||||
|
cmd: "page {{ page_notification }}"
|
||||||
|
- service: "{{ command_text_printf }}"
|
||||||
|
data:
|
||||||
|
component: notification.notifi_text01
|
||||||
|
message: "{{ states(notification_text) }}"
|
||||||
|
- delay:
|
||||||
|
milliseconds: "{{ delay_value }}"
|
||||||
|
- service: "{{ command_text_printf }}"
|
||||||
|
data:
|
||||||
|
component: notification.notifi_label
|
||||||
|
message: "{{ states(notification_label) }}"
|
||||||
|
|
||||||
|
##### Button Notification clear #####
|
||||||
|
- conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id: btn_notificationclearrelease
|
||||||
|
sequence:
|
||||||
|
- service: switch.turn_off
|
||||||
|
data:
|
||||||
|
entity_id: "{{ notification_unread }}"
|
||||||
|
- service: "{{ command_printf }}"
|
||||||
|
data:
|
||||||
|
cmd: "page {{ page_home }}"
|
||||||
|
|
||||||
|
##### Button Notification accept #####
|
||||||
|
- conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id: btn_notificationacceptrelease
|
||||||
|
sequence:
|
||||||
|
- service: switch.turn_off
|
||||||
|
data:
|
||||||
|
entity_id: "{{ notification_unread }}"
|
||||||
|
- service: "{{ command_notification_clear }}"
|
||||||
|
data: {}
|
||||||
|
- service: "{{ command_printf }}"
|
||||||
|
data:
|
||||||
|
cmd: "page {{ page_home }}"
|
||||||
|
|
||||||
#### TFT Upload Automation #####
|
#### TFT Upload Automation #####
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: trigger
|
- condition: trigger
|
||||||
@@ -4072,6 +4183,20 @@ action:
|
|||||||
entity_id: !input climate
|
entity_id: !input climate
|
||||||
#hvac_mode: 'heat'
|
#hvac_mode: 'heat'
|
||||||
temperature: "{{ display_target_temperature }}"
|
temperature: "{{ display_target_temperature }}"
|
||||||
|
|
||||||
|
##### Set notify icon #####
|
||||||
|
- variables:
|
||||||
|
notify_pic: >-
|
||||||
|
{%- if is_state(notification_unread, 'on') and states(notification_text) |length > 0 -%} {{ home_button_notify_red }}
|
||||||
|
{%- elif is_state(notification_unread, 'off') and states(notification_text) |length > 0 -%} {{ home_button_notify_white }}
|
||||||
|
{%- else -%} {{ home_button_blank }}
|
||||||
|
{%- endif -%}
|
||||||
|
- delay:
|
||||||
|
milliseconds: "{{ delay_value }}"
|
||||||
|
- service: "{{ command_printf }}"
|
||||||
|
data:
|
||||||
|
cmd: "homebt04_pic.pic={{ notify_pic }}"
|
||||||
|
|
||||||
|
|
||||||
## PAGE WEATHE01 ##
|
## PAGE WEATHE01 ##
|
||||||
- conditions: '{{ trigger.event.data.new_state.state == page_weather01 }}'
|
- conditions: '{{ trigger.event.data.new_state.state == page_weather01 }}'
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ api:
|
|||||||
- wait_until:
|
- wait_until:
|
||||||
switch.is_on: nextion_init
|
switch.is_on: nextion_init
|
||||||
- lambda: 'id(disp1).set_component_font_color(component.c_str(), message);'
|
- lambda: 'id(disp1).set_component_font_color(component.c_str(), message);'
|
||||||
|
|
||||||
##### Service to send a command "background color" directly to the display #####
|
##### Service to send a command "background color" directly to the display #####
|
||||||
- service: send_command_background_color
|
- service: send_command_background_color
|
||||||
variables:
|
variables:
|
||||||
@@ -189,6 +190,46 @@ api:
|
|||||||
switch.is_on: nextion_init
|
switch.is_on: nextion_init
|
||||||
- lambda: 'id(disp1).set_component_background_color(component.c_str(), message);'
|
- lambda: 'id(disp1).set_component_background_color(component.c_str(), message);'
|
||||||
|
|
||||||
|
##### Service to show a notification-message on the screen #####
|
||||||
|
- service: notification_show
|
||||||
|
variables:
|
||||||
|
label: string
|
||||||
|
text: string
|
||||||
|
then:
|
||||||
|
- wait_until:
|
||||||
|
switch.is_on: nextion_init
|
||||||
|
- lambda: |-
|
||||||
|
id(disp1).send_command_printf("page notification");
|
||||||
|
id(disp1).set_component_text_printf("notification.notifi_label", "%s", label.c_str());
|
||||||
|
id(disp1).set_component_text_printf("notification.notifi_text01", "%s", text.c_str());
|
||||||
|
id(notification_label).publish_state(label.c_str());
|
||||||
|
id(notification_text).publish_state(text.c_str());
|
||||||
|
- switch.turn_on: notification_unread
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
switch.is_on: notification_sound
|
||||||
|
then:
|
||||||
|
- rtttl.play: "two short:d=4,o=5,b=100:16e6,16e6"
|
||||||
|
|
||||||
|
##### Service to clear the notification #####
|
||||||
|
- service: notification_clear
|
||||||
|
then:
|
||||||
|
- wait_until:
|
||||||
|
switch.is_on: nextion_init
|
||||||
|
- lambda: |-
|
||||||
|
id(notification_label).publish_state("");
|
||||||
|
id(notification_text).publish_state("");
|
||||||
|
- switch.turn_off: notification_unread
|
||||||
|
|
||||||
|
##### Service to play a rtttl tones #####
|
||||||
|
# Example tones : https://codebender.cc/sketch:109888#RTTTL%20Songs.ino
|
||||||
|
- service: play_rtttl
|
||||||
|
variables:
|
||||||
|
song_str: string
|
||||||
|
then:
|
||||||
|
- rtttl.play:
|
||||||
|
rtttl: !lambda 'return song_str;'
|
||||||
|
|
||||||
#### Service to send thermostat cycle state ####
|
#### Service to send thermostat cycle state ####
|
||||||
- service: send_thermostat_cycle_state
|
- service: send_thermostat_cycle_state
|
||||||
variables:
|
variables:
|
||||||
@@ -549,6 +590,14 @@ text_sensor:
|
|||||||
name: ${device_name} BSSID
|
name: ${device_name} BSSID
|
||||||
disabled_by_default: true
|
disabled_by_default: true
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: ${device_name} Notification Label
|
||||||
|
id: notification_label
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: ${device_name} Notification Text
|
||||||
|
id: notification_text
|
||||||
|
|
||||||
##### last click sensor, the main action variable - push to HA #####
|
##### last click sensor, the main action variable - push to HA #####
|
||||||
- platform: nextion
|
- platform: nextion
|
||||||
nextion_id: disp1
|
nextion_id: disp1
|
||||||
@@ -675,9 +724,25 @@ switch:
|
|||||||
assumed_state: off
|
assumed_state: off
|
||||||
optimistic: true
|
optimistic: true
|
||||||
|
|
||||||
|
##### Notification unread #####
|
||||||
|
- platform: template
|
||||||
|
name: ${device_name} Notification unread
|
||||||
|
id: notification_unread
|
||||||
|
entity_category: config
|
||||||
|
restore_state: true
|
||||||
|
optimistic: true
|
||||||
|
|
||||||
|
##### Notification sound #####
|
||||||
|
- platform: template
|
||||||
|
name: ${device_name} Notification sound
|
||||||
|
id: notification_sound
|
||||||
|
entity_category: config
|
||||||
|
restore_state: true
|
||||||
|
optimistic: true
|
||||||
|
|
||||||
##### UPDATE TFT DISPLAY #####
|
##### UPDATE TFT DISPLAY #####
|
||||||
- platform: template
|
- platform: template
|
||||||
name: Update TFT display
|
name: ${device_name} Update TFT display
|
||||||
id: tft_update
|
id: tft_update
|
||||||
entity_category: config
|
entity_category: config
|
||||||
turn_on_action:
|
turn_on_action:
|
||||||
@@ -803,7 +868,11 @@ display:
|
|||||||
- wait_until:
|
- wait_until:
|
||||||
api.connected
|
api.connected
|
||||||
- delay: 0.5s
|
- delay: 0.5s
|
||||||
- rtttl.play: "two short:d=4,o=5,b=100:16e6,16e6"
|
- if:
|
||||||
|
condition:
|
||||||
|
switch.is_on: notification_sound
|
||||||
|
then:
|
||||||
|
- rtttl.play: "two short:d=4,o=5,b=100:16e6,16e6"
|
||||||
- delay: 0.5s
|
- delay: 0.5s
|
||||||
- switch.template.publish:
|
- switch.template.publish:
|
||||||
id: nextion_init
|
id: nextion_init
|
||||||
|
|||||||
Reference in New Issue
Block a user