HI,
I don’t know why without any reason scripts got triggered:
Those script are based on this post
HI,
I don’t know why without any reason scripts got triggered:
Those script are based on this post
You really should share your script and automations.
A script will not start on its own, it’s called somewhere.
You’ve got lots of stuff happening nearly at the same time. I’d bet you my bottom dollar one of these events calls the script…
You are right.
Below all the code (scripts and automations). Now code is all commented.
sensor:
platform: template
sensors:
harmony_activity:
friendly_name: ‘Harmony Status’
value_template: >
{% if is_state(“remote.harmony_hub”, ‘on’) %}
{{ states.remote.harmony_hub.attributes.current_activity }}
{% else %}
PowerOff
{% endif %}
platform: history_stats
name: TV accesa
entity_id: media_player.tv_soggiorno
state: ‘playing’
type: time
start: ‘{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}’
end: ‘{{ now() }}’
platform: template
sensors:
sorgentetvsoggiorno:
value_template: ‘{{ states.media_player.tv_soggiorno.attributes[“source”] }}’
friendly_name: ‘TV Soggiorno’
switch:
platform: template
switches:
tvsoggiorno_switch:
friendly_name: “TV Soggiorno”
value_template: “{{ is_state(‘remote.harmony_hub’, ‘on’) }}”
turn_on:
service: script.turn_on
data:
entity_id: script.tv
turn_off:
service: script.turn_on
data:
entity_id: script.tvoff
icon_template: >
{% if is_state(‘remote.harmony_hub’, ‘on’) %}
mdi:television-classic
{% else %}
mdi:television-classic-off
{% endif %}
platform: template
switches:
plex_switch:
friendly_name: “Plex”
value_template: “{{ is_state(‘remote.harmony_hub’, ‘on’) }}”
turn_on:
service: script.turn_on
data:
entity_id: script.Plex
turn_off:
service: script.turn_on
data:
entity_id: script.tvoff
platform: template
switches:
netflix_switch:
friendly_name: “Netflix”
value_template: “{{ is_state(‘remote.harmony_hub’, ‘on’) }}”
turn_on:
service: script.turn_on
data:
entity_id: script.netflix
turn_off:
service: script.turn_on
data:
entity_id: script.tvoff
platform: template
switches:
primevideo_switch:
friendly_name: “Prime Video”
value_template: “{{ is_state(‘remote.harmony_hub’, ‘on’) }}”
turn_on:
service: script.turn_on
data:
entity_id: script.primevideo
turn_off:
service: script.turn_on
data:
entity_id: script.tvoff
platform: template
switches:
bluray_switch:
friendly_name: “BluRay”
value_template: “{{ is_state(‘remote.harmony_hub’, ‘on’) }}”
turn_on:
service: script.turn_on
data:
entity_id: script.bluray
turn_off:
service: script.turn_on
data:
entity_id: script.tvoff
platform: template
switches:
vhs_switch:
friendly_name: “VHS”
value_template: “{{ is_state(‘remote.harmony_hub’, ‘on’) }}”
turn_on:
service: script.turn_on
data:
entity_id: script.vhs
turn_off:
service: script.turn_on
data:
entity_id: script.tvoff
media_player:
input_select:
harmony_soggiorno:
name: Harmony Soggiorno
options:
- Spenta
- TV
- Plex
- Netflix
- Prime Video
- VHS
- BluRay
- Spotify
#initial: Spenta
icon: mdi:television-classic
# sequence:
# - service: remote.turn_on
# entity_id: remote.harmony_hub
# data:
# activity: "38508191"
# sequence:
# - service: remote.turn_on
# entity_id: remote.harmony_hub
# data:
# activity: "27269375"
# sequence:
# - service: remote.turn_on
# entity_id: remote.harmony_hub
# data:
# activity: "27220282"
# sequence:
# - service: remote.turn_on
# entity_id: remote.harmony_hub
# data:
# activity: "27244009"
# sequence:
# - service: remote.turn_on
# entity_id: remote.harmony_hub
# data:
# activity: "27243190"
# sequence:
# - service: remote.turn_on
# entity_id: remote.harmony_hub
# data:
# activity: "38687198"
# sequence:
# - service: remote.turn_on
# entity_id: remote.harmony_hub
# data:
# activity: "38640383"
# sequence:
# - service: remote.turn_off
# entity_id: remote.harmony_hub
automation:
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: remote.harmony_hub
# condition:
# condition: template
# value_template: '{{ trigger.to_state.attributes.current_activity == "Guarda la TV" }}'
# action:
# service: input_select.select_option
# entity_id: input_select.harmony_soggiorno
# data:
# option: "TV"
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: remote.harmony_hub
# condition:
# condition: template
# value_template: '{{ trigger.to_state.attributes.current_activity == "PowerOff" }}'
# action:
# service: input_select.select_option
# entity_id: input_select.harmony_soggiorno
# data:
# option: "Spenta"
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: remote.harmony_hub
# condition:
# condition: template
# value_template: '{{ trigger.to_state.attributes.current_activity == "Guarda Plex" }}'
# action:
# service: input_select.select_option
# entity_id: input_select.harmony_soggiorno
# data:
# option: "Plex"
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: remote.harmony_hub
# condition:
# condition: template
# value_template: '{{ trigger.to_state.attributes.current_activity == "Guarda Netflix" }}'
# action:
# service: input_select.select_option
# entity_id: input_select.harmony_soggiorno
# data:
# option: "Netflix"
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: remote.harmony_hub
# condition:
# condition: template
# value_template: '{{ trigger.to_state.attributes.current_activity == "Guarda Prime" }}'
# action:
# service: input_select.select_option
# entity_id: input_select.harmony_soggiorno
# data:
# option: "Prime Video"
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: remote.harmony_hub
# condition:
# condition: template
# value_template: '{{ trigger.to_state.attributes.current_activity == "Guarda una VHS" }}'
# action:
# service: input_select.select_option
# entity_id: input_select.harmony_soggiorno
# data:
# option: "VHS"
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: remote.harmony_hub
# condition:
# condition: template
# value_template: '{{ trigger.to_state.attributes.current_activity == "Guarda un Film" }}'
# action:
# service: input_select.select_option
# entity_id: input_select.harmony_soggiorno
# data:
# option: "BluRay"
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: remote.harmony_hub
# condition:
# condition: template
# value_template: '{{ trigger.to_state.attributes.current_activity == "Ascolta Spotify" }}'
# action:
# service: input_select.select_option
# entity_id: input_select.harmony_soggiorno
# data:
# option: "Spotify"
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: input_select.harmony_soggiorno
# to: 'TV'
# action:
# service: script.turn_on
# entity_id: script.tv
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: input_select.harmony_soggiorno
# to: 'Plex'
# action:
# service: script.turn_on
# entity_id: script.plex
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: input_select.harmony_soggiorno
# to: 'Netflix'
# action:
# service: script.turn_on
# entity_id: script.netflix
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: input_select.harmony_soggiorno
# to: 'Prime Video'
# action:
# service: script.turn_on
# entity_id: script.primevideo
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: input_select.harmony_soggiorno
# to: 'Spotify'
# action:
# service: script.turn_on
# entity_id: script.spotify
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: input_select.harmony_soggiorno
# to: 'BluRay'
# action:
# service: script.turn_on
# entity_id: script.bluray
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: input_select.harmony_soggiorno
# to: 'VHS'
# action:
# service: script.turn_on
# entity_id: script.vhs
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: input_select.harmony_soggiorno
# to: 'Spenta'
# action:
# service: script.turn_on
# entity_id: script.tvoff
it would really help if you could format your code correctly, but basically your script is turned on when you set your input_select.harmony_soggiorno
to Spenta
- alias: “TV turned off from HASS”
# hide_entity: true
# # initial_state: 'on'
# trigger:
# platform: state
# entity_id: input_select.harmony_soggiorno
# to: 'Spenta'
# action:
# service: script.turn_on
# entity_id: script.tvoff
Here’s how to format your code on this forum:
somehow somewhere either you call the script or you set the input_select, the script won’t trigger on its own…
I wish there was shortcut or other means to quickly add this to a post. Bookmarking for now, thanks!
bit.ly/HAForumCode