I am completely new to Home Assistant. So to start off this my goal is to have Home Assistant Dim the two lights in my living room when I play media on my Vizio TV. Which I tend to use SmartCast were it uses the plex app to play my media.
Currently the lights that I have are the walmart Merkury, which with Tuya. I do have them added to Home Assistant and can turn the lights on and off via the Home Assistant dashboard.
I’ve created an automation script, and scene script. I’ve check that the automation works by forcing it to execute and triggering the scene, which my livingroom lights do dim and go back to normal, so that portion works. The issue I think is that plex, or smartcast is not triggering the automation. Below are my configs.
configureation.yaml
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Text to speech
tts:
- platform: google_translate
tuya:
username: SecretEmail
password: SecretPassword
country_code: 86
plex:
host: MyServerIP
port: 32400
media_player:
use_episode_art: true
ignore_new_shared_users: false
scene:
- name: Livingroom normal
entities:
light.06200636b4e62d1a727e:
state: on
transition: 2
brightness: 100
light.62118678dc4f22bc7378:
state: on
transition: 2
brightness: 100
- name: Livingroom dim
entities:
light.06200636b4e62d1a727e:
state: on
transition: 2
brightness: 1
light.62118678dc4f22bc7378:
state: on
transition: 2
brightness: 1
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
#scene: !include scenes.yaml
automations.yaml
- id: '1585550781277'
alias: Playing Media
description: ''
trigger:
- entity_id: media_player.plex_plex_for_vizio_vizio_smartcast
from: idle
platform: state
to: playing
condition: []
action:
- scene: scene.livingroom_dim
- id: '1585550904757'
alias: Stopped Media
description: Media is either not playing, or paused.
trigger:
- entity_id: media_player.plex_plex_for_vizio_vizio_smartcast
from: playing
platform: state
to: idle
condition: []
action:
- scene: scene.livingroom_normal
Should they be Double Quotes or Single Quotes as you mentioned before. I know in some languages they are interpreted differently, but I don’t know about yml.
In this specific situation, either single or double can be used.
Where you need to pay attention is when the situation requires nested quotes. In that case, the outer ones should be different (i.e. double) from the inner ones (i.e. single).
Ok. Do you know if it is possible to add Disney Plus to a source_list. Currently my wife is watching Disney+ with Vizio SmartCast and the data shows app_id: _UNKNOWN_APP app_name: _UNKNOWN_APP
I don’t use the Plex integration so I don’t know the answer. FWIW, that question is unrelated to why the automation fails to trigger and merits its own separate topic. By posting a second unrelated question in this topic, you reduce the chances of someone (who knows the answer) from seeing it because this topic’s title is all about the first question.
Whenever you get a chance to test it, let us know if the solution I offered (above) solves the problem.
are you positively sure about that rule?
I’ve always thought to have learned the rule of thumb to be quoting is only necessary to prevent the YAML parser interpreting values as booleans. Which are 1/0, on/off, yes/no, true/false.
home/not_home are no booleans so don’t need quoting, nor do the alarm states.
that’s why this works fine:
- alias: 'Send notification when alarm is Disarmed'
trigger:
platform: state
entity_id: alarm_control_panel.ha_rpi4_alarm
to: disarmed #<-- unquoted
condition:
condition: state
entity_id: input_boolean.notify_alarm
state: 'on' # <-- needs a quote
action:
service: notify.notify
data_template:
message: >
ALARM! The alarm is Disarmed at {{states('sensor.date_time')}}
do you have a source? I recently stumbled upon this
As simple rule of thumb, if your data contains any of these characters :-{}[]!#|>&%@ better quote it. Also quote it if you want a string but it could be mistaken for a valid number (integer or float) or if it consists only of “Yes”, “No”, “yes”, “no”, “true” or “false”, which would be converted to a boolean without quotes.
What exactly did you do as it sounds a bit strange - what’s “triggering the scene”?
Anyway, take a look at this, especially the second paragraph. To activate a scene you need to call a service but
doesn’t have one. it should be
- id: '1585550781277'
alias: Playing Media
trigger:
- entity_id: media_player.plex_plex_for_vizio_vizio_smartcast
from: idle
platform: state
to: playing
action:
- service: scene.turn_on
entity_id: scene.livingroom_dim
- id: '1585550904757'
alias: Stopped Media
description: Media is either not playing, or paused.
trigger:
- entity_id: media_player.plex_plex_for_vizio_vizio_smartcast
from: playing
platform: state
to: idle
action:
- service: scene.turn_on
entity_id: scene.livingroom_normal
ha yes, a good source. Ive grown used to quoting alphanumerical characters. It is necessary because those characters can breakup a string, so if you want it to be the full string, keep it together with the quotes. A good editor shows that. (using Bbedit myself)
btw it doesn’t end there. Eg, what does ‘better quote it’ mean It means it depends on the situation… iow, one always has to check for validity.
Of course, after a while one gets to recognize the uncertainties.
which often happen when handling numbers. when does Yaml recognize it as a number and when is it a string… using numeric_trigger solves the for you but then you cant use state: … in templates, remember a number is always a string unless you make it a number using |float or |int
nope… unfortunately you have to rewrite those into your scripts now… was an ‘improvement’ some versions ago… which has a rather huge downside: a light uses its transitioned brightness as its last brightness now, meaning when you turn it on again, it is dimmed to 0% (in a use case where one transitions the lights to ‘Off’) (which was my most used scene/scenario…) before, the scene was transitioned, and didn’t touch that.
well, do you think it’s down to YAML here?
I think between YAML and your code (python) is HA processing as HA runs YAML parser and then filters and refines data and packs it into data variable, for example.
so it’s more than YAML alone here in HA world I presume.
sure. dont forget javascript, and its templates , and it’s special way of treating states/values. Still, I find the Yaml code to be the most demanding, and python can be more forgiving.
yeah, and well, it’s not just demanding, it’s about understanding some subtle concepts.
I spent 2 days to find a way to instruct card-mod to create a dictionary to change several attributes at different levels of the same parent element like this
hui-input-number-entity-row:
$:
hui-generic-entity-row:
# hide icon and name
$: |
state-badge {display: none}
div.info.text-content {visibility: hidden}
# set font size and input width
paper-input:
$:
paper-input-container: |
iron-input {
font-size: 20px
width: '3rem'
}
well, tbh, that’s a bit outside the scope of this thread, and most certainly deserves its own. A thread for best/use-cases of card-mod, because many people seem to be lost there (count me among those)